I2cDiscreteIoExpander
v4.0.1
Arduino library for TI PCF8575C 16-bit I2C I/O expander.
|
Public Member Functions | |
I2cDiscreteIoExpander (uint8_t) | |
Constructor. More... | |
uint8_t | digitalRead () |
Retrieve discrete values from device. More... | |
uint8_t | digitalWrite (uint16_t) |
Write discrete values to device. More... | |
uint8_t | getAddress () |
Retrieve device address. More... | |
uint16_t | getPorts () |
Retrieve ports 1 (P17..P10), 0 (P07..P00). More... | |
void | enableBitwiseInversion () |
Enable bitwise inversion. More... | |
void | disableBitwiseInversion () |
Disable bitwise inversion. More... | |
bool | isInverted () |
Indicate whether bitwise inversion is enabled. More... | |
Private Attributes | |
uint8_t | address_ |
Device address as defined by pins A2, A1, A0. | |
uint16_t | ports_ |
Storage object for I2cDiscreteIoExpander ports 1 (P17..P10), 0 (P07..P00). | |
bool | shouldInvert_ |
Flag indicating whether bits are to be inverted before read/write (false=don't invert, true=invert). | |
Static Private Attributes | |
static const uint8_t | BASE_ADDRESS_ = 0x20 |
Factory pre-set slave address. | |
Related Functions | |
(Note that these are not member functions.) | |
static const uint8_t | TWI_SUCCESS = 0 |
I2C/TWI success (transaction was successful). | |
static const uint8_t | TWI_DEVICE_NACK = 2 |
I2C/TWI device not present (address sent, NACK received). | |
static const uint8_t | TWI_DATA_NACK = 3 |
I2C/TWI data not received (data sent, NACK received). | |
static const uint8_t | TWI_ERROR = 4 |
I2C/TWI other error. | |
I2cDiscreteIoExpander::I2cDiscreteIoExpander | ( | uint8_t | address | ) |
Constructor.
Assigns device address, resets storage object, enables bitwise inversion.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Assigns device address, resets storage object, enables bitwise inversion.
uint8_t I2cDiscreteIoExpander::digitalRead | ( | ) |
Retrieve discrete values from device.
loop()
in order to read from device. 0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
uint8_t I2cDiscreteIoExpander::digitalWrite | ( | uint16_t | ports | ) |
Write discrete values to device.
loop()
in order to write to device. ports | word to be written to device (0x0000..0xFFFF) |
0 | success |
1 | length too long for buffer |
2 | address send, NACK received (device not on bus) |
3 | data send, NACK received |
4 | other twi error (lost bus arbitration, bus error, ...) |
uint8_t I2cDiscreteIoExpander::getAddress | ( | ) |
Retrieve device address.
uint16_t I2cDiscreteIoExpander::getPorts | ( | ) |
Retrieve ports 1 (P17..P10), 0 (P07..P00).
loop()
to retrieve ports. void I2cDiscreteIoExpander::enableBitwiseInversion | ( | ) |
Enable bitwise inversion.
All bits will be inverted prior to future read/write operations.
void I2cDiscreteIoExpander::disableBitwiseInversion | ( | ) |
Disable bitwise inversion.
Bits will not be inverted prior to future read/write operations.
bool I2cDiscreteIoExpander::isInverted | ( | ) |
Indicate whether bitwise inversion is enabled.