![]() |
Laelaps
2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
|
control register mask More...
#include <laeI2CMux.h>
Public Member Functions | |
LaeI2CMux (LaeI2C &i2cBus, uint_t addr=LaeI2CMuxAddrDft) | |
Initialization constructor. More... | |
virtual | ~LaeI2CMux () |
Destructor. | |
virtual int | read (int chan, uint_t addr, byte_t buf[], size_t len) |
Read from a multiplexed I2C slave endpoint device. More... | |
virtual int | write (int chan, uint_t addr, byte_t buf[], size_t len) |
Write from an I2C endpoint device. More... | |
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. More... | |
virtual int | readChannelStates (byte_t &chanBits) |
Read the current I2C multiplexer enable state. More... | |
virtual int | reset () |
Reset I2C devices on multiplexer bus. More... | |
bool | isChanEnabled (int chan, byte_t chanBits) |
Check if a channel is enabled in the channel bit map. More... | |
std::string | getDevName () |
Get associated I2C device name. More... | |
bool | isOpen () |
Check if bound I2C device is open. More... | |
Protected Member Functions | |
void | lock () |
Lock the shared resource. More... | |
void | unlock () |
Unlock the shared resource. More... | |
int | setChannel (int chan) |
Set channel. More... | |
Protected Attributes | |
LaeI2C & | m_i2cBus |
boulnd I2C bus instance | |
uint_t | m_addrMux |
I2C multiplexer address. | |
int | m_chan |
current active channel | |
pthread_mutex_t | m_mutex |
mutex | |
control register mask
TI PCA9548A I2C mulitplexer switch class.
Definition at line 100 of file laeI2CMux.h.
LaeI2CMux::LaeI2CMux | ( | LaeI2C & | i2cBus, |
uint_t | addr = LaeI2CMuxAddrDft |
||
) |
Initialization constructor.
i2cbus | Bound open I2C bus instance. |
addr | I2C Mux address. |
Definition at line 63 of file laeI2CMux.cxx.
References laelaps::LaeI2CMuxChanNone, m_chan, and m_mutex.
|
inline |
Get associated I2C device name.
Definition at line 206 of file laeI2CMux.h.
References laelaps::LaeI2C::getDevName(), and m_i2cBus.
|
inline |
Check if a channel is enabled in the channel bit map.
chan | Multiplexed channel number. |
chanBits | Bit map of enable/disable channels. |
Definition at line 196 of file laeI2CMux.h.
|
inline |
Check if bound I2C device is open.
Definition at line 216 of file laeI2CMux.h.
References laelaps::LaeI2C::isOpen(), and m_i2cBus.
Referenced by Laelaps.WatchDog.WatchDog::cmdConfigDPin(), Laelaps.WatchDog.WatchDog::cmdEnableAuxPort5V(), Laelaps.WatchDog.WatchDog::cmdEnableAuxPortBatt(), Laelaps.WatchDog.WatchDog::cmdEnableMotorCtlrs(), Laelaps.WatchDog.WatchDog::cmdGetFwVersion(), Laelaps.WatchDog.WatchDog::cmdPetTheDog(), Laelaps.WatchDog.WatchDog::cmdReadAPin(), Laelaps.WatchDog.WatchDog::cmdReadDPin(), Laelaps.WatchDog.WatchDog::cmdReadEnables(), Laelaps.WatchDog.WatchDog::cmdReadVoltages(), Laelaps.WatchDog.WatchDog::cmdResetRgbLed(), Laelaps.WatchDog.WatchDog::cmdSetAlarms(), Laelaps.WatchDog.WatchDog::cmdSetBatterySoC(), Laelaps.WatchDog.WatchDog::cmdSetRgbLed(), and Laelaps.WatchDog.WatchDog::cmdWriteDPin().
|
inlineprotected |
Lock the shared resource.
The lock()/unlock() primitives provide for safe multi-threading.
Definition at line 237 of file laeI2CMux.h.
Referenced by read(), readChannelStates(), transact(), and write().
|
virtual |
Read from a multiplexed I2C slave endpoint device.
Reads data from a device at the given address on the bound I2C bus.
chan | Multiplexed channel number. | |
addr | Endpoint I2C device's 7/10-bit address. | |
[out] | buf | Pointer to the buffer that will receive the data bytes. |
len | Number of bytes to read. |
Definition at line 76 of file laeI2CMux.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, lock(), m_chan, m_i2cBus, laelaps::LaeI2C::read(), setChannel(), and unlock().
|
virtual |
Read the current I2C multiplexer enable state.
[out] | chanBits | Bit map of enable/disable channels. |
Definition at line 163 of file laeI2CMux.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, lock(), m_addrMux, m_i2cBus, laelaps::LaeI2C::read(), and unlock().
|
inlinevirtual |
Reset I2C devices on multiplexer bus.
Definition at line 182 of file laeI2CMux.h.
References laelaps::LAE_ECODE_INTERNAL.
|
protected |
Set channel.
This function does not call the lock/unlock mutex.
chan | Multiplexed channel number. |
Definition at line 185 of file laeI2CMux.cxx.
References laelaps::LAE_ECODE_BAD_VAL, laelaps::LAE_ECODE_IO, laelaps::LAE_OK, laelaps::LaeI2CMuxChanMax, laelaps::LaeI2CMuxChanMin, m_addrMux, m_chan, m_i2cBus, and laelaps::LaeI2C::write().
Referenced by read(), transact(), unlock(), and write().
|
virtual |
Perform a write/read transaction to/from an I2C slave endpoint device.
chan | Multiplexed channel number. | |
addr | Endpoint I2C device's 7/10-bit address. | |
[in] | wbuf | Pointer to the buffer that contains the data to be written. |
wlen | Number of bytes to write. | |
[out] | rbuf | Pointer to the buffer that will receive the data. |
rlen | Number of bytes to read. | |
usec | Delay between write and read operations (usecs). |
Definition at line 136 of file laeI2CMux.cxx.
References laelaps::LAE_OK, lock(), m_chan, m_i2cBus, setChannel(), unlock(), and laelaps::LaeI2C::write_read().
Referenced by sensor::vl6180::LaeVL6180Mux::readReg16(), and sensor::vl6180::LaeVL6180Mux::readReg8().
|
inlineprotected |
Unlock the shared resource.
Definition at line 248 of file laeI2CMux.h.
References setChannel().
Referenced by read(), readChannelStates(), transact(), and write().
|
virtual |
Write from an I2C endpoint device.
Write data to a device at the given address on the bound I2C bus.
chan | Multiplexed channel number. |
addr | Endpoint I2C device's 7/10-bit address. |
[int] | buf Pointer to the buffer that will be written. |
len | Number of bytes to write. |
Definition at line 106 of file laeI2CMux.cxx.
References laelaps::LAE_ECODE_IO, laelaps::LAE_OK, lock(), m_chan, m_i2cBus, setChannel(), unlock(), and laelaps::LaeI2C::write().
Referenced by sensor::vl6180::LaeVL6180Mux::writeReg16(), and sensor::vl6180::LaeVL6180Mux::writeReg8().