diff --git a/boards/shields/x_nucleo_iks01a3/x_nucleo_iks01a3.overlay b/boards/shields/x_nucleo_iks01a3/x_nucleo_iks01a3.overlay index fdded5a9e96..a81db57aacc 100644 --- a/boards/shields/x_nucleo_iks01a3/x_nucleo_iks01a3.overlay +++ b/boards/shields/x_nucleo_iks01a3/x_nucleo_iks01a3.overlay @@ -22,7 +22,7 @@ stts751@4a { compatible = "st,stts751"; reg = <0x4a>; - drdy-gpios = <&arduino_header 4 0>; /* A4 */ + drdy-gpios = <&arduino_header 4 GPIO_ACTIVE_LOW>; /* A4 */ label = "STTS751"; }; diff --git a/drivers/sensor/stts751/stts751.c b/drivers/sensor/stts751/stts751.c index 4ddd756325b..837fbb8cf71 100644 --- a/drivers/sensor/stts751/stts751.c +++ b/drivers/sensor/stts751/stts751.c @@ -200,6 +200,7 @@ static const struct stts751_config stts751_config = { #ifdef CONFIG_STTS751_TRIGGER .event_port = DT_INST_0_ST_STTS751_DRDY_GPIOS_CONTROLLER, .event_pin = DT_INST_0_ST_STTS751_DRDY_GPIOS_PIN, + .int_flags = DT_INST_0_ST_STTS751_DRDY_GPIOS_FLAGS, #endif #if defined(DT_ST_STTS751_BUS_I2C) .bus_init = stts751_i2c_init, diff --git a/drivers/sensor/stts751/stts751.h b/drivers/sensor/stts751/stts751.h index b7cf68e8155..516d83c971a 100644 --- a/drivers/sensor/stts751/stts751.h +++ b/drivers/sensor/stts751/stts751.h @@ -30,6 +30,7 @@ struct stts751_config { #ifdef CONFIG_STTS751_TRIGGER const char *event_port; u8_t event_pin; + u8_t int_flags; #endif #ifdef DT_ST_STTS751_BUS_I2C u16_t i2c_slv_addr; diff --git a/drivers/sensor/stts751/stts751_trigger.c b/drivers/sensor/stts751/stts751_trigger.c index 8853ed7bde0..48e791f1352 100644 --- a/drivers/sensor/stts751/stts751_trigger.c +++ b/drivers/sensor/stts751/stts751_trigger.c @@ -70,7 +70,8 @@ static void stts751_handle_interrupt(void *arg) stts751->thsld_handler(dev, &thsld_trigger); } - gpio_pin_enable_callback(stts751->gpio, cfg->event_pin); + gpio_pin_interrupt_configure(stts751->gpio, cfg->event_pin, + GPIO_INT_EDGE_TO_ACTIVE); } static void stts751_gpio_callback(struct device *dev, @@ -82,7 +83,7 @@ static void stts751_gpio_callback(struct device *dev, ARG_UNUSED(pins); - gpio_pin_disable_callback(dev, cfg->event_pin); + gpio_pin_interrupt_configure(dev, cfg->event_pin, GPIO_INT_DISABLE); #if defined(CONFIG_STTS751_TRIGGER_OWN_THREAD) k_sem_give(&stts751->gpio_sem); @@ -143,8 +144,7 @@ int stts751_init_interrupt(struct device *dev) #endif /* CONFIG_STTS751_TRIGGER_OWN_THREAD */ ret = gpio_pin_configure(stts751->gpio, cfg->event_pin, - GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | - GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE); + GPIO_INPUT | cfg->int_flags); if (ret < 0) { LOG_DBG("Could not configure gpio"); return ret; @@ -168,5 +168,6 @@ int stts751_init_interrupt(struct device *dev) stts751_low_temperature_threshold_set(stts751->ctx, stts751_from_celsius_to_lsb(temp_lo)); - return gpio_pin_enable_callback(stts751->gpio, cfg->event_pin); + return gpio_pin_interrupt_configure(stts751->gpio, cfg->event_pin, + GPIO_INT_EDGE_TO_ACTIVE); } diff --git a/dts/bindings/sensor/st,stts751-i2c.yaml b/dts/bindings/sensor/st,stts751-i2c.yaml index 6d76b15930e..ba41e8125dd 100644 --- a/dts/bindings/sensor/st,stts751-i2c.yaml +++ b/dts/bindings/sensor/st,stts751-i2c.yaml @@ -13,3 +13,7 @@ properties: type: phandle-array required: false description: DRDY pin + + This pin defaults to active high when produced by the sensor. + The property value should ensure the flags properly describe + the signal that is presented to the driver. diff --git a/tests/drivers/build_all/sensors_stmemsc.conf b/tests/drivers/build_all/sensors_stmemsc.conf index b2f81d4405a..ad8294bd5e5 100644 --- a/tests/drivers/build_all/sensors_stmemsc.conf +++ b/tests/drivers/build_all/sensors_stmemsc.conf @@ -6,3 +6,4 @@ CONFIG_GPIO=y CONFIG_SPI=y CONFIG_SENSOR=y CONFIG_LIS2DW12=y +CONFIG_STTS751=y diff --git a/tests/drivers/build_all/sensors_stmemsc_trigger.conf b/tests/drivers/build_all/sensors_stmemsc_trigger.conf index 65cafc94f4a..677282358eb 100644 --- a/tests/drivers/build_all/sensors_stmemsc_trigger.conf +++ b/tests/drivers/build_all/sensors_stmemsc_trigger.conf @@ -7,3 +7,5 @@ CONFIG_SPI=y CONFIG_SENSOR=y CONFIG_LIS2DW12=y CONFIG_LIS2DW12_TRIGGER_OWN_THREAD=y +CONFIG_STTS751=y +CONFIG_STTS751_TRIGGER_OWN_THREAD=y