Lines Matching +full:data +full:- +full:ready

4  * SPDX-License-Identifier: Apache-2.0
19 struct fxas21002_data *data = in fxas21002_gpio_callback() local
21 const struct fxas21002_config *config = data->dev->config; in fxas21002_gpio_callback()
23 if ((pin_mask & BIT(config->int_gpio.pin)) == 0U) { in fxas21002_gpio_callback()
27 gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_DISABLE); in fxas21002_gpio_callback()
30 k_sem_give(&data->trig_sem); in fxas21002_gpio_callback()
32 k_work_submit(&data->work); in fxas21002_gpio_callback()
38 struct fxas21002_data *data = dev->data; in fxas21002_handle_drdy_int() local
40 if (data->drdy_handler) { in fxas21002_handle_drdy_int()
41 data->drdy_handler(dev, data->drdy_trig); in fxas21002_handle_drdy_int()
49 const struct fxas21002_config *config = dev->config; in fxas21002_handle_int()
50 struct fxas21002_data *data = dev->data; in fxas21002_handle_int() local
53 k_sem_take(&data->sem, K_FOREVER); in fxas21002_handle_int()
55 if (config->ops->byte_read(dev, FXAS21002_REG_INT_SOURCE, in fxas21002_handle_int()
61 k_sem_give(&data->sem); in fxas21002_handle_int()
67 gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in fxas21002_handle_int()
76 struct fxas21002_data *data = p1; in fxas21002_thread_main() local
79 k_sem_take(&data->trig_sem, K_FOREVER); in fxas21002_thread_main()
80 fxas21002_handle_int(data->dev); in fxas21002_thread_main()
88 struct fxas21002_data *data = in fxas21002_work_handler() local
91 fxas21002_handle_int(data->dev); in fxas21002_work_handler()
99 const struct fxas21002_config *config = dev->config; in fxas21002_trigger_set()
100 struct fxas21002_data *data = dev->data; in fxas21002_trigger_set() local
106 if (!config->int_gpio.port) { in fxas21002_trigger_set()
107 return -ENOTSUP; in fxas21002_trigger_set()
110 k_sem_take(&data->sem, K_FOREVER); in fxas21002_trigger_set()
112 switch (trig->type) { in fxas21002_trigger_set()
115 data->drdy_handler = handler; in fxas21002_trigger_set()
116 data->drdy_trig = trig; in fxas21002_trigger_set()
120 ret = -ENOTSUP; in fxas21002_trigger_set()
124 /* The sensor must be in standby or ready mode when writing the in fxas21002_trigger_set()
130 ret = -EIO; in fxas21002_trigger_set()
134 /* Put the sensor in ready mode */ in fxas21002_trigger_set()
136 LOG_ERR("Could not set ready mode"); in fxas21002_trigger_set()
137 ret = -EIO; in fxas21002_trigger_set()
142 if (config->ops->reg_field_update(dev, FXAS21002_REG_CTRLREG2, mask, in fxas21002_trigger_set()
145 ret = -EIO; in fxas21002_trigger_set()
152 ret = -EIO; in fxas21002_trigger_set()
156 /* Wait the transition time from ready mode */ in fxas21002_trigger_set()
159 config->dr); in fxas21002_trigger_set()
163 k_sem_give(&data->sem); in fxas21002_trigger_set()
170 const struct fxas21002_config *config = dev->config; in fxas21002_trigger_init()
171 struct fxas21002_data *data = dev->data; in fxas21002_trigger_init() local
175 data->dev = dev; in fxas21002_trigger_init()
178 k_sem_init(&data->trig_sem, 0, K_SEM_MAX_LIMIT); in fxas21002_trigger_init()
179 k_thread_create(&data->thread, data->thread_stack, in fxas21002_trigger_init()
181 fxas21002_thread_main, data, 0, NULL, in fxas21002_trigger_init()
185 data->work.handler = fxas21002_work_handler; in fxas21002_trigger_init()
194 if (config->ops->byte_write(dev, FXAS21002_REG_CTRLREG2, in fxas21002_trigger_init()
197 return -EIO; in fxas21002_trigger_init()
200 if (!gpio_is_ready_dt(&config->int_gpio)) { in fxas21002_trigger_init()
201 LOG_ERR("GPIO device not ready"); in fxas21002_trigger_init()
202 return -ENODEV; in fxas21002_trigger_init()
205 ret = gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT); in fxas21002_trigger_init()
210 gpio_init_callback(&data->gpio_cb, fxas21002_gpio_callback, in fxas21002_trigger_init()
211 BIT(config->int_gpio.pin)); in fxas21002_trigger_init()
213 ret = gpio_add_callback(config->int_gpio.port, &data->gpio_cb); in fxas21002_trigger_init()
218 ret = gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in fxas21002_trigger_init()