diff --git a/drivers/sensor/tdk/icm42x70/icm42x70.c b/drivers/sensor/tdk/icm42x70/icm42x70.c index 5252b483464b6..265ac3f56c8c7 100644 --- a/drivers/sensor/tdk/icm42x70/icm42x70.c +++ b/drivers/sensor/tdk/icm42x70/icm42x70.c @@ -482,12 +482,17 @@ static void icm42x70_convert_accel(struct sensor_value *val, int16_t raw_val, ui val->val2 = conv_val % 1000000; } -static void icm42x70_convert_temp(struct sensor_value *val, int16_t raw_val) +static void icm42x70_convert_temp(struct sensor_value *val, int16_t raw_val, bool hires) { int64_t conv_val; /* see datasheet section 15.9 for details */ - conv_val = 25 * 1000000 + ((int64_t)raw_val * 1000000 / 2); + if (hires) { + conv_val = (25 * 1000000) + ((int64_t)raw_val * 1000000 / 128); + } else { + conv_val = (25 * 1000000) + ((int64_t)raw_val * 1000000 / 2); + } + val->val1 = conv_val / 1000000; val->val2 = conv_val % 1000000; } @@ -530,7 +535,15 @@ static int icm42x70_channel_get(const struct device *dev, enum sensor_channel ch icm42670_convert_gyro(val, data->gyro_z, data->gyro_fs); #endif } else if (chan == SENSOR_CHAN_DIE_TEMP) { - icm42x70_convert_temp(val, data->temp); + /* see datasheet section 15.9 for details */ + if (IS_ENABLED(CONFIG_ICM42X70_TRIGGER)) { + icm42x70_convert_temp(val, data->temp, data->driver.fifo_highres_enabled); + } else { + /* The temperature data read in non-fifo mode is of 2-bytes; + * which is same as FIFO with high resolution temp data. + */ + icm42x70_convert_temp(val, data->temp, true); + } #ifdef CONFIG_TDK_APEX } else if ((enum sensor_channel_tdk_apex)chan == SENSOR_CHAN_APEX_MOTION) { if (cfg->apex == TDK_APEX_PEDOMETER) {