53 #include "rnr/rnrconfig.h"    63 LaeI2CMux::LaeI2CMux(
LaeI2C &i2cBus, uint_t addr) :
    64     m_i2cBus(i2cBus), m_addrMux(addr)
    68   pthread_mutex_init(&
m_mutex, NULL);
    73   pthread_mutex_destroy(&
m_mutex);
    87       LOGDIAG3(
"I2C Mux: Channel %d I2C device address 0x%02x: "    88           "Failed to read from endpoint device data.",
    95       LOGWARN(
"I2C Mux: Channel %d I2C device address 0x%02x: "    96           "Only %d/%d bytes read from endpoint device.",
    97           m_chan, addr, n, (
int)len);
   103   return rc < 0? rc: n;
   117       LOGDIAG3(
"I2C Mux: Channel %d I2C device address 0x%02x: "   118           "Failed to write to device data.",
   123     else if( n != (
int)len )
   125       LOGWARN(
"I2C Mux: Channel %d I2C device address 0x%02x: "   126           "Only %d/%d bytes written to endpoint device.",
   127           m_chan, addr, n, (
int)len);
   133   return rc < 0? rc: n;
   137                         const byte_t wbuf[], 
size_t wlen,
   138                         byte_t rbuf[], 
size_t rlen,
   152       LOGDIAG3(
"I2C Mux: Channel %d I2C device address 0x%02x: "   153           "Failed to write_read to device data.",
   160   return rc < 0? rc: n;
   171     LOGSYSERROR(
"I2C Mux: Address 0x%02x: Failed to read channel states.",
   189     LOGERROR(
"I2C Mux: %d channel: Out-of-range.", chan);
   195     byte_t  ctl = (byte_t)(1 << chan);    
   199       LOGSYSERROR(
"I2C Mux: Address 0x%02x: Failed to select channel.",
 int setChannel(int chan)
Set channel. 
virtual int write_read(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. 
static const int LAE_ECODE_IO
I/O error. 
uint_t m_addrMux
I2C multiplexer address. 
const int LaeI2CMuxChanNone
no channel selected 
Laelaps PCA9548A I2C multiplexer switch interface. 
Laelaps I2C class interface. 
LaeI2C & m_i2cBus
boulnd I2C bus instance 
virtual ~LaeI2CMux()
Destructor. 
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 
virtual int read(uint_t addr, byte_t buf[], size_t len)
Read from a I2C slave endpoint device. 
The <b><i>Laelaps</i></b> namespace encapsulates all <b><i>Laelaps</i></b> related constructs...
virtual int write(uint_t addr, const byte_t buf[], size_t len)
Write to an I2C slave endpoint device. 
const int LaeI2CMuxChanMax
min channel number 
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 int LaeI2CMuxChanMin
min channel number 
static const int LAE_ECODE_BAD_VAL
bad value general error 
void lock()
Lock the shared resource. 
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. 
static const int LAE_OK
not an error, success