drivers/ina220: adapt to new I2C api
This commit is contained in:
parent
6016266c77
commit
34bddca083
@ -39,10 +39,10 @@ static int ina220_read_reg(const ina220_t *dev, uint8_t reg, uint16_t *out)
|
|||||||
} tmp = { .u16 = 0 };
|
} tmp = { .u16 = 0 };
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
status = i2c_read_regs(dev->i2c, dev->addr, reg, &tmp.c[0], 2);
|
status = i2c_read_regs(dev->i2c, dev->addr, reg, &tmp.c[0], 2, 0);
|
||||||
|
|
||||||
if (status != 2) {
|
if (status < 0) {
|
||||||
return -1;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
*out = ntohs(tmp.u16);
|
*out = ntohs(tmp.u16);
|
||||||
@ -60,10 +60,10 @@ static int ina220_write_reg(const ina220_t *dev, uint8_t reg, uint16_t in)
|
|||||||
|
|
||||||
tmp.u16 = htons(in);
|
tmp.u16 = htons(in);
|
||||||
|
|
||||||
status = i2c_write_regs(dev->i2c, dev->addr, reg, &tmp.c[0], 2);
|
status = i2c_write_regs(dev->i2c, dev->addr, reg, &tmp.c[0], 2, 0);
|
||||||
|
|
||||||
if (status != 2) {
|
if (status < 0) {
|
||||||
return -1;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -48,10 +48,6 @@ int main(void)
|
|||||||
int16_t val;
|
int16_t val;
|
||||||
|
|
||||||
puts("INA220 sensor driver test application\n");
|
puts("INA220 sensor driver test application\n");
|
||||||
printf("Initializing I2C_%i... ", TEST_INA220_I2C);
|
|
||||||
if (i2c_init_master(TEST_INA220_I2C, I2C_SPEED_FAST) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Initializing INA220 sensor at I2C_%i, address 0x%02x... ",
|
printf("Initializing INA220 sensor at I2C_%i, address 0x%02x... ",
|
||||||
TEST_INA220_I2C, TEST_INA220_ADDR);
|
TEST_INA220_I2C, TEST_INA220_ADDR);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user