Skip to content

Commit e16b8ab

Browse files
committed
driver/sensor: lis2mdl: 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 e16b8ab

File tree

8 files changed

+21
-8
lines changed

8 files changed

+21
-8
lines changed

boards/arm/bbc_microbit/bbc_microbit.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
status = "disabled";
8282
reg = <0x1e>;
8383
label = "LSM303AGR-MAGN";
84-
irq-gpios = <&gpio0 27 0>; /* A3 */
84+
irq-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>; /* A3 */
8585
};
8686

8787
lsm303agr-accel@19 {

boards/shields/x_nucleo_iks01a2/x_nucleo_iks01a2.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
compatible = "st,lis2mdl","st,lsm303agr-magn";
3131
reg = <0x1e>;
3232
label = "LSM303AGR-MAGN";
33-
irq-gpios = <&arduino_header 3 0>; /* A3 */
33+
irq-gpios = <&arduino_header 3 GPIO_ACTIVE_HIGH>; /* A3 */
3434
};
3535

3636
lsm303agr-accel@19 {

boards/shields/x_nucleo_iks01a3/x_nucleo_iks01a3.overlay

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
lis2mdl@1e {
3030
compatible = "st,lis2mdl";
3131
reg = <0x1e>;
32-
irq-gpios = <&arduino_header 2 0>; /* A2 */
32+
irq-gpios = <&arduino_header 2 GPIO_ACTIVE_HIGH>; /* A2 */
3333
label = "LIS2MDL";
3434
};
3535

drivers/sensor/lis2mdl/lis2mdl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ static const struct lis2mdl_config lis2mdl_dev_config = {
259259
#ifdef CONFIG_LIS2MDL_TRIGGER
260260
.gpio_name = DT_INST_0_ST_LIS2MDL_IRQ_GPIOS_CONTROLLER,
261261
.gpio_pin = DT_INST_0_ST_LIS2MDL_IRQ_GPIOS_PIN,
262+
.gpio_flags = DT_INST_0_ST_LIS2MDL_IRQ_GPIOS_FLAGS,
262263
#endif /* CONFIG_LIS2MDL_TRIGGER */
263264
#if defined(DT_ST_LIS2MDL_BUS_SPI)
264265
.bus_init = lis2mdl_spi_init,

drivers/sensor/lis2mdl/lis2mdl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct lis2mdl_config {
3333
#ifdef CONFIG_LIS2MDL_TRIGGER
3434
char *gpio_name;
3535
u32_t gpio_pin;
36+
u8_t gpio_flags;
3637
#endif /* CONFIG_LIS2MDL_TRIGGER */
3738
#ifdef DT_ST_LIS2MDL_BUS_I2C
3839
u16_t i2c_slv_addr;

drivers/sensor/lis2mdl/lis2mdl_trigger.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ static void lis2mdl_handle_interrupt(void *arg)
6262
lis2mdl->handler_drdy(dev, &drdy_trigger);
6363
}
6464

65-
gpio_pin_enable_callback(lis2mdl->gpio, config->gpio_pin);
65+
gpio_pin_interrupt_configure(lis2mdl->gpio, config->gpio_pin,
66+
GPIO_INT_EDGE_TO_ACTIVE);
6667
}
6768

6869
static void lis2mdl_gpio_callback(struct device *dev,
@@ -74,7 +75,7 @@ static void lis2mdl_gpio_callback(struct device *dev,
7475

7576
ARG_UNUSED(pins);
7677

77-
gpio_pin_disable_callback(dev, config->gpio_pin);
78+
gpio_pin_interrupt_configure(dev, config->gpio_pin, GPIO_INT_DISABLE);
7879

7980
#if defined(CONFIG_LIS2MDL_TRIGGER_OWN_THREAD)
8081
k_sem_give(&lis2mdl->gpio_sem);
@@ -134,8 +135,7 @@ int lis2mdl_init_interrupt(struct device *dev)
134135
#endif
135136

136137
gpio_pin_configure(lis2mdl->gpio, config->gpio_pin,
137-
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
138-
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
138+
GPIO_INPUT | config->gpio_flags);
139139

140140
gpio_init_callback(&lis2mdl->gpio_cb,
141141
lis2mdl_gpio_callback,
@@ -146,5 +146,6 @@ int lis2mdl_init_interrupt(struct device *dev)
146146
return -EIO;
147147
}
148148

149-
return gpio_pin_enable_callback(lis2mdl->gpio, config->gpio_pin);
149+
return gpio_pin_interrupt_configure(lis2mdl->gpio, config->gpio_pin,
150+
GPIO_INT_EDGE_TO_ACTIVE);
150151
}

dts/bindings/sensor/st,lis2mdl-i2c.yaml

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

dts/bindings/sensor/st,lis2mdl-spi.yaml

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

0 commit comments

Comments
 (0)