Skip to content

Commit 19fe816

Browse files
vladislav-pejicnashif
authored andcommitted
driver: sensor: adxl367: Temp conversion
Fix for conversion of temperature values in adxl367_temp_convert and missing break statement. Signed-off-by: Vladislav Pejic <[email protected]>
1 parent eb15f30 commit 19fe816

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/sensor/adi/adxl367/adxl367.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -903,10 +903,10 @@ void adxl367_temp_convert(struct sensor_value *val, int16_t value)
903903
static void adxl367_temp_convert(struct sensor_value *val, int16_t value)
904904
#endif /*CONFIG_SENSOR_ASYNC_API*/
905905
{
906-
int64_t temp_data = (value + ADXL367_TEMP_OFFSET) * ADXL367_TEMP_SCALE;
906+
int64_t temp_data = (value - ADXL367_TEMP_25C);
907907

908-
val->val1 = temp_data / ADXL367_TEMP_SCALE_DIV;
909-
val->val2 = temp_data % ADXL367_TEMP_SCALE_DIV;
908+
val->val1 = temp_data / 54 /*temp sensitivity LSB/C*/ + 25/*bias test conditions*/;
909+
val->val2 = temp_data % 54 * 10000;
910910
}
911911

912912
static int adxl367_channel_get(const struct device *dev,
@@ -932,6 +932,7 @@ static int adxl367_channel_get(const struct device *dev,
932932
break;
933933
case SENSOR_CHAN_DIE_TEMP:
934934
adxl367_temp_convert(val, data->temp_val);
935+
break;
935936
default:
936937
return -ENOTSUP;
937938
}

0 commit comments

Comments
 (0)