Skip to content

Commit 632d6b9

Browse files
JordanYatescarlescufi
authored andcommitted
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 <[email protected]>
1 parent 5953a26 commit 632d6b9

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

drivers/sensor/bosch/bme680/bme680.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ static int bme680_read_compensation(const struct device *dev)
320320
uint8_t buff[BME680_LEN_COEFF_ALL];
321321
int err = 0;
322322

323+
if (data->has_read_compensation) {
324+
return 0;
325+
}
326+
323327
err = bme680_reg_read(dev, BME680_REG_COEFF1, buff, BME680_LEN_COEFF1);
324328
if (err < 0) {
325329
return err;
@@ -373,6 +377,7 @@ static int bme680_read_compensation(const struct device *dev)
373377
data->res_heat_range = ((buff[39] & BME680_MSK_RH_RANGE) >> 4);
374378
data->range_sw_err = ((int8_t)(buff[41] & BME680_MSK_RANGE_SW_ERR)) / 16;
375379

380+
data->has_read_compensation = true;
376381
return 0;
377382
}
378383

drivers/sensor/bosch/bme680/bme680.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ struct bme680_data {
196196
uint8_t res_heat_range;
197197
int8_t res_heat_val;
198198
int8_t range_sw_err;
199+
bool has_read_compensation;
199200

200201
/* Calculated sensor values. */
201202
int32_t calc_temp;

0 commit comments

Comments
 (0)