drivers/sensor: lis2dw12: fix for wrong gpio_callback handling
It seems that gpio_pin_disable_callback() has never been working for that sensor as it was expected. We used there argument 'dev' as its own (lis2dw12) device pointer. While this argument is a gpio_port device pointer not lis2dw12 sensor device pointer. So cfg->int_gpio_pin always tries to disable callback for some random pin read from accidental data sector. Signed-off-by: Michał Oleszczyk <oleszczyk.m@gmail.com>
This commit is contained in:
parent
2dfbf21410
commit
2663f71c6a
2 changed files with 7 additions and 3 deletions
|
@ -112,6 +112,7 @@ struct lis2dw12_data {
|
|||
lis2dw12_ctx_t *ctx;
|
||||
#ifdef CONFIG_LIS2DW12_TRIGGER
|
||||
struct device *gpio;
|
||||
u8_t gpio_pin;
|
||||
struct gpio_callback gpio_cb;
|
||||
sensor_trigger_handler_t drdy_handler;
|
||||
#ifdef CONFIG_LIS2DW12_PULSE
|
||||
|
|
|
@ -192,11 +192,12 @@ static void lis2dw12_gpio_callback(struct device *dev,
|
|||
{
|
||||
struct lis2dw12_data *lis2dw12 =
|
||||
CONTAINER_OF(cb, struct lis2dw12_data, gpio_cb);
|
||||
const struct lis2dw12_device_config *cfg = dev->config->config_info;
|
||||
|
||||
ARG_UNUSED(pins);
|
||||
if ((pins & BIT(lis2dw12->gpio_pin)) == 0U) {
|
||||
return;
|
||||
}
|
||||
|
||||
gpio_pin_disable_callback(dev, cfg->int_gpio_pin);
|
||||
gpio_pin_disable_callback(dev, lis2dw12->gpio_pin);
|
||||
|
||||
#if defined(CONFIG_LIS2DW12_TRIGGER_OWN_THREAD)
|
||||
k_sem_give(&lis2dw12->gpio_sem);
|
||||
|
@ -257,6 +258,8 @@ int lis2dw12_init_interrupt(struct device *dev)
|
|||
lis2dw12->dev = dev;
|
||||
#endif /* CONFIG_LIS2DW12_TRIGGER_OWN_THREAD */
|
||||
|
||||
lis2dw12->gpio_pin = cfg->int_gpio_pin;
|
||||
|
||||
ret = gpio_pin_configure(lis2dw12->gpio, cfg->int_gpio_pin,
|
||||
GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
|
||||
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue