1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:32:45 +01:00

drivers/hdc1000: adapt to new i2c API

This commit is contained in:
Hyungsin 2018-06-28 12:24:49 -07:00 committed by dylad
parent 34bddca083
commit 79430a208a

View File

@ -31,8 +31,6 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#define I2C_SPEED I2C_SPEED_FAST
#ifndef HDC1000_RENEW_INTERVAL
#define HDC1000_RENEW_INTERVAL (1000000ul)
#endif
@ -48,16 +46,10 @@ int hdc1000_init(hdc1000_t *dev, const hdc1000_params_t *params)
/* write device descriptor */
memcpy(&dev->p, params, sizeof(hdc1000_params_t));
/* initialize the I2C bus */
i2c_acquire(dev->p.i2c);
if (i2c_init_master(dev->p.i2c, I2C_SPEED) < 0) {
i2c_release(dev->p.i2c);
return HDC1000_NOBUS;
}
/* try if we can interact with the device by reading its manufacturer ID */
i2c_acquire(dev->p.i2c);
if (i2c_read_regs(dev->p.i2c, dev->p.addr,
HDC1000_MANUFACTURER_ID, reg, 2) != 2) {
HDC1000_MANUFACTURER_ID, reg, 2, 0) < 0) {
i2c_release(dev->p.i2c);
return HDC1000_NOBUS;
}
@ -73,7 +65,7 @@ int hdc1000_init(hdc1000_t *dev, const hdc1000_params_t *params)
reg[0] = (tmp >> 8);
reg[1] = tmp;
if (i2c_write_regs(dev->p.i2c, dev->p.addr, HDC1000_CONFIG, reg, 2) != 2) {
if (i2c_write_regs(dev->p.i2c, dev->p.addr, HDC1000_CONFIG, reg, 2, 0) < 0) {
i2c_release(dev->p.i2c);
return HDC1000_NOBUS;
}
@ -100,7 +92,7 @@ int hdc1000_trigger_conversion(const hdc1000_t *dev)
* to the address 0x00 (HDC1000_TEMPERATURE).
* Conversion Time is 6.50ms for each value for 14 bit resolution.
*/
if (i2c_write_byte(dev->p.i2c, dev->p.addr, HDC1000_TEMPERATURE) != 1) {
if (i2c_write_byte(dev->p.i2c, dev->p.addr, HDC1000_TEMPERATURE, 0) < 0) {
status = HDC1000_BUSERR;
}
@ -117,7 +109,7 @@ int hdc1000_get_results(const hdc1000_t *dev, int16_t *temp, int16_t *hum)
/* first we read the RAW results from the device */
i2c_acquire(dev->p.i2c);
if (i2c_read_bytes(dev->p.i2c, dev->p.addr, buf, 4) != 4) {
if (i2c_read_bytes(dev->p.i2c, dev->p.addr, buf, 4, 0) < 0) {
status = HDC1000_BUSERR;
}
i2c_release(dev->p.i2c);