Lines Matching +full:extra +full:- +full:byte

1 /* ST Microelectronics LSM6DSV16X 6-axis IMU sensor driver
5 * SPDX-License-Identifier: Apache-2.0
24 * lsm6dsv16x_enable_xl_int - XL enable selected int pin to generate interrupt
28 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_enable_xl_int()
29 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_enable_xl_int()
35 /* dummy read: re-trigger interrupt */ in lsm6dsv16x_enable_xl_int()
40 if ((cfg->drdy_pin == 1) || (ON_I3C_BUS(cfg) && (!I3C_INT_PIN(cfg)))) { in lsm6dsv16x_enable_xl_int()
70 * lsm6dsv16x_enable_g_int - Gyro enable selected int pin to generate interrupt
74 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_enable_g_int()
75 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_enable_g_int()
81 /* dummy read: re-trigger interrupt */ in lsm6dsv16x_enable_g_int()
86 if ((cfg->drdy_pin == 1) || (ON_I3C_BUS(cfg) && (!I3C_INT_PIN(cfg)))) { in lsm6dsv16x_enable_g_int()
116 * lsm6dsv16x_trigger_set - link external trigger to event data ready
122 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_trigger_set()
123 struct lsm6dsv16x_data *lsm6dsv16x = dev->data; in lsm6dsv16x_trigger_set()
126 if (!cfg->trig_enabled) { in lsm6dsv16x_trigger_set()
128 return -ENOTSUP; in lsm6dsv16x_trigger_set()
133 return -EINVAL; in lsm6dsv16x_trigger_set()
136 switch (trig->type) { in lsm6dsv16x_trigger_set()
138 if (trig->chan == SENSOR_CHAN_ACCEL_XYZ) { in lsm6dsv16x_trigger_set()
139 lsm6dsv16x->handler_drdy_acc = handler; in lsm6dsv16x_trigger_set()
140 lsm6dsv16x->trig_drdy_acc = trig; in lsm6dsv16x_trigger_set()
146 } else if (trig->chan == SENSOR_CHAN_GYRO_XYZ) { in lsm6dsv16x_trigger_set()
147 lsm6dsv16x->handler_drdy_gyr = handler; in lsm6dsv16x_trigger_set()
148 lsm6dsv16x->trig_drdy_gyr = trig; in lsm6dsv16x_trigger_set()
158 ret = -ENOTSUP; in lsm6dsv16x_trigger_set()
168 * lsm6dsv16x_handle_interrupt - handle the drdy event
173 struct lsm6dsv16x_data *lsm6dsv16x = dev->data; in lsm6dsv16x_handle_interrupt()
174 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_handle_interrupt()
175 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_handle_interrupt()
181 * read (clearing the interrupt condition), so we can skip the extra bus in lsm6dsv16x_handle_interrupt()
198 if ((status.drdy_xl) && (lsm6dsv16x->handler_drdy_acc != NULL)) { in lsm6dsv16x_handle_interrupt()
199 lsm6dsv16x->handler_drdy_acc(dev, lsm6dsv16x->trig_drdy_acc); in lsm6dsv16x_handle_interrupt()
202 if ((status.drdy_gy) && (lsm6dsv16x->handler_drdy_gyr != NULL)) { in lsm6dsv16x_handle_interrupt()
203 lsm6dsv16x->handler_drdy_gyr(dev, lsm6dsv16x->trig_drdy_gyr); in lsm6dsv16x_handle_interrupt()
209 ret = gpio_pin_interrupt_configure_dt(lsm6dsv16x->drdy_gpio, in lsm6dsv16x_handle_interrupt()
212 LOG_ERR("%s: Not able to configure pin_int", dev->name); in lsm6dsv16x_handle_interrupt()
221 k_sem_give(&lsm6dsv16x->intr_sem); in lsm6dsv16x_intr_callback()
223 k_work_submit(&lsm6dsv16x->work); in lsm6dsv16x_intr_callback()
226 lsm6dsv16x_stream_irq_handler(lsm6dsv16x->dev); in lsm6dsv16x_intr_callback()
239 ret = gpio_pin_interrupt_configure_dt(lsm6dsv16x->drdy_gpio, GPIO_INT_DISABLE); in lsm6dsv16x_gpio_callback()
241 LOG_ERR("%s: Not able to configure pin_int", dev->name); in lsm6dsv16x_gpio_callback()
256 k_sem_take(&lsm6dsv16x->intr_sem, K_FOREVER); in lsm6dsv16x_thread()
257 lsm6dsv16x_handle_interrupt(lsm6dsv16x->dev); in lsm6dsv16x_thread()
268 lsm6dsv16x_handle_interrupt(lsm6dsv16x->dev); in lsm6dsv16x_work_cb()
276 const struct device *dev = target->dev; in lsm6dsv16x_ibi_cb()
277 struct lsm6dsv16x_data *lsm6dsv16x = dev->data; in lsm6dsv16x_ibi_cb()
281 * 1st byte: MDB in lsm6dsv16x_ibi_cb()
282 * - MDB[0]: FIFO interrupts (FIFO_WTM_IA, FIFO_OVR_IA, FIFO_FULL_IA, CONTER_BDR_IA) in lsm6dsv16x_ibi_cb()
283 * - MDB[1]: Physical interrupts (XLDS, GDA, TDA, XLDA_OIS, GDA_OIS) in lsm6dsv16x_ibi_cb()
284 * - MDB[2]: Basic interrupts (SLEEP_CHANGE_IA, D6D_IA, DOUBLE_TAP, SINGLE_TAP, WU_IA, in lsm6dsv16x_ibi_cb()
286 * - MDB[3]: SHUB DRDY (SENS_HUB_ENDOP) in lsm6dsv16x_ibi_cb()
287 * - MDB[4]: Advanced Function interrupt group in lsm6dsv16x_ibi_cb()
288 * - MDB[7:5]: 3'b000: Vendor Definied in lsm6dsv16x_ibi_cb()
290 * 2nd byte: FIFO_STATUS1 in lsm6dsv16x_ibi_cb()
291 * 3rd byte: FIFO_STATUS2 in lsm6dsv16x_ibi_cb()
292 * 4th byte: ALL_INT_SRC in lsm6dsv16x_ibi_cb()
293 * 5th byte: STATUS_REG in lsm6dsv16x_ibi_cb()
294 * 6th byte: STATUS_REG_OIS in lsm6dsv16x_ibi_cb()
295 * 7th byte: STATUS_MASTER_MAIN in lsm6dsv16x_ibi_cb()
296 * 8th byte: EMB_FUNC_STATUS in lsm6dsv16x_ibi_cb()
297 * 9th byte: FSM_STATUS in lsm6dsv16x_ibi_cb()
298 * 10th byte: MLC_STATUS in lsm6dsv16x_ibi_cb()
300 if (payload->payload_len != sizeof(lsm6dsv16x->ibi_payload)) { in lsm6dsv16x_ibi_cb()
302 return -EINVAL; in lsm6dsv16x_ibi_cb()
305 memcpy(&lsm6dsv16x->ibi_payload, payload->payload, payload->payload_len); in lsm6dsv16x_ibi_cb()
315 struct lsm6dsv16x_data *lsm6dsv16x = dev->data; in lsm6dsv16x_init_interrupt()
316 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_init_interrupt()
317 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_init_interrupt()
320 lsm6dsv16x->drdy_gpio = (cfg->drdy_pin == 1) ? in lsm6dsv16x_init_interrupt()
321 (struct gpio_dt_spec *)&cfg->int1_gpio : in lsm6dsv16x_init_interrupt()
322 (struct gpio_dt_spec *)&cfg->int2_gpio; in lsm6dsv16x_init_interrupt()
325 if ((!ON_I3C_BUS(cfg) || (I3C_INT_PIN(cfg))) && !gpio_is_ready_dt(lsm6dsv16x->drdy_gpio)) { in lsm6dsv16x_init_interrupt()
327 return -EINVAL; in lsm6dsv16x_init_interrupt()
331 lsm6dsv16x_stream_irq_handler(lsm6dsv16x->dev); in lsm6dsv16x_init_interrupt()
335 k_sem_init(&lsm6dsv16x->intr_sem, 0, K_SEM_MAX_LIMIT); in lsm6dsv16x_init_interrupt()
337 k_thread_create(&lsm6dsv16x->thread, lsm6dsv16x->thread_stack, in lsm6dsv16x_init_interrupt()
342 k_thread_name_set(&lsm6dsv16x->thread, "lsm6dsv16x"); in lsm6dsv16x_init_interrupt()
344 lsm6dsv16x->work.handler = lsm6dsv16x_work_cb; in lsm6dsv16x_init_interrupt()
348 ret = gpio_pin_configure_dt(lsm6dsv16x->drdy_gpio, GPIO_INPUT); in lsm6dsv16x_init_interrupt()
354 gpio_init_callback(&lsm6dsv16x->gpio_cb, in lsm6dsv16x_init_interrupt()
356 BIT(lsm6dsv16x->drdy_gpio->pin)); in lsm6dsv16x_init_interrupt()
358 if (gpio_add_callback(lsm6dsv16x->drdy_gpio->port, &lsm6dsv16x->gpio_cb) < 0) { in lsm6dsv16x_init_interrupt()
360 return -EIO; in lsm6dsv16x_init_interrupt()
366 LOG_DBG("drdy_pulsed is %d", (int)cfg->drdy_pulsed); in lsm6dsv16x_init_interrupt()
367 lsm6dsv16x_data_ready_mode_t mode = cfg->drdy_pulsed ? LSM6DSV16X_DRDY_PULSED : in lsm6dsv16x_init_interrupt()
373 LOG_ERR("drdy_pulsed config error %d", (int)cfg->drdy_pulsed); in lsm6dsv16x_init_interrupt()
387 ret = gpio_pin_interrupt_configure_dt(lsm6dsv16x->drdy_gpio, in lsm6dsv16x_init_interrupt()
395 lsm6dsv16x->i3c_dev->ibi_cb = lsm6dsv16x_ibi_cb; in lsm6dsv16x_init_interrupt()
408 ret = lsm6dsv16x_i3c_ibi_time_set(ctx, cfg->bus_act_sel); in lsm6dsv16x_init_interrupt()
411 return -EIO; in lsm6dsv16x_init_interrupt()
414 if (i3c_ibi_enable(lsm6dsv16x->i3c_dev) != 0) { in lsm6dsv16x_init_interrupt()
416 return -EIO; in lsm6dsv16x_init_interrupt()
424 return gpio_pin_interrupt_configure_dt(lsm6dsv16x->drdy_gpio, in lsm6dsv16x_init_interrupt()