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