modm API documentation
PCA9535 16-Bit I/O Expander

Classes

class  modm::pca9535< I2cMaster >
 

Detailed Description

lbuild module: modm:driver:pca9535

Also software-compatible with PCA9555. The lower three address bits can be configured: 0100abc.

Notice that you can specify multiple pins at the same time for functions with argument type Pins, either by ORing the according pins, or converting a 16-bit value using the Pins(uint16_t) converting constructor.

Other functions with argument type Pin can only take one pin. If you want to operate on all 16-bit, use the get(Inputs|Outputs|Directions|Polarities)() getters.

using Pin = expander.Pin;
using Pins = expander.Pins;
expander.setOutput(Pins(0xff); // set all lower 8 pins to output
expander.set(Pin::P0_0); // set only pin 00 high
expander.reset(Pin::P0_1 | Pin::P0_2); // reset 2 pins
expander.toggle(Pin::P0_3 | Pin::P0_4 | Pin::P0_5); // toggle 3 pins
expander.readInput(); // transfer input states from the external chip
bool high = expander.read(Pin::P1_0); // check a single pin
Pins input = expander.getInputs(); // get all 16 input states
bool isAnyPinHigh = input.any(Pin::P1_1 | Pin::P1_2 | Pin::P1_3); // check if any of 3 pins is high