Lines Matching +full:temperature +full:- +full:format

1 /* ST Microelectronics LSM6DSV16X 6-axis IMU sensor driver
6 * SPDX-License-Identifier: Apache-2.0
11 #include <zephyr/dt-bindings/sensor/lsm6dsv16x.h>
69 (q31_t) (round((val) * ((int64_t)1 << (31 - (range)))))
76 (q31_t) ((int64_t)(micro_val) * ((int64_t)1 << (31 - (range))) / 1000000LL)
97 /* bit range for Temperature sensor */
100 /* transform temperature LSB into micro-Celsius */
106 /* Calculate scaling factor to transform micro-g/LSB unit into micro-ms2/LSB */
121 /* Calculate scaling factor to transform micro-dps/LSB unit into micro-rads/LSB */
143 const struct lsm6dsv16x_decoder_header *header = &data->header; in lsm6dsv16x_decoder_get_frame_count()
146 return -ENOTSUP; in lsm6dsv16x_decoder_get_frame_count()
149 if (!header->is_fifo) { in lsm6dsv16x_decoder_get_frame_count()
164 return -ENOTSUP; in lsm6dsv16x_decoder_get_frame_count()
182 buffer_end = buffer + LSM6DSV16X_FIFO_SIZE(edata->fifo_count); in lsm6dsv16x_decoder_get_frame_count()
260 const struct lsm6dsv16x_decoder_header *header = &edata->header; in lsm6dsv16x_decode_fifo()
279 buffer_end = buffer + LSM6DSV16X_FIFO_SIZE(edata->fifo_count); in lsm6dsv16x_decode_fifo()
287 ((struct sensor_data_header *)data_out)->base_timestamp_ns = in lsm6dsv16x_decode_fifo()
288 edata->header.timestamp - in lsm6dsv16x_decode_fifo()
289 (tot_chan_fifo_words - 1) * accel_period_ns[edata->accel_batch_odr]; in lsm6dsv16x_decode_fifo()
291 ((struct sensor_data_header *)data_out)->base_timestamp_ns = in lsm6dsv16x_decode_fifo()
292 edata->header.timestamp - in lsm6dsv16x_decode_fifo()
293 (tot_chan_fifo_words - 1) * gyro_period_ns[edata->gyro_batch_odr]; in lsm6dsv16x_decode_fifo()
296 ((struct sensor_data_header *)data_out)->base_timestamp_ns = in lsm6dsv16x_decode_fifo()
297 edata->header.timestamp - in lsm6dsv16x_decode_fifo()
298 (tot_chan_fifo_words - 1) * temp_period_ns[edata->temp_batch_odr]; in lsm6dsv16x_decode_fifo()
303 ((struct sensor_data_header *)data_out)->base_timestamp_ns = in lsm6dsv16x_decode_fifo()
304 edata->header.timestamp - in lsm6dsv16x_decode_fifo()
305 (tot_chan_fifo_words - 1) * sflp_period_ns[edata->sflp_batch_odr]; in lsm6dsv16x_decode_fifo()
321 const int32_t scale = accel_scaler[header->accel_fs]; in lsm6dsv16x_decode_fifo()
335 out->readings[count].timestamp_delta = in lsm6dsv16x_decode_fifo()
336 (xl_count - 1) * accel_period_ns[edata->accel_batch_odr]; in lsm6dsv16x_decode_fifo()
342 out->shift = accel_range[header->accel_fs]; in lsm6dsv16x_decode_fifo()
344 out->readings[count].x = Q31_SHIFT_MICROVAL(scale * x, out->shift); in lsm6dsv16x_decode_fifo()
345 out->readings[count].y = Q31_SHIFT_MICROVAL(scale * y, out->shift); in lsm6dsv16x_decode_fifo()
346 out->readings[count].z = Q31_SHIFT_MICROVAL(scale * z, out->shift); in lsm6dsv16x_decode_fifo()
352 const int32_t scale = gyro_scaler[header->gyro_fs]; in lsm6dsv16x_decode_fifo()
366 out->readings[count].timestamp_delta = in lsm6dsv16x_decode_fifo()
367 (gy_count - 1) * gyro_period_ns[edata->gyro_batch_odr]; in lsm6dsv16x_decode_fifo()
373 out->shift = gyro_range[header->gyro_fs]; in lsm6dsv16x_decode_fifo()
375 out->readings[count].x = Q31_SHIFT_MICROVAL(scale * x, out->shift); in lsm6dsv16x_decode_fifo()
376 out->readings[count].y = Q31_SHIFT_MICROVAL(scale * y, out->shift); in lsm6dsv16x_decode_fifo()
377 out->readings[count].z = Q31_SHIFT_MICROVAL(scale * z, out->shift); in lsm6dsv16x_decode_fifo()
398 out->readings[count].timestamp_delta = in lsm6dsv16x_decode_fifo()
399 (temp_count - 1) * temp_period_ns[edata->temp_batch_odr]; in lsm6dsv16x_decode_fifo()
404 out->shift = temp_range; in lsm6dsv16x_decode_fifo()
406 out->readings[count].temperature = Q31_SHIFT_MICROVAL(t_uC, out->shift); in lsm6dsv16x_decode_fifo()
427 out->readings[count].timestamp_delta = in lsm6dsv16x_decode_fifo()
428 (game_rot_count - 1) * sflp_period_ns[edata->sflp_batch_odr]; in lsm6dsv16x_decode_fifo()
451 w = sqrtf(1.0f - sumsq); in lsm6dsv16x_decode_fifo()
454 * Quaternions are numbers between -1 and 1. So let's select the signed in lsm6dsv16x_decode_fifo()
455 * Q0.31 format (m = 0, n (fractional bits) == 31) in lsm6dsv16x_decode_fifo()
457 out->shift = 0; in lsm6dsv16x_decode_fifo()
459 out->readings[count].x = Q31_SHIFT_VAL(x.f, out->shift); in lsm6dsv16x_decode_fifo()
460 out->readings[count].y = Q31_SHIFT_VAL(y.f, out->shift); in lsm6dsv16x_decode_fifo()
461 out->readings[count].z = Q31_SHIFT_VAL(z.f, out->shift); in lsm6dsv16x_decode_fifo()
462 out->readings[count].w = Q31_SHIFT_VAL(w, out->shift); in lsm6dsv16x_decode_fifo()
484 out->readings[count].timestamp_delta = in lsm6dsv16x_decode_fifo()
485 (gbias_count - 1) * sflp_period_ns[edata->sflp_batch_odr]; in lsm6dsv16x_decode_fifo()
491 out->shift = gyro_range[LSM6DSV16X_DT_FS_125DPS]; in lsm6dsv16x_decode_fifo()
493 out->readings[count].x = Q31_SHIFT_MICROVAL(scale * x, out->shift); in lsm6dsv16x_decode_fifo()
494 out->readings[count].y = Q31_SHIFT_MICROVAL(scale * y, out->shift); in lsm6dsv16x_decode_fifo()
495 out->readings[count].z = Q31_SHIFT_MICROVAL(scale * z, out->shift); in lsm6dsv16x_decode_fifo()
515 out->readings[count].timestamp_delta = in lsm6dsv16x_decode_fifo()
516 (gravity_count - 1) * sflp_period_ns[edata->sflp_batch_odr]; in lsm6dsv16x_decode_fifo()
522 out->shift = 12; in lsm6dsv16x_decode_fifo()
524 out->readings[count].x = Q31_SHIFT_VAL(x, out->shift); in lsm6dsv16x_decode_fifo()
525 out->readings[count].y = Q31_SHIFT_VAL(y, out->shift); in lsm6dsv16x_decode_fifo()
526 out->readings[count].z = Q31_SHIFT_VAL(z, out->shift); in lsm6dsv16x_decode_fifo()
550 const struct lsm6dsv16x_decoder_header *header = &edata->header; in lsm6dsv16x_decode_sample()
556 return -EINVAL; in lsm6dsv16x_decode_sample()
564 const int32_t scale = accel_scaler[header->accel_fs]; in lsm6dsv16x_decode_sample()
566 if (edata->has_accel == 0) { in lsm6dsv16x_decode_sample()
567 return -ENODATA; in lsm6dsv16x_decode_sample()
572 out->header.base_timestamp_ns = edata->header.timestamp; in lsm6dsv16x_decode_sample()
573 out->header.reading_count = 1; in lsm6dsv16x_decode_sample()
575 out->shift = accel_range[header->accel_fs]; in lsm6dsv16x_decode_sample()
577 out->readings[0].x = Q31_SHIFT_MICROVAL(scale * edata->acc[0], out->shift); in lsm6dsv16x_decode_sample()
578 out->readings[0].y = Q31_SHIFT_MICROVAL(scale * edata->acc[1], out->shift); in lsm6dsv16x_decode_sample()
579 out->readings[0].z = Q31_SHIFT_MICROVAL(scale * edata->acc[2], out->shift); in lsm6dsv16x_decode_sample()
587 const int32_t scale = gyro_scaler[header->gyro_fs]; in lsm6dsv16x_decode_sample()
589 if (edata->has_gyro == 0) { in lsm6dsv16x_decode_sample()
590 return -ENODATA; in lsm6dsv16x_decode_sample()
595 out->header.base_timestamp_ns = edata->header.timestamp; in lsm6dsv16x_decode_sample()
596 out->header.reading_count = 1; in lsm6dsv16x_decode_sample()
598 out->shift = gyro_range[header->gyro_fs]; in lsm6dsv16x_decode_sample()
600 out->readings[0].x = Q31_SHIFT_MICROVAL(scale * edata->gyro[0], out->shift); in lsm6dsv16x_decode_sample()
601 out->readings[0].y = Q31_SHIFT_MICROVAL(scale * edata->gyro[1], out->shift); in lsm6dsv16x_decode_sample()
602 out->readings[0].z = Q31_SHIFT_MICROVAL(scale * edata->gyro[2], out->shift); in lsm6dsv16x_decode_sample()
610 if (edata->has_temp == 0) { in lsm6dsv16x_decode_sample()
611 return -ENODATA; in lsm6dsv16x_decode_sample()
616 out->header.base_timestamp_ns = edata->header.timestamp; in lsm6dsv16x_decode_sample()
617 out->header.reading_count = 1; in lsm6dsv16x_decode_sample()
619 out->shift = temp_range; in lsm6dsv16x_decode_sample()
621 /* transform temperature LSB into micro-Celsius */ in lsm6dsv16x_decode_sample()
622 t_uC = SENSOR_TEMP_UCELSIUS(edata->temp); in lsm6dsv16x_decode_sample()
624 out->readings[0].temperature = Q31_SHIFT_MICROVAL(t_uC, out->shift); in lsm6dsv16x_decode_sample()
630 return -EINVAL; in lsm6dsv16x_decode_sample()
641 if (header->is_fifo) { in lsm6dsv16x_decoder_decode()
669 return -ENOTSUP; in lsm6dsv16x_decoder_get_size_info()