1 /*
2  * Copyright (c) 2023 Google LLC
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_DRIVERS_SENSOR_ICM42688_DECODER_H_
8 #define ZEPHYR_DRIVERS_SENSOR_ICM42688_DECODER_H_
9 
10 #include <stdint.h>
11 #include <zephyr/drivers/sensor.h>
12 
13 struct icm42688_decoder_header {
14 	uint64_t timestamp;
15 	uint8_t is_fifo: 1;
16 	uint8_t gyro_fs: 3;
17 	uint8_t accel_fs: 2;
18 	uint8_t reserved: 2;
19 } __attribute__((__packed__));
20 
21 struct icm42688_fifo_data {
22 	struct icm42688_decoder_header header;
23 	uint8_t int_status;
24 	uint16_t gyro_odr: 4;
25 	uint16_t accel_odr: 4;
26 	uint16_t fifo_count: 11;
27 	uint16_t reserved: 5;
28 } __attribute__((__packed__));
29 
30 struct icm42688_encoded_data {
31 	struct icm42688_decoder_header header;
32 	struct {
33 		uint8_t channels: 7;
34 		uint8_t reserved: 1;
35 	}  __attribute__((__packed__));
36 	int16_t readings[7];
37 };
38 
39 int icm42688_encode(const struct device *dev, const struct sensor_chan_spec *const channels,
40 		    const size_t num_channels, uint8_t *buf);
41 
42 int icm42688_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder);
43 
44 #endif /* ZEPHYR_DRIVERS_SENSOR_ICM42688_DECODER_H_ */
45