Lines Matching +full:interrupt +full:- +full:map
4 * SPDX-License-Identifier: Apache-2.0
23 const struct bma280_config *config = dev->config; in setup_int1()
25 gpio_pin_interrupt_configure_dt(&config->int1_gpio, in setup_int1()
34 const struct bma280_config *config = dev->config; in bma280_attr_set()
37 if (!config->int1_gpio.port) { in bma280_attr_set()
38 return -ENOTSUP; in bma280_attr_set()
42 return -ENOTSUP; in bma280_attr_set()
47 slope_th = (uint64_t)val->val1 * 1000000U + (uint64_t)val->val2; in bma280_attr_set()
49 if (i2c_reg_write_byte_dt(&config->i2c, in bma280_attr_set()
53 return -EIO; in bma280_attr_set()
56 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_attr_set()
59 val->val1 << BMA280_SLOPE_DUR_SHIFT) in bma280_attr_set()
62 return -EIO; in bma280_attr_set()
65 return -ENOTSUP; in bma280_attr_set()
79 setup_int1(drv_data->dev, false); in bma280_gpio_callback()
82 k_sem_give(&drv_data->gpio_sem); in bma280_gpio_callback()
84 k_work_submit(&drv_data->work); in bma280_gpio_callback()
90 struct bma280_data *drv_data = dev->data; in bma280_thread_cb()
91 const struct bma280_config *config = dev->config; in bma280_thread_cb()
96 err = i2c_reg_read_byte_dt(&config->i2c, in bma280_thread_cb()
99 drv_data->data_ready_handler != NULL && in bma280_thread_cb()
101 drv_data->data_ready_handler(dev, in bma280_thread_cb()
102 drv_data->data_ready_trigger); in bma280_thread_cb()
106 err = i2c_reg_read_byte_dt(&config->i2c, in bma280_thread_cb()
109 drv_data->any_motion_handler != NULL && in bma280_thread_cb()
111 drv_data->any_motion_handler(dev, in bma280_thread_cb()
112 drv_data->any_motion_trigger); in bma280_thread_cb()
114 /* clear latched interrupt */ in bma280_thread_cb()
115 err = i2c_reg_update_byte_dt(&config->i2c, in bma280_thread_cb()
121 LOG_DBG("Could not update clear the interrupt"); in bma280_thread_cb()
138 k_sem_take(&drv_data->gpio_sem, K_FOREVER); in bma280_thread()
139 bma280_thread_cb(drv_data->dev); in bma280_thread()
150 bma280_thread_cb(drv_data->dev); in bma280_work_cb()
158 struct bma280_data *drv_data = dev->data; in bma280_trigger_set()
159 const struct bma280_config *config = dev->config; in bma280_trigger_set()
161 if (!config->int1_gpio.port) { in bma280_trigger_set()
162 return -ENOTSUP; in bma280_trigger_set()
165 if (trig->type == SENSOR_TRIG_DATA_READY) { in bma280_trigger_set()
166 /* disable data ready interrupt while changing trigger params */ in bma280_trigger_set()
167 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_trigger_set()
170 LOG_DBG("Could not disable data ready interrupt"); in bma280_trigger_set()
171 return -EIO; in bma280_trigger_set()
174 drv_data->data_ready_handler = handler; in bma280_trigger_set()
178 drv_data->data_ready_trigger = trig; in bma280_trigger_set()
180 /* enable data ready interrupt */ in bma280_trigger_set()
181 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_trigger_set()
185 LOG_DBG("Could not enable data ready interrupt"); in bma280_trigger_set()
186 return -EIO; in bma280_trigger_set()
188 } else if (trig->type == SENSOR_TRIG_DELTA) { in bma280_trigger_set()
189 /* disable any-motion interrupt while changing trigger params */ in bma280_trigger_set()
190 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_trigger_set()
193 LOG_DBG("Could not disable data ready interrupt"); in bma280_trigger_set()
194 return -EIO; in bma280_trigger_set()
197 drv_data->any_motion_handler = handler; in bma280_trigger_set()
201 drv_data->any_motion_trigger = trig; in bma280_trigger_set()
203 /* enable any-motion interrupt */ in bma280_trigger_set()
204 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_trigger_set()
208 LOG_DBG("Could not enable data ready interrupt"); in bma280_trigger_set()
209 return -EIO; in bma280_trigger_set()
212 return -ENOTSUP; in bma280_trigger_set()
220 struct bma280_data *drv_data = dev->data; in bma280_init_interrupt()
221 const struct bma280_config *config = dev->config; in bma280_init_interrupt()
224 if (i2c_reg_write_byte_dt(&config->i2c, in bma280_init_interrupt()
229 return -EIO; in bma280_init_interrupt()
232 /* setup data ready gpio interrupt */ in bma280_init_interrupt()
233 if (!gpio_is_ready_dt(&config->int1_gpio)) { in bma280_init_interrupt()
235 return -ENODEV; in bma280_init_interrupt()
238 gpio_pin_configure_dt(&config->int1_gpio, GPIO_INPUT); in bma280_init_interrupt()
240 gpio_init_callback(&drv_data->gpio_cb, in bma280_init_interrupt()
242 BIT(config->int1_gpio.pin)); in bma280_init_interrupt()
244 if (gpio_add_callback(config->int1_gpio.port, &drv_data->gpio_cb) < 0) { in bma280_init_interrupt()
246 return -EIO; in bma280_init_interrupt()
249 /* map data ready interrupt to INT1 */ in bma280_init_interrupt()
250 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_init_interrupt()
254 LOG_DBG("Could not map data ready interrupt pin"); in bma280_init_interrupt()
255 return -EIO; in bma280_init_interrupt()
258 /* map any-motion interrupt to INT1 */ in bma280_init_interrupt()
259 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_init_interrupt()
263 LOG_DBG("Could not map any-motion interrupt pin"); in bma280_init_interrupt()
264 return -EIO; in bma280_init_interrupt()
267 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_init_interrupt()
270 LOG_DBG("Could not disable data ready interrupt"); in bma280_init_interrupt()
271 return -EIO; in bma280_init_interrupt()
274 /* disable any-motion interrupt */ in bma280_init_interrupt()
275 if (i2c_reg_update_byte_dt(&config->i2c, in bma280_init_interrupt()
278 LOG_DBG("Could not disable data ready interrupt"); in bma280_init_interrupt()
279 return -EIO; in bma280_init_interrupt()
282 drv_data->dev = dev; in bma280_init_interrupt()
285 k_sem_init(&drv_data->gpio_sem, 0, K_SEM_MAX_LIMIT); in bma280_init_interrupt()
287 k_thread_create(&drv_data->thread, drv_data->thread_stack, in bma280_init_interrupt()
293 drv_data->work.handler = bma280_work_cb; in bma280_init_interrupt()