Skip to content

These module docs are in beta and may be incomplete.

modm:driver:pca9535: PCA9535 16-Bit I/O Expander

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;

RF_CALL_BLOCKING(expander.setOutput(Pins(0xff)); // set all lower 8 pins to output
RF_CALL_BLOCKING(expander.set(Pin::P0_0));       // set only pin 00 high
RF_CALL_BLOCKING(expander.reset(Pin::P0_1 | Pin::P0_2)); // reset 2 pins
RF_CALL_BLOCKING(expander.toggle(Pin::P0_3 | Pin::P0_4 | Pin::P0_5));    // toggle 3 pins

RF_CALL_BLOCKING(expander.readInput());  // transfer input states from the external chip
bool high =;    // 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


// Class
class modm::Pca9535< typename I2cMaster  >;
// Struct
struct modm::pca9535;


modm:driver:pca9535 modm_driver_pca9535 modm: driver: pca9535 modm_architecture_gpio_expander modm: architecture: gpio.expander modm_driver_pca9535->modm_architecture_gpio_expander modm_architecture_i2c_device modm: architecture: i2c.device modm_driver_pca9535->modm_architecture_i2c_device modm_architecture_register modm: architecture: register modm_driver_pca9535->modm_architecture_register modm_driver modm: driver modm_driver_pca9535->modm_driver modm_math_utils modm: math: utils modm_driver_pca9535->modm_math_utils modm_processing_resumable modm: processing: resumable modm_driver_pca9535->modm_processing_resumable