20 #include <sys/ioctl.h> 21 #include <linux/i2c.h> 22 #include <linux/i2c-dev.h> 34 const char *
const compName
44 if (-1 != this->m_fd) {
51 this->m_fd =
::open(device, O_RDWR);
52 return (-1 != this->m_fd);
70 if (-1 == this->m_fd) {
75 int stat = ioctl(this->m_fd, I2C_SLAVE, addr);
82 stat =
static_cast<int>(write(this->m_fd, serBuffer.
getData(), serBuffer.
getSize()));
97 if (-1 == this->m_fd) {
102 int stat = ioctl(this->m_fd, I2C_SLAVE, addr);
109 stat =
static_cast<int>(read(this->m_fd, serBuffer.
getData(), serBuffer.
getSize()));
125 if (-1 == this->m_fd) {
134 struct i2c_msg rdwr_msgs[2];
137 rdwr_msgs[0].addr =
static_cast<U16
>(addr);
138 rdwr_msgs[0].flags = 0;
139 rdwr_msgs[0].len =
static_cast<U16
>(writeBuffer.
getSize());
140 rdwr_msgs[0].buf = writeBuffer.
getData();
143 rdwr_msgs[1].addr =
static_cast<U16
>(addr);
144 rdwr_msgs[1].flags = I2C_M_RD;
145 rdwr_msgs[1].len =
static_cast<U16
>(readBuffer.
getSize());
146 rdwr_msgs[1].buf = readBuffer.
getData();
148 struct i2c_rdwr_ioctl_data rdwr_data;
149 rdwr_data.msgs = rdwr_msgs;
bool open(const char *device)
PlatformIntType NATIVE_INT_TYPE
LinuxI2cDriver(const char *const compName)
C++-compatible configuration header for fprime configuration.
Auto-generated base for LinuxI2cDriver component.
Other errors that don't fit.
I2C driver failed to open device.