Skip to content

Driver

PCAL9555 Driver

A C++20 driver for the NXP PCA9555 and PCAL9555A 16-bit I2C GPIO expanders. It drives outputs, reads inputs and interrupt sources, and on the PCAL9555A sets drive strength, pull resistors, input latches and open-drain ports, on any MCU.

Quickstart API guide Source on GitHub

The driver has no platform code. You give it a small class that brings the bus up and moves bytes; it does the rest: the presence and identity checks, the register pairs, the write order that avoids glitches, and a copy of every register so that a pin change is one transfer, and the check that finds a power-on reset before a stale copy is written over it.

16-bit I2C GPIO expander PCA9555 / PCAL9555A NXP Semiconductors
Function
16 I/O pins in two 8-pin ports; each pin an input or a latched output, with input polarity inversion
Interface
I2C up to 400 kHz; 7-bit address 0x20 to 0x27 from the A2, A1 and A0 pins
Interrupt
Open-drain INT on any input change, cleared by reading the input port
Agile I/O (PCAL9555A)
Four drive strengths per pin, 100 kΩ pull-up or pull-down per pin, input latch, interrupt mask and status, push-pull or open-drain per port
Supply
PCA9555 2.3 V to 5.5 V; PCAL9555A 1.65 V to 5.5 V

What you get

  • One object per chip. PCAL9555<YourPort> takes your port, the address and a Config, and does no I/O until EnsureInitialized(). See API guide.
  • Both parts, one API. Config::variant names the part; on a PCA9555 the Agile I/O calls return Unsupported without touching the bus. See Agile I/O.
  • Errors you can act on. Every call returns Result<T> with an Error such as Bus, DeviceIdMismatch or Unsupported. See API guide.
  • Datasheet defaults. Config{} holds the power-up value of every register. See Configuration.
  • A tiny port. Three bus hooks and an optional log hook, checked by a concept at compile time. The chip needs no delays and has no reset pin. See Porting.
  • No heap, no exceptions, no RTTI. The host tests build with -fno-exceptions -fno-rtti. See Contract.
  • Tested without hardware. Host tests run the driver against a protocol model of the chip, with every bus transfer failed in turn. See Testing and CI.

Datasheet

Document Revision Get it
Datasheet: PCAL9555A Low-voltage 16-bit I2C-bus GPIO with Agile I/O, interrupt and weak pull-up (NXP PCAL9555A) Rev. 2, 2014-12-19 PDF · vendor page
Datasheet: PCA9555 16-bit I2C-bus and SMBus I/O port with interrupt (NXP PCA9555) Rev. 10, 2017-11-08 PDF · vendor page

Written against these revisions; the SHA-256 of each file is in docs/datasheets.yml. Where each part of the driver is in the datasheet: Datasheet map.

Where to go next

  • Quickstart


    Wire the chip, write the port, blink an LED and read a button.

  • Hardware


    Pins, addresses, bus transactions, interrupt and power.

  • Contract


    What the driver promises, what it needs, threading and errors.

  • API guide


    Start, drive outputs, read inputs, handle interrupts and errors, task by task.

  • Agile I/O


    The PCAL9555A extras: drive strength, pull resistors, latches, interrupt mask.

  • API reference


    Every class and member, generated from the headers.