19 #include <linux/i2c-dev.h> 20 #include <linux/i2c.h> 21 #include <sys/ioctl.h> 34 if (-1 != this->m_fd) {
41 this->m_fd =
::open(device, O_RDWR);
42 return (-1 != this->m_fd);
53 if (-1 == this->m_fd) {
58 int stat = ioctl(this->m_fd, I2C_SLAVE, addr);
66 ssize_t status_write = write(this->m_fd, serBuffer.
getData(),
static_cast<size_t>(serBuffer.
getSize()));
67 if (status_write == -1) {
75 if (-1 == this->m_fd) {
80 int stat = ioctl(this->m_fd, I2C_SLAVE, addr);
88 ssize_t status_read = read(this->m_fd, serBuffer.
getData(),
static_cast<size_t>(serBuffer.
getSize()));
89 if (status_read == -1) {
100 if (-1 == this->m_fd) {
113 struct i2c_msg rdwr_msgs[2];
116 rdwr_msgs[0].addr =
static_cast<U16
>(addr);
117 rdwr_msgs[0].flags = 0;
118 rdwr_msgs[0].len =
static_cast<U16
>(writeBuffer.
getSize());
119 rdwr_msgs[0].buf = writeBuffer.
getData();
122 rdwr_msgs[1].addr =
static_cast<U16
>(addr);
123 rdwr_msgs[1].flags = I2C_M_RD;
124 rdwr_msgs[1].len =
static_cast<U16
>(readBuffer.
getSize());
125 rdwr_msgs[1].buf = readBuffer.
getData();
127 struct i2c_rdwr_ioctl_data rdwr_data;
128 rdwr_data.msgs = rdwr_msgs;
132 int stat = ioctl(this->m_fd, I2C_RDWR, &rdwr_data);
bool open(const char *device)
LinuxI2cDriver(const char *const compName)
Auto-generated base for LinuxI2cDriver component.
FwSizeType getSize() const
PlatformIndexType FwIndexType
Other errors that don't fit.
#define FW_ASSERT_NO_OVERFLOW(value, T)
I2C driver failed to open device.