PCAL9555 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
pcal9555_registers.hpp File Reference

PCA9555 / PCAL9555A register map: command bytes, fields and power-up defaults. More...

#include <cstdint>

Go to the source code of this file.

Namespaces

namespace  pcal9555
 The PCAL9555 driver: everything it declares lives here; internals in detail.
 
namespace  pcal9555::reg
 The PCA9555 / PCAL9555A register map.
 

Functions

constexpr bool pcal9555::reg::IsImplemented (uint8_t command, bool agile) noexcept
 Whether a part implements a command byte (table 4): 0x00 to 0x07 on both parts, and on the PCAL9555A also 0x40 to 0x4D and 0x4F. The PCA9555 data sheet does not define its answer to any other command byte, so the driver never sends one.
 

Variables

constexpr uint8_t pcal9555::reg::kInputPort0 = 0x00
 Input port 0 (R): pin levels; 0x01 is port 1.
 
constexpr uint8_t pcal9555::reg::kOutputPort0 = 0x02
 Output port 0 (R/W); 0x03 is port 1.
 
constexpr uint8_t pcal9555::reg::kPolarityPort0 = 0x04
 Polarity inversion 0 (R/W); 0x05 is port 1.
 
constexpr uint8_t pcal9555::reg::kConfigPort0 = 0x06
 Configuration 0 (R/W): 1 = input; 0x07 port 1.
 
constexpr uint8_t pcal9555::reg::kDriveStrength0 = 0x40
 Drive strength 0 (R/W): P0_0-3; 0x41 P0_4-7.
 
constexpr uint8_t pcal9555::reg::kDriveStrength2 = 0x42
 Drive strength 2 (R/W): P1_0-3; 0x43 P1_4-7.
 
constexpr uint8_t pcal9555::reg::kInputLatch0 = 0x44
 Input latch 0 (R/W): 1 = latched; 0x45 port 1.
 
constexpr uint8_t pcal9555::reg::kPullEnable0 = 0x46
 Pull-up/pull-down enable 0 (R/W); 0x47 port 1.
 
constexpr uint8_t pcal9555::reg::kPullSelect0 = 0x48
 Pull-up/pull-down selection 0 (R/W): 1 = pull-up.
 
constexpr uint8_t pcal9555::reg::kInterruptMask0 = 0x4A
 Interrupt mask 0 (R/W): 1 = masked.
 
constexpr uint8_t pcal9555::reg::kInterruptStatus0 = 0x4C
 Interrupt status 0 (R); 0x4D is port 1.
 
constexpr uint8_t pcal9555::reg::kOutputPortConfig = 0x4F
 Output port configuration (R/W).
 
constexpr uint8_t pcal9555::reg::kOutputConfigOden0 = 1U << 0
 0x4F ODEN0: port 0 open-drain.
 
constexpr uint8_t pcal9555::reg::kOutputConfigOden1 = 1U << 1
 
constexpr uint16_t pcal9555::reg::kIdentityPattern = 0x55AA
 
constexpr uint8_t pcal9555::reg::kOutputConfigReservedMask = 0xFC
 0x4F bits 7..2 are reserved and read 0 (PCAL9555A table 27).
 
constexpr uint32_t pcal9555::reg::kDriveBitsPerPin = 2U
 Bits per pin in the drive strength registers: pin n of a port uses bits 2(n%4)+1..2(n%4).
 
constexpr uint32_t pcal9555::reg::kDriveCodeMask = 0x3
 Mask of one pin's drive strength code.
 
constexpr uint16_t pcal9555::reg::kOutputReset = 0xFFFF
 Output ports: every pin high.
 
constexpr uint16_t pcal9555::reg::kPolarityReset = 0x0000
 Polarity inversion: none.
 
constexpr uint16_t pcal9555::reg::kConfigReset = 0xFFFF
 
constexpr uint32_t pcal9555::reg::kDriveStrengthReset = 0xFFFF'FFFFU
 Drive strength: full on every pin (0x40 to 0x43 all 0xFF).
 
constexpr uint16_t pcal9555::reg::kInputLatchReset = 0x0000
 Input latch: off.
 
constexpr uint16_t pcal9555::reg::kPullEnableReset = 0xFFFF
 Pull resistors: enabled.
 
constexpr uint16_t pcal9555::reg::kPullSelectReset = 0xFFFF
 Pull resistors: pull-up.
 
constexpr uint16_t pcal9555::reg::kInterruptMaskReset = 0xFFFF
 Interrupts: every pin masked.
 
constexpr uint8_t pcal9555::reg::kOutputPortConfigReset = 0x00
 Both ports push-pull.
 

Detailed Description

PCA9555 / PCAL9555A register map: command bytes, fields and power-up defaults.

Section and table numbers refer to the NXP PCAL9555A data sheet, Rev. 2 (section 6.2, table 4) and the NXP PCA9555 data sheet, Rev. 10 (section 6.2).

Registers are 8 bits wide and come in pairs: port 0 at the even command byte, port 1 at the odd one. After the command byte the chip toggles between the two registers of a pair on each data byte (section 7); it does not step on to the next pair. The driver therefore moves at most two bytes per transfer, port 0 first, and treats a pair as one 16-bit value with port 0 in bits 7..0 (pins 0 to 7 are P0_0 to P0_7, pins 8 to 15 are P1_0 to P1_7).

The PCA9555 has the registers 0x00 to 0x07 only. The PCAL9555A adds the Agile I/O bank at 0x40 to 0x4F (0x4E is not used).