Quick Start ⚡

This tutorial demonstrates how to bring up a PCAL9555A expander using the library on any platform.

  1. Include the header and create an I2C implementation
1
2
3
4
5
6
#include "pcal95555.hpp"

class MyI2C : public pcal95555::I2cInterface<MyI2C> {
    bool write(uint8_t addr, uint8_t reg, const uint8_t *data, size_t len) override;
    bool read(uint8_t addr, uint8_t reg, uint8_t *data, size_t len) override;
};
  1. Instantiate the driver
1
2
MyI2C i2c;
PACL95555 gpio(&i2c, 0x20); // default I2C address
  1. Reset the expander to a known state and configure pins
1
2
gpio.ResetToDefault(); // all pins become inputs with pull-ups
gpio.SetPinDirection(0, PACL95555::GPIODir::Output);
  1. Toggle outputs and read inputs
1
2
gpio.WritePin(0, true);
bool input = gpio.ReadPin(1);
  1. Handle interrupts (optional)
1
2
3
4
auto callback = [](uint16_t status) {
    // respond to interrupts here
};
gpio.SetInterruptCallback(callback);

These minimal steps bring the expander online. The library exposes many more functions for configuring pull resistors, drive strength and polarity. Refer to the API Reference once you are comfortable with the basics.

For more advanced configuration, see the Configuration guide.


Navigation ⬅️ InstallationBack to Index • ➡️ Configuration