Lines Matching +full:current +full:- +full:lsb
5 * SPDX-License-Identifier: Apache-2.0
21 const struct fxos8700_config *config = data->dev->config; in fxos8700_gpio_callback()
23 if ((pin_mask & BIT(config->int_gpio.pin)) == 0U) { in fxos8700_gpio_callback()
27 gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_DISABLE); in fxos8700_gpio_callback()
30 k_sem_give(&data->trig_sem); in fxos8700_gpio_callback()
32 k_work_submit(&data->work); in fxos8700_gpio_callback()
38 struct fxos8700_data *data = dev->data; in fxos8700_handle_drdy_int()
40 if (data->drdy_handler) { in fxos8700_handle_drdy_int()
41 data->drdy_handler(dev, data->drdy_trig); in fxos8700_handle_drdy_int()
50 const struct fxos8700_config *config = dev->config; in fxos8700_handle_pulse_int()
51 struct fxos8700_data *data = dev->data; in fxos8700_handle_pulse_int()
56 k_sem_take(&data->sem, K_FOREVER); in fxos8700_handle_pulse_int()
58 if (config->ops->byte_read(dev, FXOS8700_REG_PULSE_SRC, in fxos8700_handle_pulse_int()
63 k_sem_give(&data->sem); in fxos8700_handle_pulse_int()
66 handler = data->double_tap_handler; in fxos8700_handle_pulse_int()
67 trig = data->double_tap_trig; in fxos8700_handle_pulse_int()
69 handler = data->tap_handler; in fxos8700_handle_pulse_int()
70 trig = data->tap_trig; in fxos8700_handle_pulse_int()
84 const struct fxos8700_config *config = dev->config; in fxos8700_handle_motion_int()
85 struct fxos8700_data *data = dev->data; in fxos8700_handle_motion_int()
86 sensor_trigger_handler_t handler = data->motion_handler; in fxos8700_handle_motion_int()
89 k_sem_take(&data->sem, K_FOREVER); in fxos8700_handle_motion_int()
91 if (config->ops->byte_read(dev, FXOS8700_REG_FF_MT_SRC, in fxos8700_handle_motion_int()
96 k_sem_give(&data->sem); in fxos8700_handle_motion_int()
100 handler(dev, data->motion_trig); in fxos8700_handle_motion_int()
110 struct fxos8700_data *data = dev->data; in fxos8700_handle_m_vecm_int()
112 if (data->m_vecm_handler) { in fxos8700_handle_m_vecm_int()
113 data->m_vecm_handler(dev, data->m_vecm_trig); in fxos8700_handle_m_vecm_int()
122 const struct fxos8700_config *config = dev->config; in fxos8700_handle_int()
123 struct fxos8700_data *data = dev->data; in fxos8700_handle_int()
127 k_sem_take(&data->sem, K_FOREVER); in fxos8700_handle_int()
129 if (config->ops->byte_read(dev, FXOS8700_REG_INT_SOURCE, in fxos8700_handle_int()
135 k_sem_give(&data->sem); in fxos8700_handle_int()
152 k_sem_take(&data->sem, K_FOREVER); in fxos8700_handle_int()
154 if (config->ops->byte_read(dev, FXOS8700_REG_M_INT_SRC, in fxos8700_handle_int()
160 k_sem_give(&data->sem); in fxos8700_handle_int()
167 gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in fxos8700_handle_int()
179 k_sem_take(&data->trig_sem, K_FOREVER); in fxos8700_thread_main()
180 fxos8700_handle_int(data->dev); in fxos8700_thread_main()
191 fxos8700_handle_int(data->dev); in fxos8700_work_handler()
199 const struct fxos8700_config *config = dev->config; in fxos8700_trigger_set()
200 struct fxos8700_data *data = dev->data; in fxos8700_trigger_set()
205 k_sem_take(&data->sem, K_FOREVER); in fxos8700_trigger_set()
207 switch (trig->type) { in fxos8700_trigger_set()
210 data->drdy_handler = handler; in fxos8700_trigger_set()
211 data->drdy_trig = trig; in fxos8700_trigger_set()
216 data->tap_handler = handler; in fxos8700_trigger_set()
217 data->tap_trig = trig; in fxos8700_trigger_set()
221 data->double_tap_handler = handler; in fxos8700_trigger_set()
222 data->double_tap_trig = trig; in fxos8700_trigger_set()
228 data->motion_handler = handler; in fxos8700_trigger_set()
229 data->motion_trig = trig; in fxos8700_trigger_set()
235 data->m_vecm_handler = handler; in fxos8700_trigger_set()
236 data->m_vecm_trig = trig; in fxos8700_trigger_set()
241 ret = -ENOTSUP; in fxos8700_trigger_set()
246 * registers, therefore get the current power mode so we can restore it in fxos8700_trigger_set()
251 ret = -EIO; in fxos8700_trigger_set()
258 ret = -EIO; in fxos8700_trigger_set()
263 if (config->ops->reg_field_update(dev, FXOS8700_REG_CTRLREG4, mask, in fxos8700_trigger_set()
266 ret = -EIO; in fxos8700_trigger_set()
273 ret = -EIO; in fxos8700_trigger_set()
278 k_sem_give(&data->sem); in fxos8700_trigger_set()
286 const struct fxos8700_config *config = dev->config; in fxos8700_pulse_init()
288 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_CFG, in fxos8700_pulse_init()
289 config->pulse_cfg)) { in fxos8700_pulse_init()
290 return -EIO; in fxos8700_pulse_init()
293 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_THSX, in fxos8700_pulse_init()
294 config->pulse_ths[0])) { in fxos8700_pulse_init()
295 return -EIO; in fxos8700_pulse_init()
298 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_THSY, in fxos8700_pulse_init()
299 config->pulse_ths[1])) { in fxos8700_pulse_init()
300 return -EIO; in fxos8700_pulse_init()
303 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_THSZ, in fxos8700_pulse_init()
304 config->pulse_ths[2])) { in fxos8700_pulse_init()
305 return -EIO; in fxos8700_pulse_init()
308 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_TMLT, in fxos8700_pulse_init()
309 config->pulse_tmlt)) { in fxos8700_pulse_init()
310 return -EIO; in fxos8700_pulse_init()
313 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_LTCY, in fxos8700_pulse_init()
314 config->pulse_ltcy)) { in fxos8700_pulse_init()
315 return -EIO; in fxos8700_pulse_init()
318 if (config->ops->byte_write(dev, FXOS8700_REG_PULSE_WIND, in fxos8700_pulse_init()
319 config->pulse_wind)) { in fxos8700_pulse_init()
320 return -EIO; in fxos8700_pulse_init()
330 const struct fxos8700_config *config = dev->config; in fxos8700_motion_init()
333 if (config->ops->byte_write(dev, in fxos8700_motion_init()
340 return -EIO; in fxos8700_motion_init()
344 if (config->ops->byte_write(dev, FXOS8700_REG_FF_MT_THS, in fxos8700_motion_init()
346 return -EIO; in fxos8700_motion_init()
356 const struct fxos8700_config *config = dev->config; in fxos8700_m_vecm_init()
357 uint8_t m_vecm_cfg = config->mag_vecm_cfg; in fxos8700_m_vecm_init()
364 /* Set magnetic vector-magnitude function */ in fxos8700_m_vecm_init()
365 if (config->ops->byte_write(dev, FXOS8700_REG_M_VECM_CFG, in fxos8700_m_vecm_init()
367 LOG_ERR("Could not set magnetic vector-magnitude function"); in fxos8700_m_vecm_init()
368 return -EIO; in fxos8700_m_vecm_init()
371 /* Set magnetic vector-magnitude function threshold values: in fxos8700_m_vecm_init()
372 * handle both MSB and LSB registers in fxos8700_m_vecm_init()
374 if (config->ops->byte_write(dev, FXOS8700_REG_M_VECM_THS_MSB, in fxos8700_m_vecm_init()
375 config->mag_vecm_ths[0])) { in fxos8700_m_vecm_init()
376 LOG_ERR("Could not set magnetic vector-magnitude function threshold MSB value"); in fxos8700_m_vecm_init()
377 return -EIO; in fxos8700_m_vecm_init()
380 if (config->ops->byte_write(dev, FXOS8700_REG_M_VECM_THS_LSB, in fxos8700_m_vecm_init()
381 config->mag_vecm_ths[1])) { in fxos8700_m_vecm_init()
382 LOG_ERR("Could not set magnetic vector-magnitude function threshold LSB value"); in fxos8700_m_vecm_init()
383 return -EIO; in fxos8700_m_vecm_init()
392 const struct fxos8700_config *config = dev->config; in fxos8700_trigger_init()
393 struct fxos8700_data *data = dev->data; in fxos8700_trigger_init()
397 data->dev = dev; in fxos8700_trigger_init()
400 k_sem_init(&data->trig_sem, 0, K_SEM_MAX_LIMIT); in fxos8700_trigger_init()
401 k_thread_create(&data->thread, data->thread_stack, in fxos8700_trigger_init()
408 data->work.handler = fxos8700_work_handler; in fxos8700_trigger_init()
423 if (config->ops->byte_write(dev, FXOS8700_REG_CTRLREG5, in fxos8700_trigger_init()
426 return -EIO; in fxos8700_trigger_init()
432 return -EIO; in fxos8700_trigger_init()
438 return -EIO; in fxos8700_trigger_init()
443 LOG_ERR("Could not configure magnetic vector-magnitude"); in fxos8700_trigger_init()
444 return -EIO; in fxos8700_trigger_init()
448 if (!gpio_is_ready_dt(&config->int_gpio)) { in fxos8700_trigger_init()
450 return -ENODEV; in fxos8700_trigger_init()
453 ret = gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT); in fxos8700_trigger_init()
458 gpio_init_callback(&data->gpio_cb, fxos8700_gpio_callback, in fxos8700_trigger_init()
459 BIT(config->int_gpio.pin)); in fxos8700_trigger_init()
461 ret = gpio_add_callback(config->int_gpio.port, &data->gpio_cb); in fxos8700_trigger_init()
466 ret = gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in fxos8700_trigger_init()