PCA9555 / PCAL9555A Driver
API reference
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
pcal95555 Namespace Reference

Classes

class  I2cInterface
 CRTP-based template interface for I2C bus operations. More...
 
class  PCAL95555
 Driver for the PCA9555 / PCAL9555A / PCAL95555AHF I²C GPIO expander. More...
 
struct  PinReadResult
 Fixed-capacity result container for multi-pin read operations. More...
 

Enumerations

enum class  Pcal95555Reg : uint8_t {
  INPUT_PORT_0 = 0x00 , INPUT_PORT_1 = 0x01 , OUTPUT_PORT_0 = 0x02 , OUTPUT_PORT_1 = 0x03 ,
  POLARITY_INV_0 = 0x04 , POLARITY_INV_1 = 0x05 , CONFIG_PORT_0 = 0x06 , CONFIG_PORT_1 = 0x07 ,
  DRIVE_STRENGTH_0 = 0x40 , DRIVE_STRENGTH_1 = 0x41 , DRIVE_STRENGTH_2 = 0x42 , DRIVE_STRENGTH_3 = 0x43 ,
  INPUT_LATCH_0 = 0x44 , INPUT_LATCH_1 = 0x45 , PULL_ENABLE_0 = 0x46 , PULL_ENABLE_1 = 0x47 ,
  PULL_SELECT_0 = 0x48 , PULL_SELECT_1 = 0x49 , INT_MASK_0 = 0x4A , INT_MASK_1 = 0x4B ,
  INT_STATUS_0 = 0x4C , INT_STATUS_1 = 0x4D , OUTPUT_CONF = 0x4F
}
 Register addresses for the PCA9555 / PCAL9555A I/O expander chips. More...
 
enum class  GPIODir : uint8_t { Input = 1 , Output = 0 }
 
enum class  Polarity : uint8_t { Normal = 0 , Inverted = 1 }
 
enum class  DriveStrength : uint8_t { Level0 = 0 , Level1 = 1 , Level2 = 2 , Level3 = 3 }
 
enum class  OutputMode : uint8_t { PushPull = 0 , OpenDrain = 1 }
 
enum class  InterruptEdge : uint8_t { Rising = 1 , Falling = 2 , Both = 3 }
 
enum class  InterruptState : uint8_t { Enabled = 0 , Disabled = 1 }
 
enum class  Error : uint16_t {
  None = 0 , InvalidPin = 1 << 0 , InvalidMask = 1 << 1 , I2CReadFail = 1 << 2 ,
  I2CWriteFail = 1 << 3 , UnsupportedFeature = 1 << 4 , InvalidAddress = 1 << 5
}
 
enum class  ChipVariant : uint8_t { Unknown = 0 , PCA9555 = 1 , PCAL9555A = 2 }
 Identifies the detected or user-specified chip variant. More...
 
enum class  CtrlPin : uint8_t { INTN = 0 , RSTN }
 Identifies the hardware control pins of the PCAL95555. More...
 
enum class  GpioSignal : uint8_t { INACTIVE = 0 , ACTIVE = 1 }
 Abstract signal level for control pins. More...
 

Functions

constexpr Error operator| (Error lhs, Error rhs) noexcept
 Combine two Error flags.
 
constexpr Error operator& (Error lhs, Error rhs) noexcept
 Intersect two Error flags.
 
constexpr Error operator~ (Error e) noexcept
 Complement an Error flag (useful with ClearErrorFlags).
 
const char * GetDriverVersion () noexcept
 

Enumeration Type Documentation

◆ ChipVariant

enum class pcal95555::ChipVariant : uint8_t
strong

Identifies the detected or user-specified chip variant.

The driver supports both the standard PCA9555 and the enhanced PCAL9555A. The variant is auto-detected during initialization by probing an Agile I/O register. It can also be forced via the constructor to skip detection.

Enumerator
Unknown 

Not yet detected (pre-initialization)

PCA9555 

Standard PCA9555 (registers 0x00-0x07 only)

PCAL9555A 

NXP PCAL9555A with Agile I/O (registers 0x00-0x07 + 0x40-0x4F)

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ CtrlPin

enum class pcal95555::CtrlPin : uint8_t
strong

Identifies the hardware control pins of the PCAL95555.

Used with GpioSet() / GpioRead() to control or read the IC's dedicated GPIO pins through the I2cInterface.

  • INTN: Active-low interrupt output (read-only via GpioRead)

The PCA9555 and PCAL9555A have no reset input (PCAL9555A data sheet Rev. 2, table 3; PCA9555 Rev. 10, table 3): the only reset is power-on reset, and PCAL95555::ResetToDefault() rewrites the power-up register values instead. RSTN is kept only so existing ports still compile.

Enumerator
INTN 

Interrupt output (active-low, open-drain, read-only)

RSTN 

No such pin on these parts; never driven by the driver.

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555_i2c_interface.hpp.

◆ DriveStrength

enum class pcal95555::DriveStrength : uint8_t
strong

Output drive strength levels (00=¼, 11=full).

Enumerator
Level0 
Level1 
Level2 
Level3 
Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ Error

enum class pcal95555::Error : uint16_t
strong

Error conditions reported by the driver.

Enumerator
None 
InvalidPin 

Provided pin index out of range.

InvalidMask 

A mask-form call got a mask that selects no pin (0)

I2CReadFail 

An I2C read operation failed.

I2CWriteFail 

An I2C write operation failed.

UnsupportedFeature 

Feature requires PCAL9555A but chip is PCA9555.

InvalidAddress 

