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:
parent
5953a26dc6
commit
632d6b9416
2 changed files with 6 additions and 0 deletions
|
@ -320,6 +320,10 @@ static int bme680_read_compensation(const struct device *dev)
|
||||||
uint8_t buff[BME680_LEN_COEFF_ALL];
|
uint8_t buff[BME680_LEN_COEFF_ALL];
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
if (data->has_read_compensation) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
err = bme680_reg_read(dev, BME680_REG_COEFF1, buff, BME680_LEN_COEFF1);
|
err = bme680_reg_read(dev, BME680_REG_COEFF1, buff, BME680_LEN_COEFF1);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
return err;
|
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->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->range_sw_err = ((int8_t)(buff[41] & BME680_MSK_RANGE_SW_ERR)) / 16;
|
||||||
|
|
||||||
|
data->has_read_compensation = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -196,6 +196,7 @@ struct bme680_data {
|
||||||
uint8_t res_heat_range;
|
uint8_t res_heat_range;
|
||||||
int8_t res_heat_val;
|
int8_t res_heat_val;
|
||||||
int8_t range_sw_err;
|
int8_t range_sw_err;
|
||||||
|
bool has_read_compensation;
|
||||||
|
|
||||||
/* Calculated sensor values. */
|
/* Calculated sensor values. */
|
||||||
int32_t calc_temp;
|
int32_t calc_temp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue