Skip to content

Commit 0b0074f

Browse files
committed
driver/sensor: lis3mdl: update to use new GPIO API
Get rid of all the deprecated functions and definitions replacing them with the new ones. Signed-off-by: Armando Visconti <[email protected]>
1 parent 31cd5ac commit 0b0074f

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

boards/shields/x_nucleo_iks01a1/x_nucleo_iks01a1.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
lis3mdl-magn@1e {
2323
compatible = "st,lis3mdl-magn";
2424
reg = <0x1e>;
25-
irq-gpios = <&arduino_header 4 0>; /* A4 */
25+
irq-gpios = <&arduino_header 4 GPIO_ACTIVE_HIGH>; /* A4 */
2626
label = "LIS3MDL";
2727
};
2828

drivers/sensor/lis3mdl/lis3mdl_trigger.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ int lis3mdl_trigger_set(struct device *dev,
3333

3434
drv_data->data_ready_trigger = *trig;
3535

36-
gpio_pin_enable_callback(drv_data->gpio,
37-
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
36+
gpio_pin_interrupt_configure(drv_data->gpio,
37+
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
38+
GPIO_INT_EDGE_TO_ACTIVE);
3839

3940
return 0;
4041
}
@@ -47,7 +48,9 @@ static void lis3mdl_gpio_callback(struct device *dev,
4748

4849
ARG_UNUSED(pins);
4950

50-
gpio_pin_disable_callback(dev, DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
51+
gpio_pin_interrupt_configure(dev,
52+
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
53+
GPIO_INT_DISABLE);
5154

5255
#if defined(CONFIG_LIS3MDL_TRIGGER_OWN_THREAD)
5356
k_sem_give(&drv_data->gpio_sem);
@@ -66,8 +69,9 @@ static void lis3mdl_thread_cb(void *arg)
6669
&drv_data->data_ready_trigger);
6770
}
6871

69-
gpio_pin_enable_callback(drv_data->gpio,
70-
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
72+
gpio_pin_interrupt_configure(drv_data->gpio,
73+
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
74+
GPIO_INT_EDGE_TO_ACTIVE);
7175
}
7276

7377
#ifdef CONFIG_LIS3MDL_TRIGGER_OWN_THREAD
@@ -110,8 +114,8 @@ int lis3mdl_init_interrupt(struct device *dev)
110114

111115
gpio_pin_configure(drv_data->gpio,
112116
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
113-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
114-
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
117+
GPIO_INPUT |
118+
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_FLAGS);
115119

116120
gpio_init_callback(&drv_data->gpio_cb,
117121
lis3mdl_gpio_callback,
@@ -148,8 +152,9 @@ int lis3mdl_init_interrupt(struct device *dev)
148152
drv_data->dev = dev;
149153
#endif
150154

151-
gpio_pin_enable_callback(drv_data->gpio,
152-
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN);
155+
gpio_pin_interrupt_configure(drv_data->gpio,
156+
DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN,
157+
GPIO_INT_EDGE_TO_ACTIVE);
153158

154159
return 0;
155160
}

dts/bindings/sensor/st,lis3mdl-magn.yaml

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

tests/drivers/build_all/dts_fixup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
#define DT_INST_0_ST_LIS3MDL_MAGN_BASE_ADDRESS 0x19
115115
#define DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_PIN 0
116116
#define DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_CONTROLLER ""
117+
#define DT_INST_0_ST_LIS3MDL_MAGN_IRQ_GPIOS_FLAGS 0
117118
#endif
118119

119120
#ifndef DT_INST_0_ST_LPS25HB_PRESS_LABEL

0 commit comments

Comments
 (0)