Provided I2C address is out of valid range (0x20-0x27)

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ GPIODir

enum class pcal95555::GPIODir : uint8_t
strong

GPIO direction (1=input, 0=output).

Enumerator
Input 
Output 
Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ GpioSignal

enum class pcal95555::GpioSignal : uint8_t
strong

Abstract signal level for control pins.

Decouples the driver's intent from the physical pin polarity.

Enumerator
INACTIVE 

Pin function is deasserted.

ACTIVE 

Pin function is asserted.

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555_i2c_interface.hpp.

◆ InterruptEdge

enum class pcal95555::InterruptEdge : uint8_t
strong

Interrupt edge trigger type.

Enumerator
Rising 

Trigger on rising edge (LOW to HIGH)

Falling 

Trigger on falling edge (HIGH to LOW)

Both 

Trigger on both edges.

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ InterruptState

enum class pcal95555::InterruptState : uint8_t
strong

Interrupt enable/disable state.

Enumerator
Enabled 

Interrupt enabled (mask bit = 0)

Disabled 

Interrupt disabled/masked (mask bit = 1)

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ OutputMode

enum class pcal95555::OutputMode : uint8_t
strong

Output mode (push-pull vs open-drain).

Enumerator
PushPull 
OpenDrain 
Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ Pcal95555Reg

enum class pcal95555::Pcal95555Reg : uint8_t
strong

Register addresses for the PCA9555 / PCAL9555A I/O expander chips.

PCAL95555 register map (all control registers).

The register map is split into two banks:

Standard PCA9555 registers (0x00-0x07) - Supported by both PCA9555 and PCAL9555A:

  • Input/Output registers (0x00-0x03): Read inputs and control outputs
  • Configuration registers (0x04-0x07): Configure polarity and port direction

PCAL9555A Agile I/O registers (0x40-0x4F) - PCAL9555A only:

  • Drive strength registers (0x40-0x43): Control output drive strength
  • Input/Pull registers (0x44-0x49): Configure input latching and pull-up/down
  • Interrupt registers (0x4A-0x4D): Manage interrupt mask and status
  • Output configuration (0x4F): Push-pull vs open-drain per port

Each register controls 8 pins, with PORT_0 handling pins 0-7 and PORT_1 handling pins 8-15.

Note
Accessing Agile I/O registers on a standard PCA9555 will result in I2C NACK. The driver auto-detects the chip variant and guards these registers accordingly.
Enumerator
INPUT_PORT_0 

Input port 0 (read-only) [PCA9555 + PCAL9555A].

INPUT_PORT_1 

Input port 1 (read-only) [PCA9555 + PCAL9555A].

OUTPUT_PORT_0 

Output port 0 [PCA9555 + PCAL9555A].

OUTPUT_PORT_1 

Output port 1 [PCA9555 + PCAL9555A].

POLARITY_INV_0 

Polarity inversion port 0 [PCA9555 + PCAL9555A].

POLARITY_INV_1 

Polarity inversion port 1 [PCA9555 + PCAL9555A].

CONFIG_PORT_0 

Configuration (direction) port 0 [PCA9555 + PCAL9555A].

CONFIG_PORT_1 

Configuration (direction) port 1 [PCA9555 + PCAL9555A].

DRIVE_STRENGTH_0 

Output drive strength port 0 low nibble [PCAL9555A only].

DRIVE_STRENGTH_1 

Output drive strength port 0 high nibble [PCAL9555A only].

DRIVE_STRENGTH_2 

Output drive strength port 1 low nibble [PCAL9555A only].

DRIVE_STRENGTH_3 

Output drive strength port 1 high nibble [PCAL9555A only].

INPUT_LATCH_0 

Input latch port 0 [PCAL9555A only].

INPUT_LATCH_1 

Input latch port 1 [PCAL9555A only].

PULL_ENABLE_0 

Pull-up/pull-down enable port 0 [PCAL9555A only].

PULL_ENABLE_1 

Pull-up/pull-down enable port 1 [PCAL9555A only].

PULL_SELECT_0 

Pull-up/pull-down selection port 0 [PCAL9555A only].

PULL_SELECT_1 

Pull-up/pull-down selection port 1 [PCAL9555A only].

INT_MASK_0 

Interrupt mask port 0 [PCAL9555A only].

INT_MASK_1 

Interrupt mask port 1 [PCAL9555A only].

INT_STATUS_0 

Interrupt status port 0 (read-only) [PCAL9555A only].

INT_STATUS_1 

Interrupt status port 1 (read-only) [PCAL9555A only].

OUTPUT_CONF 

Output port configuration [PCAL9555A only].

Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

◆ Polarity

enum class pcal95555::Polarity : uint8_t
strong

Input polarity inversion (0=normal, 1=inverted).

Enumerator
Normal 
Inverted 
Examples
/home/runner/work/hf-pcal95555-driver/hf-pcal95555-driver/inc/pcal95555.hpp.

Function Documentation

◆ GetDriverVersion()

const char * pcal95555::GetDriverVersion ( )
inlinenoexcept

◆ operator&()

constexpr Error pcal95555::operator& ( Error  lhs,
Error  rhs 
)
inlineconstexprnoexcept

Intersect two Error flags.

◆ operator|()

constexpr Error pcal95555::operator| ( Error  lhs,
Error  rhs 
)
inlineconstexprnoexcept

Combine two Error flags.

◆ operator~()

constexpr Error pcal95555::operator~ ( Error  e)
inlineconstexprnoexcept

Complement an Error flag (useful with ClearErrorFlags).