XPoint 0.1.0
Hardware-agnostic crosspoint matrix routing library
Loading...
Searching...
No Matches
MCP23017Driver Class Reference

XPointDriver implementation for the MCP23017 16-bit I2C GPIO expander. More...

#include <MCP23017Driver.h>

Inheritance diagram for MCP23017Driver:
XPointDriver

Public Types

typedef uint8_t(* MapFn) (uint8_t r, uint8_t c)
 Function pointer type: (row, col) → MCP23017 pin index 0–15.
 

Public Member Functions

 MCP23017Driver (I2CInterface *i2c, uint8_t addr, MapFn map)
 Construct the driver.
 
void begin () override
 Set IODIRA and IODIRB to 0x00 (all outputs) then write OLATA/OLATB.
 
void setNodeHardware (uint8_t r, uint8_t c, bool state) override
 Set or clear one output pin and immediately write both OLAT registers.
 
void commitPhysicalUpdates () override
 No-op — MCP23017 writes commit inside setNodeHardware().
 
uint8_t gpioA () const
 Read the OLATA shadow register (for diagnostics / testing).
 
uint8_t gpioB () const
 Read the OLATB shadow register (for diagnostics / testing).
 
- Public Member Functions inherited from XPointDriver
virtual ~XPointDriver ()
 
virtual void setNodeLevel (uint8_t r, uint8_t c, uint16_t level)
 Set an analog drive level for node (r, c).
 
virtual void releaseNode (uint8_t, uint8_t)
 De-energize the coil that was pulsed on node (r, c).
 

Detailed Description

XPointDriver implementation for the MCP23017 16-bit I2C GPIO expander.

Maintains shadow copies of OLATA and OLATB to minimize I2C transactions; both registers are written atomically on each setNodeHardware() call.

Member Typedef Documentation

◆ MapFn

typedef uint8_t(* MCP23017Driver::MapFn) (uint8_t r, uint8_t c)

Function pointer type: (row, col) → MCP23017 pin index 0–15.

Constructor & Destructor Documentation

◆ MCP23017Driver()

MCP23017Driver::MCP23017Driver ( I2CInterface i2c,
uint8_t  addr,
MapFn  map 
)

Construct the driver.

Parameters
[in]i2cI2C bus implementation (WireI2C or MockI2C).
[in]addr7-bit device address (0x20–0x27 set by A0–A2 pins).
[in]mapMapper; must return pin indices in [0, 15].

Member Function Documentation

◆ begin()

void MCP23017Driver::begin ( )
overridevirtual

Set IODIRA and IODIRB to 0x00 (all outputs) then write OLATA/OLATB.

Must be called before the first setNodeHardware() so the device does not fight the MCU on the bus lines.

Implements XPointDriver.

◆ commitPhysicalUpdates()

void MCP23017Driver::commitPhysicalUpdates ( )
inlineoverridevirtual

No-op — MCP23017 writes commit inside setNodeHardware().

Reimplemented from XPointDriver.

◆ gpioA()

uint8_t MCP23017Driver::gpioA ( ) const
inline

Read the OLATA shadow register (for diagnostics / testing).

Returns
Current shadow value of OLATA.

◆ gpioB()

uint8_t MCP23017Driver::gpioB ( ) const
inline

Read the OLATB shadow register (for diagnostics / testing).

Returns
Current shadow value of OLATB.

◆ setNodeHardware()

void MCP23017Driver::setNodeHardware ( uint8_t  r,
uint8_t  c,
bool  state 
)
overridevirtual

Set or clear one output pin and immediately write both OLAT registers.

Parameters
[in]rRow index.
[in]cColumn index.
[in]statetrue = pin HIGH, false = pin LOW.

Implements XPointDriver.


The documentation for this class was generated from the following files: