Lines Matching +full:adxl362 +full:- +full:trigger
4 * SPDX-License-Identifier: Apache-2.0
15 #include "adxl362.h"
18 LOG_MODULE_DECLARE(ADXL362, CONFIG_SENSOR_LOG_LEVEL);
23 struct adxl362_data *drv_data = dev->data; in adxl362_thread_cb()
32 k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER); in adxl362_thread_cb()
33 if (drv_data->inact_handler != NULL) { in adxl362_thread_cb()
35 drv_data->inact_handler(dev, drv_data->inact_trigger); in adxl362_thread_cb()
39 if (drv_data->act_handler != NULL) { in adxl362_thread_cb()
41 drv_data->act_handler(dev, drv_data->act_trigger); in adxl362_thread_cb()
45 if (drv_data->drdy_handler != NULL && in adxl362_thread_cb()
47 drv_data->drdy_handler(dev, drv_data->drdy_trigger); in adxl362_thread_cb()
49 k_mutex_unlock(&drv_data->trigger_mutex); in adxl362_thread_cb()
60 adxl362_stream_irq_handler(drv_data->dev); in adxl362_gpio_callback()
64 k_sem_give(&drv_data->gpio_sem); in adxl362_gpio_callback()
66 k_work_submit(&drv_data->work); in adxl362_gpio_callback()
79 k_sem_take(&drv_data->gpio_sem, K_FOREVER); in adxl362_thread()
80 adxl362_thread_cb(drv_data->dev); in adxl362_thread()
89 adxl362_thread_cb(drv_data->dev); in adxl362_work_cb()
97 struct adxl362_data *drv_data = dev->data; in adxl362_trigger_set()
98 const struct adxl362_config *config = dev->config; in adxl362_trigger_set()
101 if (!config->interrupt.port) { in adxl362_trigger_set()
102 return -ENOTSUP; in adxl362_trigger_set()
105 switch (trig->type) { in adxl362_trigger_set()
107 k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER); in adxl362_trigger_set()
108 drv_data->act_handler = handler; in adxl362_trigger_set()
109 drv_data->act_trigger = trig; in adxl362_trigger_set()
110 k_mutex_unlock(&drv_data->trigger_mutex); in adxl362_trigger_set()
116 k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER); in adxl362_trigger_set()
117 drv_data->inact_handler = handler; in adxl362_trigger_set()
118 drv_data->inact_trigger = trig; in adxl362_trigger_set()
119 k_mutex_unlock(&drv_data->trigger_mutex); in adxl362_trigger_set()
125 k_mutex_lock(&drv_data->trigger_mutex, K_FOREVER); in adxl362_trigger_set()
126 drv_data->drdy_handler = handler; in adxl362_trigger_set()
127 drv_data->drdy_trigger = trig; in adxl362_trigger_set()
128 k_mutex_unlock(&drv_data->trigger_mutex); in adxl362_trigger_set()
133 LOG_ERR("Unsupported sensor trigger"); in adxl362_trigger_set()
134 return -ENOTSUP; in adxl362_trigger_set()
148 const struct adxl362_config *cfg = dev->config; in adxl362_init_interrupt()
149 struct adxl362_data *drv_data = dev->data; in adxl362_init_interrupt()
152 k_mutex_init(&drv_data->trigger_mutex); in adxl362_init_interrupt()
154 if (!gpio_is_ready_dt(&cfg->interrupt)) { in adxl362_init_interrupt()
155 LOG_ERR("GPIO port %s not ready", cfg->interrupt.port->name); in adxl362_init_interrupt()
156 return -ENODEV; in adxl362_init_interrupt()
164 ret = gpio_pin_configure_dt(&cfg->interrupt, GPIO_INPUT); in adxl362_init_interrupt()
169 gpio_init_callback(&drv_data->gpio_cb, in adxl362_init_interrupt()
171 BIT(cfg->interrupt.pin)); in adxl362_init_interrupt()
173 ret = gpio_add_callback(cfg->interrupt.port, &drv_data->gpio_cb); in adxl362_init_interrupt()
178 drv_data->dev = dev; in adxl362_init_interrupt()
181 k_sem_init(&drv_data->gpio_sem, 0, K_SEM_MAX_LIMIT); in adxl362_init_interrupt()
183 k_thread_create(&drv_data->thread, drv_data->thread_stack, in adxl362_init_interrupt()
189 k_thread_name_set(&drv_data->thread, dev->name); in adxl362_init_interrupt()
191 drv_data->work.handler = adxl362_work_cb; in adxl362_init_interrupt()
194 ret = gpio_pin_interrupt_configure_dt(&cfg->interrupt, in adxl362_init_interrupt()