diff --git a/boards/arm/hexiwear_k64/hexiwear_k64.dts b/boards/arm/hexiwear_k64/hexiwear_k64.dts index c052a2c03c8f7..eee7bb70c99e4 100644 --- a/boards/arm/hexiwear_k64/hexiwear_k64.dts +++ b/boards/arm/hexiwear_k64/hexiwear_k64.dts @@ -100,8 +100,8 @@ compatible = "nxp,fxas21002"; reg = <0x20>; label = "FXAS21002"; - int1-gpios = <&gpiod 1 0>; - int2-gpios = <&gpioc 18 0>; + int1-gpios = <&gpiod 1 GPIO_ACTIVE_LOW>; + int2-gpios = <&gpioc 18 GPIO_ACTIVE_LOW>; }; }; diff --git a/boards/arm/warp7_m4/warp7_m4.dts b/boards/arm/warp7_m4/warp7_m4.dts index 276c528cf740e..0245c21d4cd7e 100644 --- a/boards/arm/warp7_m4/warp7_m4.dts +++ b/boards/arm/warp7_m4/warp7_m4.dts @@ -62,7 +62,7 @@ compatible = "nxp,fxas21002"; reg = <0x20>; label = "FXAS21002"; - int1-gpios = <&gpio7 0 0>; + int1-gpios = <&gpio7 0 GPIO_ACTIVE_LOW>; }; }; diff --git a/drivers/sensor/fxas21002/fxas21002.c b/drivers/sensor/fxas21002/fxas21002.c index 3d877a48506e6..aa9d8058d94d3 100644 --- a/drivers/sensor/fxas21002/fxas21002.c +++ b/drivers/sensor/fxas21002/fxas21002.c @@ -293,9 +293,11 @@ static const struct fxas21002_config fxas21002_config = { #ifdef CONFIG_FXAS21002_DRDY_INT1 .gpio_name = DT_INST_0_NXP_FXAS21002_INT1_GPIOS_CONTROLLER, .gpio_pin = DT_INST_0_NXP_FXAS21002_INT1_GPIOS_PIN, + .gpio_flags = DT_INST_0_NXP_FXAS21002_INT1_GPIOS_FLAGS, #else .gpio_name = DT_INST_0_NXP_FXAS21002_INT2_GPIOS_CONTROLLER, .gpio_pin = DT_INST_0_NXP_FXAS21002_INT2_GPIOS_PIN, + .gpio_flags = DT_INST_0_NXP_FXAS21002_INT2_GPIOS_FLAGS, #endif #endif }; diff --git a/drivers/sensor/fxas21002/fxas21002.h b/drivers/sensor/fxas21002/fxas21002.h index 4f7803aa42095..261dc44bb090a 100644 --- a/drivers/sensor/fxas21002/fxas21002.h +++ b/drivers/sensor/fxas21002/fxas21002.h @@ -61,6 +61,7 @@ struct fxas21002_config { #ifdef CONFIG_FXAS21002_TRIGGER char *gpio_name; u8_t gpio_pin; + gpio_devicetree_flags_t gpio_flags; #endif u8_t i2c_address; u8_t whoami; diff --git a/drivers/sensor/fxas21002/fxas21002_trigger.c b/drivers/sensor/fxas21002/fxas21002_trigger.c index 672740b589130..f7cfefa9c390c 100644 --- a/drivers/sensor/fxas21002/fxas21002_trigger.c +++ b/drivers/sensor/fxas21002/fxas21002_trigger.c @@ -21,7 +21,8 @@ static void fxas21002_gpio_callback(struct device *dev, return; } - gpio_pin_disable_callback(dev, data->gpio_pin); + gpio_pin_interrupt_configure(data->gpio, data->gpio_pin, + GPIO_INT_DISABLE); #if defined(CONFIG_FXAS21002_TRIGGER_OWN_THREAD) k_sem_give(&data->trig_sem); @@ -68,7 +69,8 @@ static void fxas21002_handle_int(void *arg) fxas21002_handle_drdy_int(dev); } - gpio_pin_enable_callback(data->gpio, config->gpio_pin); + gpio_pin_interrupt_configure(data->gpio, config->gpio_pin, + GPIO_INT_EDGE_TO_ACTIVE); } #ifdef CONFIG_FXAS21002_TRIGGER_OWN_THREAD @@ -206,15 +208,15 @@ int fxas21002_trigger_init(struct device *dev) data->gpio_pin = config->gpio_pin; gpio_pin_configure(data->gpio, config->gpio_pin, - GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | - GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE); + GPIO_INPUT | config->gpio_flags); gpio_init_callback(&data->gpio_cb, fxas21002_gpio_callback, BIT(config->gpio_pin)); gpio_add_callback(data->gpio, &data->gpio_cb); - gpio_pin_enable_callback(data->gpio, config->gpio_pin); + gpio_pin_interrupt_configure(data->gpio, config->gpio_pin, + GPIO_INT_EDGE_TO_ACTIVE); return 0; } diff --git a/dts/bindings/sensor/nxp,fxas21002.yaml b/dts/bindings/sensor/nxp,fxas21002.yaml index d6ccfff035438..cd523b48ed788 100644 --- a/dts/bindings/sensor/nxp,fxas21002.yaml +++ b/dts/bindings/sensor/nxp,fxas21002.yaml @@ -11,7 +11,15 @@ properties: int1-gpios: type: phandle-array required: false + description: INT1 pin + This pin defaults to active low when produced by the sensor. + The property value should ensure the flags properly describe + the signal that is presented to the driver. int2-gpios: type: phandle-array required: false + description: INT2 pin + This pin defaults to active low when produced by the sensor. + The property value should ensure the flags properly describe + the signal that is presented to the driver.