1 /* ST Microelectronics LSM6DSV16X 6-axis IMU sensor driver
2  *
3  * Copyright (c) 2023 Google LLC
4  * Copyright (c) 2024 STMicroelectronics
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  */
8 
9 #ifndef ZEPHYR_DRIVERS_SENSOR_LSM6DSV16X_DECODER_H_
10 #define ZEPHYR_DRIVERS_SENSOR_LSM6DSV16X_DECODER_H_
11 
12 #include <stdint.h>
13 #include <zephyr/drivers/sensor.h>
14 
15 struct lsm6dsv16x_decoder_header {
16 	uint64_t timestamp;
17 	uint8_t is_fifo: 1;
18 	uint8_t gyro_fs: 4;
19 	uint8_t accel_fs: 2;
20 	uint8_t reserved: 1;
21 } __attribute__((__packed__));
22 
23 struct lsm6dsv16x_fifo_data {
24 	struct lsm6dsv16x_decoder_header header;
25 	uint8_t int_status;
26 	uint16_t gyro_odr: 4;
27 	uint16_t accel_odr: 4;
28 	uint16_t fifo_count: 11;
29 	uint16_t reserved_1: 5;
30 	uint16_t gyro_batch_odr: 4;
31 	uint16_t accel_batch_odr: 4;
32 	uint16_t temp_batch_odr: 4;
33 	uint16_t sflp_batch_odr: 3;
34 	uint16_t reserved_2: 1;
35 } __attribute__((__packed__));
36 
37 struct lsm6dsv16x_rtio_data {
38 	struct lsm6dsv16x_decoder_header header;
39 	struct {
40 		uint8_t has_accel: 1; /* set if accel channel has data */
41 		uint8_t has_gyro: 1;  /* set if gyro channel has data */
42 		uint8_t has_temp: 1;  /* set if temp channel has data */
43 		uint8_t reserved: 5;
44 	}  __attribute__((__packed__));
45 	int16_t acc[3];
46 	int16_t gyro[3];
47 	int16_t temp;
48 };
49 
50 int lsm6dsv16x_encode(const struct device *dev, const struct sensor_chan_spec *const channels,
51 		      const size_t num_channels, uint8_t *buf);
52 
53 int lsm6dsv16x_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder);
54 
55 #endif /* ZEPHYR_DRIVERS_SENSOR_LSM6DSV16X_DECODER_H_ */
56