sensor: bme680: only read compensation params once

Only read the compensation parameters from the chip on first power up,
as they are static on the device.

Signed-off-by: Jordan Yates <jordan@embeint.com>
This commit is contained in:
Jordan Yates 2024-07-15 21:10:37 +10:00 committed by Carles Cufí
commit 632d6b9416
2 changed files with 6 additions and 0 deletions

View file

@ -320,6 +320,10 @@ static int bme680_read_compensation(const struct device *dev)
uint8_t buff[BME680_LEN_COEFF_ALL];
int err = 0;
if (data->has_read_compensation) {
return 0;
}
err = bme680_reg_read(dev, BME680_REG_COEFF1, buff, BME680_LEN_COEFF1);
if (err < 0) {
return err;
@ -373,6 +377,7 @@ static int bme680_read_compensation(const struct device *dev)
data->res_heat_range = ((buff[39] & BME680_MSK_RH_RANGE) >> 4);
data->range_sw_err = ((int8_t)(buff[41] & BME680_MSK_RANGE_SW_ERR)) / 16;
data->has_read_compensation = true;
return 0;
}

View file

@ -196,6 +196,7 @@ struct bme680_data {
uint8_t res_heat_range;
int8_t res_heat_val;
int8_t range_sw_err;
bool has_read_compensation;
/* Calculated sensor values. */
int32_t calc_temp;