|
XPoint 0.1.0
Hardware-agnostic crosspoint matrix routing library
|
XPointDriver implementation for the MCP23017 16-bit I2C GPIO expander. More...
#include <MCP23017Driver.h>
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). | |
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.
| typedef uint8_t(* MCP23017Driver::MapFn) (uint8_t r, uint8_t c) |
Function pointer type: (row, col) → MCP23017 pin index 0–15.
| MCP23017Driver::MCP23017Driver | ( | I2CInterface * | i2c, |
| uint8_t | addr, | ||
| MapFn | map | ||
| ) |
Construct the driver.
| [in] | i2c | I2C bus implementation (WireI2C or MockI2C). |
| [in] | addr | 7-bit device address (0x20–0x27 set by A0–A2 pins). |
| [in] | map | Mapper; must return pin indices in [0, 15]. |
|
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.
|
inlineoverridevirtual |
No-op — MCP23017 writes commit inside setNodeHardware().
Reimplemented from XPointDriver.
|
inline |
Read the OLATA shadow register (for diagnostics / testing).
|
inline |
Read the OLATB shadow register (for diagnostics / testing).
|
overridevirtual |
Set or clear one output pin and immediately write both OLAT registers.
| [in] | r | Row index. |
| [in] | c | Column index. |
| [in] | state | true = pin HIGH, false = pin LOW. |
Implements XPointDriver.