50 #ifndef _LAE_I2C_MUX_H 51 #define _LAE_I2C_MUX_H 55 #include "rnr/rnrconfig.h" 91 const byte_t LaeI2CMuxCtlRegMask = 0xff;
130 virtual int read(
int chan, uint_t addr, byte_t buf[],
size_t len);
146 virtual int write(
int chan, uint_t addr, byte_t buf[],
size_t len);
163 virtual int transact(
int chan, uint_t addr,
164 const byte_t wbuf[],
size_t wlen,
165 byte_t rbuf[],
size_t rlen,
198 return (LaeI2CMuxCtlRegMask & ((byte_t)(1 << chan) & chanBits)) != 0;
239 pthread_mutex_lock(&m_mutex);
250 pthread_mutex_unlock(&m_mutex);
271 #endif // _LAE_I2C_MUX_H int setChannel(int chan)
Set channel.
std::string getDevName()
Get associated I2C device name.
const i2c_addr_t LaeI2CMuxAddrDft
I2C default 7-bit address.
std::string getDevName()
Get associated I2C device name.
LaeI2CMux(LaeI2C &i2cBus, uint_t addr=LaeI2CMuxAddrDft)
Initialization constructor.
uint_t m_addrMux
I2C multiplexer address.
const int LaeI2CMuxChanNone
no channel selected
bool isOpen()
Check if bound I2C device is open.
Laelaps I2C class interface.
LaeI2C & m_i2cBus
boulnd I2C bus instance
virtual ~LaeI2CMux()
Destructor.
virtual int reset()
Reset I2C devices on multiplexer bus.
virtual int write(int chan, uint_t addr, byte_t buf[], size_t len)
Write from an I2C endpoint device.
pthread_mutex_t m_mutex
mutex
const i2c_addr_t LaeI2CMuxAddrMax
I2C maximum 7-bit address.
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
const int LaeI2CMuxChanMax
min channel number
bool isOpen()
Check if device is open.
bool isChanEnabled(int chan, byte_t chanBits)
Check if a channel is enabled in the channel bit map.
virtual int read(int chan, uint_t addr, byte_t buf[], size_t len)
Read from a multiplexed I2C slave endpoint device.
int m_chan
current active channel
const i2c_addr_t LaeI2CMuxAddrMin
I2C minimum 7-bit address.
const int LaeI2CMuxChanMin
min channel number
void lock()
Lock the shared resource.
static const int LAE_ECODE_INTERNAL
internal error (bug)
void unlock()
Unlock the shared resource.
virtual int transact(int chan, uint_t addr, const byte_t wbuf[], size_t wlen, byte_t rbuf[], size_t rlen, long usec=0)
Perform a write/read transaction to/from an I2C slave endpoint device.
virtual int readChannelStates(byte_t &chanBits)
Read the current I2C multiplexer enable state.
Top-level package include file.