22#include <linux/i2c-dev.h>
35 const char *
const compName
42 void LinuxI2cDriver ::
42 void LinuxI2cDriver :: {
…}
53 if (-1 != this->m_fd) {
60 this->m_fd =
::open(device, O_RDWR);
61 return (-1 != this->m_fd);
79 if (-1 == this->m_fd) {
85 for (U32
byte = 0;
byte < serBuffer.
getSize();
byte++) {
92 int stat = ioctl(this->m_fd, I2C_SLAVE, addr);
102 stat = write(this->m_fd, serBuffer.
getData(), serBuffer.
getSize());
120 if (-1 == this->m_fd) {
128 int stat = ioctl(this->m_fd, I2C_SLAVE, addr);
138 stat = read(this->m_fd, serBuffer.
getData(), serBuffer.
getSize());
146 for (U32
byte = 0;
byte < serBuffer.
getSize();
byte++) {
164 if (-1 == this->m_fd) {
177 struct i2c_msg rdwr_msgs[2] = {
179 .addr =
static_cast<U16
>(addr),
181 .len =
static_cast<U16
>(writeBuffer.
getSize()),
185 .addr =
static_cast<U16
>(addr),
187 .len =
static_cast<U16
>(readBuffer.
getSize()),
192 struct i2c_rdwr_ioctl_data rdwr_data = {
210 for (U32
byte = 0;
byte < writeBuffer.
getSize();
byte++) {
216 for (U32
byte = 0;
byte < readBuffer.
getSize();
byte++) {
PlatformIntType NATIVE_INT_TYPE
C++-compatible configuration header for fprime configuration.
@ I2C_OPEN_ERR
I2C driver failed to open device.
@ I2C_OTHER_ERR
Other errors that don't fit.
@ I2C_WRITE_ERR
I2C write failed.
@ I2C_OK
Transaction okay.
@ I2C_ADDRESS_ERR
I2C address invalid.
@ I2C_READ_ERR
I2C read failed.
Auto-generated base for LinuxI2cDriver component.
bool open(const char *device)
static void logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
void init()
Object initializer.