Class OpenSkyhawk::I2cMux
ClassList > OpenSkyhawk > I2cMux
Selects one downstream channel of a TCA9548A I2C multiplexer. More...
#include <I2cMux.h>
Public Functions
| Type | Name |
|---|---|
| I2cMux (uint8_t addr=0x70, TwoWire & wire=Wire) Construct a mux handle. No I2C occurs here. |
|
| bool | deviceAcks (uint8_t addr7) Probe a downstream device on the CURRENTLY SELECTED channel — does it ACK? |
| void | disableAll () Disable all channels (control byte 0x00). Optional bus quiescing. |
| bool | select (uint8_t channel, bool force=false) Route the bus to one downstream channel. |
Detailed Description
Stateless beyond a last-selected cache: select(ch) writes the 1-of-8 channel bitmask to the TCA9548A control register only when the requested channel differs from the last one written, so repeated select() of the same channel costs no I2C. Construct one per physical TCA9548A. The sketch owns Wire.begin(); I2cMux never starts the bus and performs no I2C in its constructor.
Public Functions Documentation
function I2cMux
Construct a mux handle. No I2C occurs here.
explicit OpenSkyhawk::I2cMux::I2cMux (
uint8_t addr=0x70,
TwoWire & wire=Wire
)
Parameters:
addrTCA9548A 7-bit I2C address (0x70–0x77 via A0/A1/A2). Default 0x70.wireI2C bus the mux sits on. Default Wire (I2C1 on STM32).
function deviceAcks
Probe a downstream device on the CURRENTLY SELECTED channel — does it ACK?
bool OpenSkyhawk::I2cMux::deviceAcks (
uint8_t addr7
)
Parameters:
addr77-bit address of the device behind the selected branch.
Returns:
true if the device ACKs. Call select(channel) first to route the bus to it.
function disableAll
Disable all channels (control byte 0x00). Optional bus quiescing.
void OpenSkyhawk::I2cMux::disableAll ()
function select
Route the bus to one downstream channel.
bool OpenSkyhawk::I2cMux::select (
uint8_t channel,
bool force=false
)
Parameters:
channelChannel 0–7. Values above 7 are clamped to 7.forceWrite the channel byte even if it matches the cache. Use on health/recovery paths: a TCA9548A that reset / power-glitched comes back with no channel selected while the cache still matches, so a plain select() would skip the write and the branch would stay dark forever.
Returns:
true if the channel is selected (write ACKed, or already current and not forced); false on I2C NAK — also invalidates the cache so the next select re-routes.
Note:
Writes a single byte (1 << channel); skipped when channel == last selected unless forced. Callers sharing one mux across several devices MUST call this immediately before each downstream I2C op — an interleaved driver can change the channel.
The documentation for this class was generated from the following file Firmware/Libraries/PanelGroup/Helpers/I2cMux/I2cMux.h