XPoint 0.1.0
Hardware-agnostic crosspoint matrix routing library
Loading...
Searching...
No Matches
MCP23017Driver.h
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (c) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
3// https://github.com/dstroy0/XPoint
4
26#ifndef MCP23017_DRIVER_H
27#define MCP23017_DRIVER_H
28
29#include "I2CInterface.h"
30#include "XPointDriver.h"
31#include <stdint.h>
32
40{
41 public:
43 typedef uint8_t (*MapFn)(uint8_t r, uint8_t c);
44
52 MCP23017Driver(I2CInterface *i2c, uint8_t addr, MapFn map);
53
60 void begin() override;
61
69 void setNodeHardware(uint8_t r, uint8_t c, bool state) override;
70
72 void commitPhysicalUpdates() override
73 {
74 }
75
80 uint8_t gpioA() const
81 {
82 return _ga;
83 }
84
89 uint8_t gpioB() const
90 {
91 return _gb;
92 }
93
94 private:
95 I2CInterface *_i2c;
96 uint8_t _addr;
97 MapFn _map;
98 uint8_t _ga;
99 uint8_t _gb;
100
102 void _commit();
103};
104
105#endif // MCP23017_DRIVER_H
Minimal abstract I2C interface consumed by MCP23017Driver.
Abstract hardware driver interface for the XPoint crosspoint matrix.
Abstract I2C bus interface.
Definition I2CInterface.h:28
XPointDriver implementation for the MCP23017 16-bit I2C GPIO expander.
Definition MCP23017Driver.h:40
void setNodeHardware(uint8_t r, uint8_t c, bool state) override
Set or clear one output pin and immediately write both OLAT registers.
Definition MCP23017Driver.cpp:28
void begin() override
Set IODIRA and IODIRB to 0x00 (all outputs) then write OLATA/OLATB.
Definition MCP23017Driver.cpp:18
uint8_t gpioB() const
Read the OLATB shadow register (for diagnostics / testing).
Definition MCP23017Driver.h:89
void commitPhysicalUpdates() override
No-op — MCP23017 writes commit inside setNodeHardware().
Definition MCP23017Driver.h:72
uint8_t(* MapFn)(uint8_t r, uint8_t c)
Function pointer type: (row, col) → MCP23017 pin index 0–15.
Definition MCP23017Driver.h:43
uint8_t gpioA() const
Read the OLATA shadow register (for diagnostics / testing).
Definition MCP23017Driver.h:80
Abstract base class for all XPoint hardware drivers.
Definition XPointDriver.h:41