int i2cdev_write(int fd, uint8_t *buf, size_t count, uint16_t addr) { return i2cdev_transfer(fd, buf, count, addr, 0); }
int i2ctool_get(FAR struct i2ctool_s *i2ctool, int fd, uint8_t regaddr, FAR uint16_t *result) { struct i2c_msg_s msg[2]; union { uint16_t data16; uint8_t data8; } u; int ret; /* Set up data structures */ msg[0].frequency = i2ctool->freq; msg[0].addr = i2ctool->addr; msg[0].flags = 0; msg[0].buffer = ®addr; msg[0].length = 1; msg[0].frequency = i2ctool->freq; msg[1].addr = i2ctool->addr; msg[1].flags = I2C_M_READ; if (i2ctool->width == 8) { msg[1].buffer = &u.data8; msg[1].length = 1; } else { msg[1].buffer = (uint8_t*)&u.data16; msg[1].length = 2; } if (i2ctool->start) { ret = i2cdev_transfer(fd, &msg[0], 1); if (ret== OK) { ret = i2cdev_transfer(fd, &msg[1], 1); } } else { ret = i2cdev_transfer(fd, msg, 2); } /* Return the result of the read operation */ if (ret == OK) { if (i2ctool->width == 8) { *result = (uint16_t)u.data8; } else { *result = u.data16; } } return ret; }
int i2cdev_read(int fd, uint8_t *buf, size_t count, uint16_t addr) { return i2cdev_transfer(fd, buf, count, addr, 1); }