Skip to content

Commit df1dc58

Browse files
jfischer-nogalak
authored andcommitted
drivers: ti_hdc: convert to new GPIO API
Convert TI HDC sensor driver to new GPIO API. Signed-off-by: Johann Fischer <[email protected]>
1 parent e04968a commit df1dc58

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

boards/arm/reel_board/dts/reel_board.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ arduino_i2c: &i2c0 {
132132
compatible = "ti,hdc","ti,hdc1010";
133133
reg = <0x43>;
134134
label = "HDC1010";
135-
drdy-gpios = <&gpio0 22 GPIO_PUD_PULL_UP>;
135+
drdy-gpios = <&gpio0 22 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
136136
};
137137

138138
apds9960@39 {

drivers/sensor/ti_hdc/ti_hdc.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ static void ti_hdc_gpio_callback(struct device *dev,
2626

2727
ARG_UNUSED(pins);
2828

29-
gpio_pin_disable_callback(dev, DT_INST_0_TI_HDC_DRDY_GPIOS_PIN);
29+
gpio_pin_interrupt_configure(drv_data->gpio,
30+
DT_INST_0_TI_HDC_DRDY_GPIOS_PIN,
31+
GPIO_INT_DISABLE);
3032
k_sem_give(&drv_data->data_sem);
3133
}
3234
#endif
@@ -39,7 +41,9 @@ static int ti_hdc_sample_fetch(struct device *dev, enum sensor_channel chan)
3941
__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL);
4042

4143
#if defined(DT_INST_0_TI_HDC_DRDY_GPIOS_CONTROLLER)
42-
gpio_pin_enable_callback(drv_data->gpio, DT_INST_0_TI_HDC_DRDY_GPIOS_PIN);
44+
gpio_pin_interrupt_configure(drv_data->gpio,
45+
DT_INST_0_TI_HDC_DRDY_GPIOS_PIN,
46+
GPIO_INT_EDGE_TO_ACTIVE);
4347
#endif
4448

4549
buf[0] = TI_HDC_REG_TEMP;
@@ -150,11 +154,7 @@ static int ti_hdc_init(struct device *dev)
150154
}
151155

152156
gpio_pin_configure(drv_data->gpio, DT_INST_0_TI_HDC_DRDY_GPIOS_PIN,
153-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
154-
#if defined(DT_INST_0_TI_HDC_DRDY_GPIOS_FLAGS)
155-
DT_INST_0_TI_HDC_DRDY_GPIOS_FLAGS |
156-
#endif
157-
GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE);
157+
GPIO_INPUT | DT_INST_0_TI_HDC_DRDY_GPIOS_FLAGS);
158158

159159
gpio_init_callback(&drv_data->gpio_cb,
160160
ti_hdc_gpio_callback,
@@ -164,6 +164,10 @@ static int ti_hdc_init(struct device *dev)
164164
LOG_DBG("Failed to set GPIO callback");
165165
return -EIO;
166166
}
167+
168+
gpio_pin_interrupt_configure(drv_data->gpio,
169+
DT_INST_0_TI_HDC_DRDY_GPIOS_PIN,
170+
GPIO_INT_EDGE_TO_ACTIVE);
167171
#endif
168172

169173
LOG_INF("Initialized device successfully");

dts/bindings/sensor/ti,hdc.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ properties:
1111
drdy-gpios:
1212
type: phandle-array
1313
required: false
14+
description: Data ready pin.
15+
16+
The DRDYn pin of HDC sensor is open-drain, active low.
17+
If connected directly the MCU pin should be configured
18+
as pull-up, active low.

0 commit comments

Comments
 (0)