49 #include <sys/types.h> 54 #include "rnr/rnrconfig.h" 96 virtual int open(
const std::string &strDevName);
112 virtual bool check(uint_t addr);
127 virtual int read(uint_t addr, byte_t buf[],
size_t len);
142 virtual int write(uint_t addr,
const byte_t buf[],
size_t len);
164 virtual int transfer(uint_t addr,
const byte_t wbuf[],
size_t wlen,
165 byte_t rbuf[],
size_t rlen);
184 virtual int write_read(uint_t addr,
const byte_t wbuf[],
size_t wlen,
185 byte_t rbuf[],
size_t rlen,
205 return m_i2c.fd >= 0?
true:
false;
223 pthread_mutex_lock(&m_mutex);
237 pthread_mutex_unlock(&m_mutex);
void unlock()
Unlock the I2C bus.
std::string m_strDevName
I2C device name.
std::string getDevName()
Get associated I2C device name.
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.
virtual int transfer(uint_t addr, const byte_t wbuf[], size_t wlen, byte_t rbuf[], size_t rlen)
Perform a write/read transfer to/from an I2C slave endpoint device.
i2c_t m_i2c
I2C bus instance.
pthread_mutex_t m_mutex
mutual exclusion
LaeI2C()
Default constructor.
virtual ~LaeI2C()
Destructor.
virtual int open(const std::string &strDevName)
Open I2C bus device.
virtual int read(uint_t addr, byte_t buf[], size_t len)
Read from a I2C slave endpoint device.
void lock()
Lock the I2C bus.
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.
bool isOpen()
Check if device is open.
virtual int close()
Close I2C bus device.
int i2cTryOpen(LaeI2C &i2cBus, uint_t addr)
Try to open a series of I2C devices to fine the required endpoint.
virtual bool check(uint_t addr)
Check if an I2C slave endpoint exists.
Top-level package include file.