diff --git a/sensor_ti_hdc1000.c b/sensor_ti_hdc1000.c index f629cba..3c696e3 100644 --- a/sensor_ti_hdc1000.c +++ b/sensor_ti_hdc1000.c @@ -15,7 +15,11 @@ static struct hdc1000_device *hdc1000_dev; static rt_err_t _hdc1000_init(struct rt_sensor_intf *intf) { +#if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0)) + rt_uint8_t i2c_addr = (rt_uint32_t)(intf->arg) & 0xff; +#else rt_uint8_t i2c_addr = (rt_uint32_t)(intf->user_data) & 0xff; +#endif hdc1000_dev = hdc1000_init(intf->dev_name, i2c_addr); diff --git a/sensor_ti_hdc1000.h b/sensor_ti_hdc1000.h index 30ee029..62f328d 100644 --- a/sensor_ti_hdc1000.h +++ b/sensor_ti_hdc1000.h @@ -2,7 +2,13 @@ #ifndef SENSOR_TI_HDC1000_H__ #define SENSOR_TI_HDC1000_H__ +#include +#if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0)) +#include "drivers/sensor.h" +#else #include "sensor.h" +#endif + #include "hdc1000_reg.h" #define HDC1000_SLAVE_ADDR_DEFAULT ( HDC1000_DEVICE_IIC_BUS_ADDRESS ) diff --git a/sensor_ti_hdc1000_example.c b/sensor_ti_hdc1000_example.c index 567381c..ebec664 100644 --- a/sensor_ti_hdc1000_example.c +++ b/sensor_ti_hdc1000_example.c @@ -10,7 +10,11 @@ int rt_hw_hdc1000_port(void) struct rt_sensor_config cfg; rt_int8_t result; cfg.intf.dev_name = "i2c1"; +#if defined(RTTHREAD_VERSION) && (RTTHREAD_VERSION >= RT_VERSION_CHECK(5, 0, 0)) + cfg.intf.arg = (void *)HDC1000_SLAVE_ADDR_DEFAULT; +#else cfg.intf.user_data = (void *)HDC1000_SLAVE_ADDR_DEFAULT; +#endif cfg.irq_pin.pin = RT_PIN_NONE; result = rt_hw_hdc1000_init("hdc1000", &cfg);