patch "iio: chemical: bme680: Fix sensor data read operation" added to char-misc-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
iio: chemical: bme680: Fix sensor data read operation
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 4241665e6ea063a9c1d734de790121a71db763fc Mon Sep 17 00:00:00 2001
From: Vasileios Amoiridis <[email protected]>
Date: Thu, 6 Jun 2024 23:22:56 +0200
Subject: iio: chemical: bme680: Fix sensor data read operation
A read operation is happening as follows:
a) Set sensor to forced mode
b) Sensor measures values and update data registers and sleeps again
c) Read data registers
In the current implementation the read operation happens immediately after the sensor is set to forced mode so the sensor does not have the time to update properly the registers. This leads to the following 2 problems:
1) The first ever value which is read by the register is always wrong
2) Every read operation, puts the register into forced mode and reads the data that were calculated in the previous conversion.
This behaviour was tested in 2 ways:
1) The internal meas_status_0 register was read before and after every read operation in order to verify that the data were ready even before the register was set to forced mode and also to check that after the forced mode was set the new data were not yet ready.
2) Physically changing the temperature and measuring the temperature
This commit adds the waiting time in between the set of the forced mode and the read of the data. The function is taken from the Bosch BME68x Sensor API [1].
[1]: https://github.com/boschsensortec/BME68x_SensorAPI/blob/v4.4.8/bme68x.c#L490
--- drivers/iio/chemical/bme680.h | 2 ++ drivers/iio/chemical/bme680_core.c | 46 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
drivers/iio/chemical/bme680.h +2 -0
@@ -54,7 +54,9 @@#define BME680_NB_CONV_MASK GENMASK(3, 0)#define BME680_REG_MEAS_STAT_0 0x1D +#define BME680_NEW_DATA_BIT BIT(7)#define BME680_GAS_MEAS_BIT BIT(6) +#define BME680_MEAS_BIT BIT(5)/* Calibration Parameters */ #define BME680_T2_LSB_REG 0x8A
drivers/iio/chemical/bme680_core.c +46 -0
70 lines not on this page · raw message
Signature · 1 line
2.45.2