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

I2C channel-select decorator for the TCA9548A / PCA9548A. More...

#include <TCA9548AInterface.h>

Inheritance diagram for TCA9548AInterface:
I2CInterface

Public Member Functions

 TCA9548AInterface (I2CInterface *bus, uint8_t muxAddr, uint8_t channel)
 
void begin () override
 Initialise the underlying bus and invalidate this mux's channel cache.
 
void writeRegister (uint8_t devAddr, uint8_t reg, uint8_t val) override
 Activate this channel (if not already selected), then forward the write.
 
- Public Member Functions inherited from I2CInterface
virtual ~I2CInterface ()
 
virtual void writeByte (uint8_t addr, uint8_t data)
 Write a single data byte to a device (no register address byte).
 

Detailed Description

I2C channel-select decorator for the TCA9548A / PCA9548A.

writeRegister() selects this instance's channel on the mux (if not already selected) then forwards the write to the underlying bus. The matrix and driver layers are completely unaware of the multiplexer.

Channel state is cached per mux address in a function-local static array (8 bytes of BSS). Calling begin() invalidates the cache entry for this mux so the first subsequent write always emits the channel-select byte.

Constructor & Destructor Documentation

◆ TCA9548AInterface()

TCA9548AInterface::TCA9548AInterface ( I2CInterface bus,
uint8_t  muxAddr,
uint8_t  channel 
)
inline
Parameters
[in]busPhysical I2C bus; must outlive this object.
[in]muxAddrTCA9548A 7-bit address (0x70–0x77).
[in]channelBus segment to activate on writeRegister() (0–7).

Member Function Documentation

◆ begin()

void TCA9548AInterface::begin ( )
inlineoverridevirtual

Initialise the underlying bus and invalidate this mux's channel cache.

Call once per mux address in setup() before any matrix.begin() calls. Invalidating the cache guarantees the channel-select byte is sent on the very first writeRegister() even if that channel was previously active.

Reimplemented from I2CInterface.

◆ writeRegister()

void TCA9548AInterface::writeRegister ( uint8_t  devAddr,
uint8_t  reg,
uint8_t  val 
)
inlineoverridevirtual

Activate this channel (if not already selected), then forward the write.

When the channel is already active the mux write is suppressed entirely — zero overhead compared to a direct I2C connection.

Parameters
[in]devAddr7-bit address of the target device (e.g. MCP23017).
[in]regRegister index on the target device.
[in]valByte value to write.

Implements I2CInterface.


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