STMicroelectronics / STMems_Linux_IIO_drivers

DISCONTINUED (October 2022): the maintenance for this repository has been discontinued. Please refer to https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio for the up-to-date drivers repository. This repository contains Linux Kernel (v3.10, v3.14, v3.18, v4.9, v4.14, v4.19) including STMicroelectronics MEMS IIO sensor support
Other
75 stars 42 forks source link

ism330dhcx temperature in wrong format #10

Open Paplewski opened 3 years ago

Paplewski commented 3 years ago

According to the IIO ABI documentation the temperature output units are standardized:

Units after application of scale and offset are milli degrees Celsius.

Applying the following patch solves the problem.

Subject: [PATCH 1/1] Fix temperature scaling issue

According to the iio ABI documentation the units of the temperature
is mili degrees Celsius.
---
 drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c b/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c
index 07e8e2d77f5f..9939c65a1e51 100644
--- a/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c
+++ b/drivers/iio/imu/st_ism330dhcx/st_ism330dhcx_core.c
@@ -781,7 +781,7 @@ static int st_ism330dhcx_read_raw(struct iio_dev *iio_dev,
  case IIO_CHAN_INFO_SCALE:
  switch (ch->type) {
  case IIO_TEMP:
- *val = 1;
+ *val = 1000;
  *val2 = ST_ISM330DHCX_TEMP_GAIN;
  ret = IIO_VAL_FRACTIONAL;
  break;

Edit: Currently the units are degrees C

mariotesi commented 1 year ago

pls consider update driver are moved on new github repository: https://github.com/STMicroelectronics/st-mems-android-linux-drivers-iio)