Skip to content

Commit 45c31f6

Browse files
microbuildergalak
authored andcommitted
drivers: hmc5883l: update to new GPIO API
This commit updates the HMC5883L driver to use the new GPIO API. Also add a note explicitly describing the active state of the DRDY pin in the binding file. Tested on frdm_k64f. Signed-off-by: Kevin Townsend <[email protected]>
1 parent 52d6df9 commit 45c31f6

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

drivers/sensor/hmc5883l/hmc5883l_trigger.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ int hmc5883l_trigger_set(struct device *dev,
2323

2424
__ASSERT_NO_MSG(trig->type == SENSOR_TRIG_DATA_READY);
2525

26-
gpio_pin_disable_callback(drv_data->gpio,
27-
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN);
26+
gpio_pin_interrupt_configure(drv_data->gpio,
27+
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN,
28+
GPIO_INT_DISABLE);
2829

2930
drv_data->data_ready_handler = handler;
3031
if (handler == NULL) {
@@ -33,8 +34,9 @@ int hmc5883l_trigger_set(struct device *dev,
3334

3435
drv_data->data_ready_trigger = *trig;
3536

36-
gpio_pin_enable_callback(drv_data->gpio,
37-
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN);
37+
gpio_pin_interrupt_configure(drv_data->gpio,
38+
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN,
39+
GPIO_INT_EDGE_TO_ACTIVE);
3840

3941
return 0;
4042
}
@@ -47,8 +49,9 @@ static void hmc5883l_gpio_callback(struct device *dev,
4749

4850
ARG_UNUSED(pins);
4951

50-
gpio_pin_disable_callback(dev,
51-
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN);
52+
gpio_pin_interrupt_configure(dev,
53+
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN,
54+
GPIO_INT_DISABLE);
5255

5356
#if defined(CONFIG_HMC5883L_TRIGGER_OWN_THREAD)
5457
k_sem_give(&drv_data->gpio_sem);
@@ -67,8 +70,9 @@ static void hmc5883l_thread_cb(void *arg)
6770
&drv_data->data_ready_trigger);
6871
}
6972

70-
gpio_pin_enable_callback(drv_data->gpio,
71-
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN);
73+
gpio_pin_interrupt_configure(drv_data->gpio,
74+
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN,
75+
GPIO_INT_EDGE_TO_ACTIVE);
7276
}
7377

7478
#ifdef CONFIG_HMC5883L_TRIGGER_OWN_THREAD
@@ -111,8 +115,8 @@ int hmc5883l_init_interrupt(struct device *dev)
111115

112116
gpio_pin_configure(drv_data->gpio,
113117
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN,
114-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
115-
GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE);
118+
GPIO_INPUT |
119+
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_FLAGS);
116120

117121
gpio_init_callback(&drv_data->gpio_cb,
118122
hmc5883l_gpio_callback,
@@ -136,8 +140,9 @@ int hmc5883l_init_interrupt(struct device *dev)
136140
drv_data->dev = dev;
137141
#endif
138142

139-
gpio_pin_enable_callback(drv_data->gpio,
140-
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN);
143+
gpio_pin_interrupt_configure(drv_data->gpio,
144+
DT_INST_0_HONEYWELL_HMC5883L_INT_GPIOS_PIN,
145+
GPIO_INT_EDGE_TO_ACTIVE);
141146

142147
return 0;
143148
}

dts/bindings/sensor/honeywell,hmc5883l.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ properties:
1111
int-gpios:
1212
type: phandle-array
1313
required: false
14+
description: DRDY pin
15+
16+
This pin is active low, with an internal pullup in the sensor.
17+
The property value should ensure the flags properly describe
18+
the signal that is presented to the driver.

samples/sensor/hmc5883l/boards/frdm_k64f.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
hmc5883l@1e {
99
compatible = "honeywell,hmc5883l";
1010
reg = <0x1E>;
11-
int-gpios = <&gpioc 12 0>;
11+
int-gpios = <&gpioc 12 GPIO_ACTIVE_LOW>;
1212
label = "HMC5883L";
1313
};
1414
};

0 commit comments

Comments
 (0)