Skip to contentSkip to conversation

iio: chemical: bme680: Fix measurement wait duration calculation

PATCH Superseded Chris Spencer 2 participants 2 messages Feb 2 – Feb 3 IIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: chemical: bme680: Fix measurement wait duration calculation

This function refers to the Bosch BME680 API as the source of the calculation, but one of the constants does not match the Bosch implementation. This appears to be a simple transposition of two digits, resulting in a wait time that is too short. This can cause the following 'device measurement cycle incomplete' check to occasionally fail.

Fixes 4241665e6ea0 ("iio: chemical: bme680: Fix sensor data read operation")
---
 drivers/iio/chemical/bme680_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/bme680_core.c +1 -1
index 70f81c4a96ba..24e0b59e2fdf 100644
@@ -613,7 +613,7 @@ static int bme680_wait_for_eoc(struct bme680_data *data)
 	 * + heater duration
 	 */
 	int wait_eoc_us = ((data->oversampling_temp + data->oversampling_press +
-			   data->oversampling_humid) * 1936) + (477 * 4) +
+			   data->oversampling_humid) * 1963) + (477 * 4) +
 			   (477 * 5) + 1000 + (data->heater_dur * 1000);
 
 	fsleep(wait_eoc_us);
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Chris Spencer

This function refers to the Bosch BME680 API as the source of the calculation, but one of the constants does not match the Bosch implementation. This appears to be a simple transposition of two digits, resulting in a wait time that is too short. This can cause the following 'device measurement cycle incomplete' check to occasionally fail.

Hi Chris,

This is a good catch! I didn't have problems with measurements in the past but that is also because of the entropy of the sensor plus there were some series with "buggy" sensors that were behaving a bit differently. In any case, thanks for finding this!

Here is my tag, in case it is of any worth:

Cheers,
Vasilis

Quoted 23 lines
Fixes 4241665e6ea0 ("iio: chemical: bme680: Fix sensor data read operation")
---
 drivers/iio/chemical/bme680_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/chemical/bme680_core.c +1 -1
index 70f81c4a96ba..24e0b59e2fdf 100644
@@ -613,7 +613,7 @@ static int bme680_wait_for_eoc(struct bme680_data *data)
 	 * + heater duration
 	 */
 	int wait_eoc_us = ((data->oversampling_temp + data->oversampling_press +
-			   data->oversampling_humid) * 1936) + (477 * 4) +
+			   data->oversampling_humid) * 1963) + (477 * 4) +
 			   (477 * 5) + 1000 + (data->heater_dur * 1000);
 
 	fsleep(wait_eoc_us);
Signature · 1 line
2.43.0