From f641d0546d751548594e39de2a01af4b640a3566 Mon Sep 17 00:00:00 2001 From: Peter Bigot Date: Sun, 22 Dec 2019 09:01:54 -0600 Subject: [PATCH] drivers: sensor: mpu6050: convert to new GPIO API Use new configuration API, replace callback enable/disable with interrupt enable/disable, and set active level in devicetree source. Signed-off-by: Peter Bigot --- drivers/sensor/mpu6050/mpu6050_trigger.c | 19 ++++++++++++------- .../mpu6050/boards/nrf52_pca10040.overlay | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/sensor/mpu6050/mpu6050_trigger.c b/drivers/sensor/mpu6050/mpu6050_trigger.c index f2f6794daf93d..02fc5a5f8abb7 100644 --- a/drivers/sensor/mpu6050/mpu6050_trigger.c +++ b/drivers/sensor/mpu6050/mpu6050_trigger.c @@ -25,7 +25,8 @@ int mpu6050_trigger_set(struct device *dev, return -ENOTSUP; } - gpio_pin_disable_callback(drv_data->gpio, cfg->int_pin); + gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_pin, + GPIO_INT_DISABLE); drv_data->data_ready_handler = handler; if (handler == NULL) { @@ -34,7 +35,8 @@ int mpu6050_trigger_set(struct device *dev, drv_data->data_ready_trigger = *trig; - gpio_pin_enable_callback(drv_data->gpio, cfg->int_pin); + gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_pin, + GPIO_INT_EDGE_TO_ACTIVE); return 0; } @@ -48,7 +50,8 @@ static void mpu6050_gpio_callback(struct device *dev, ARG_UNUSED(pins); - gpio_pin_disable_callback(dev, cfg->int_pin); + gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_pin, + GPIO_INT_DISABLE); #if defined(CONFIG_MPU6050_TRIGGER_OWN_THREAD) k_sem_give(&drv_data->gpio_sem); @@ -68,7 +71,9 @@ static void mpu6050_thread_cb(void *arg) &drv_data->data_ready_trigger); } - gpio_pin_enable_callback(drv_data->gpio, cfg->int_pin); + gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_pin, + GPIO_INT_EDGE_TO_ACTIVE); + } #ifdef CONFIG_MPU6050_TRIGGER_OWN_THREAD @@ -112,8 +117,7 @@ int mpu6050_init_interrupt(struct device *dev) drv_data->dev = dev; gpio_pin_configure(drv_data->gpio, cfg->int_pin, - GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE | - GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE); + GPIO_INPUT | cfg->int_flags); gpio_init_callback(&drv_data->gpio_cb, mpu6050_gpio_callback, @@ -143,7 +147,8 @@ int mpu6050_init_interrupt(struct device *dev) drv_data->work.handler = mpu6050_work_cb; #endif - gpio_pin_enable_callback(drv_data->gpio, cfg->int_pin); + gpio_pin_interrupt_configure(drv_data->gpio, cfg->int_pin, + GPIO_INT_EDGE_TO_ACTIVE); return 0; } diff --git a/samples/sensor/mpu6050/boards/nrf52_pca10040.overlay b/samples/sensor/mpu6050/boards/nrf52_pca10040.overlay index 01d73c1079bde..88b0b25d344a4 100644 --- a/samples/sensor/mpu6050/boards/nrf52_pca10040.overlay +++ b/samples/sensor/mpu6050/boards/nrf52_pca10040.overlay @@ -10,6 +10,6 @@ reg = <0x68>; status = "okay"; label = "MPU6050"; - int-gpios = <&gpio0 11 0>; + int-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; }; };