IoAbstraction
Public Types | Public Member Functions | List of all members
PCF8574IoAbstraction Class Reference

#include <IoAbstractionWire.h>

Inheritance diagram for PCF8574IoAbstraction:
BasicIoAbstraction

Public Types

enum  { NEEDS_WRITE_FLAG , PINS_CONFIGURED_READ_FLAG , PCF8575_16BIT_FLAG , INVERTED_LOGIC }
 

Public Member Functions

 PCF8574IoAbstraction (uint8_t addr, uint8_t interruptPin, WireType wireInstance=nullptr, bool mode16bit=false, bool invertedLogic=false)
 
void overrideReadFlag ()
 
void pinDirection (pinid_t pin, uint8_t mode) override
 
void writeValue (pinid_t pin, uint8_t value) override
 
uint8_t readValue (pinid_t pin) override
 
void writePort (pinid_t pin, uint8_t port) override
 
uint8_t readPort (pinid_t pin) override
 
void attachInterrupt (pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
 
bool runLoop () override
 
- Public Member Functions inherited from BasicIoAbstraction
uint8_t digitalRead (pinid_t p)
 
void digitalWrite (pinid_t p, uint8_t v)
 
uint8_t digitalReadS (pinid_t p)
 
void digitalWriteS (pinid_t p, uint8_t v)
 
void writePortS (pinid_t p, uint8_t v)
 
uint8_t readPortS (pinid_t p)
 
void pinMode (pinid_t pin, uint8_t mode)
 
bool sync ()
 

Detailed Description

An implementation of BasicIoAbstraction that supports the PCF8574/PCF8575 i2c IO chip. Providing all possible capabilities of the chip in a similar manner to Arduino pins.

See also
ioFrom8574 for how to create an instance
ioDevicePinMode for setting pin modes

Constructor & Destructor Documentation

◆ PCF8574IoAbstraction()

PCF8574IoAbstraction::PCF8574IoAbstraction ( uint8_t  addr,
uint8_t  interruptPin,
WireType  wireInstance = nullptr,
bool  mode16bit = false,
bool  invertedLogic = false 
)

Construct a 8574 expander on i2c address and with interrupts connected to a given pin (0xff no interrupts)

Parameters
addrthe I2C address on the bus
interruptPinthe pin on the Arduino that the interrupt line is connected to
wireInstancethe instance of wire to use for this device, for example &Wire.
mode16bittransfer 16 bits of data. Used in 8575 expander.
invertedLogicinvert bits sent and received from the expander.

Member Function Documentation

◆ overrideReadFlag()

void PCF8574IoAbstraction::overrideReadFlag ( )
inline

Forces the device to start reading back state during syncs even if no pins are configured as read

◆ pinDirection()

void PCF8574IoAbstraction::pinDirection ( pinid_t  pin,
uint8_t  mode 
)
overridevirtual

sets the pin direction on the device, notice that on this device input is achieved by setting the port to high so it is always set as INPUT_PULLUP, even if INPUT is chosen

Reimplemented from BasicIoAbstraction.

◆ writeValue()

void PCF8574IoAbstraction::writeValue ( pinid_t  pin,
uint8_t  value 
)
overridevirtual

writes a new value to the device after a sync.

Reimplemented from BasicIoAbstraction.

◆ readValue()

uint8_t PCF8574IoAbstraction::readValue ( pinid_t  pin)
overridevirtual

reads a value from the last cached state - updated each sync

Reimplemented from BasicIoAbstraction.

◆ writePort()

void PCF8574IoAbstraction::writePort ( pinid_t  pin,
uint8_t  port 
)
overridevirtual

Writes a complete 8 bit port value, that is updated to the device each sync

Reimplemented from BasicIoAbstraction.

◆ readPort()

uint8_t PCF8574IoAbstraction::readPort ( pinid_t  pin)
overridevirtual

Reads the complete 8 bit byte from the last cached state, that is updated each sync.

Reimplemented from BasicIoAbstraction.

◆ attachInterrupt()

void PCF8574IoAbstraction::attachInterrupt ( pinid_t  pin,
RawIntHandler  intHandler,
uint8_t  mode 
)
overridevirtual

attaches an interrupt handler for this device. Notice for this device, all pin changes will be notified on any pin of the port, it is not configurable at the device level, the type of interrupt will also always be CHANGE.

Reimplemented from BasicIoAbstraction.

◆ runLoop()

bool PCF8574IoAbstraction::runLoop ( )
overridevirtual

updates settings on the board after changes

Reimplemented from BasicIoAbstraction.


The documentation for this class was generated from the following files: