Skip to content

File I2cMux.h

File List > Firmware > Libraries > PanelGroup > Helpers > I2cMux > I2cMux.h

Go to the documentation of this file


#pragma once
#ifdef ARDUINO_ARCH_STM32

#include <Arduino.h>
#include <Wire.h>

namespace OpenSkyhawk {

class I2cMux {
public:
    explicit I2cMux(uint8_t addr = 0x70, TwoWire& wire = Wire);

    bool select(uint8_t channel, bool force = false);

    void disableAll();

    bool deviceAcks(uint8_t addr7);

private:
    uint8_t  _addr;         // TCA9548A 7-bit address
    TwoWire* _wire;         // bus the mux is on
    int8_t   _lastChannel;  // -1 = nothing selected yet; cache to skip redundant writes
};

}  // namespace OpenSkyhawk

#endif  // ARDUINO_ARCH_STM32