20 #include <sys/ioctl.h>
21 #include <linux/i2c.h>
22 #include <linux/i2c-dev.h>
35 const char *
const compName
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];
180 rdwr_msgs[0].addr =
static_cast<U16
>(addr);
181 rdwr_msgs[0].flags = 0;
182 rdwr_msgs[0].len =
static_cast<U16
>(writeBuffer.
getSize());
183 rdwr_msgs[0].buf = writeBuffer.
getData();
186 rdwr_msgs[1].addr =
static_cast<U16
>(addr);
187 rdwr_msgs[1].flags = I2C_M_RD;
188 rdwr_msgs[1].len =
static_cast<U16
>(readBuffer.
getSize());
189 rdwr_msgs[1].buf = readBuffer.
getData();
191 struct i2c_rdwr_ioctl_data rdwr_data;
192 rdwr_data.msgs = rdwr_msgs;
208 for (U32
byte = 0;
byte < writeBuffer.
getSize();
byte++) {
214 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.
LinuxI2cDriver(const char *const compName)
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.