Skip to content

Commit 2f6c7af

Browse files
committed
sensor: icm4268x: fix: Override FSR settings when high-res is enabled
When IMU is set to stream with High-res mode, the FSR settings are fixed: - ICM42688 at 16g and 2000dps. - ICM42686 at 32g and 4000dps. Unless this is enforced, the driver will provide incorrect scaling for readings coming through streaming when the current FS setting is any different than these. Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent 67a2782 commit 2f6c7af

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

drivers/sensor/tdk/icm4268x/icm4268x_rtio_stream.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,34 @@ static void icm4268x_fifo_count_cb(struct rtio *r, const struct rtio_sqe *sqe, v
104104
LOG_DBG("Requesting buffer [%u, %u] got %u", (unsigned int)min_read_size,
105105
(unsigned int)ideal_read_size, buf_len);
106106

107+
/** FSR are fixed for high-resolution, at which point we should
108+
* override driver FS config.
109+
*/
110+
uint8_t accel_fs_hr, gyro_fs_hr;
111+
112+
switch (drv_data->cfg.variant) {
113+
case ICM4268X_VARIANT_ICM42688:
114+
accel_fs_hr = ICM42688_DT_ACCEL_FS_16;
115+
gyro_fs_hr = ICM42688_DT_GYRO_FS_2000;
116+
break;
117+
case ICM4268X_VARIANT_ICM42686:
118+
accel_fs_hr = ICM42686_DT_ACCEL_FS_32;
119+
gyro_fs_hr = ICM42686_DT_GYRO_FS_4000;
120+
break;
121+
default:
122+
CODE_UNREACHABLE;
123+
}
124+
107125
/* Read FIFO and call back to rtio with rtio_sqe completion */
108126
/* TODO is packet format even needed? the fifo has a header per packet
109127
* already
110128
*/
111129
struct icm4268x_fifo_data hdr = {
112130
.header = {
113131
.is_fifo = true,
114-
.gyro_fs = drv_data->cfg.gyro_fs,
115-
.accel_fs = drv_data->cfg.accel_fs,
132+
.variant = drv_data->cfg.variant,
133+
.gyro_fs = drv_data->cfg.fifo_hires ? gyro_fs_hr : drv_data->cfg.gyro_fs,
134+
.accel_fs = drv_data->cfg.fifo_hires ? accel_fs_hr : drv_data->cfg.accel_fs,
116135
.timestamp = drv_data->timestamp,
117136
.axis_align[0] = drv_data->cfg.axis_align[0],
118137
.axis_align[1] = drv_data->cfg.axis_align[1],

0 commit comments

Comments
 (0)