drivers: bme280: do soft reset after boot
To ensure that we have the same behaviour with a power cycle and by pressing the reset button, we can perform soft reset in `bme280_chip_init()`. Signed-off-by: Efrain Calderon <efrain.calderon@aquarobur.com>
This commit is contained in:
parent
86e656b640
commit
c009450d44
2 changed files with 10 additions and 0 deletions
|
@ -353,6 +353,12 @@ static int bme280_chip_init(const struct device *dev)
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = bme280_reg_write(dev, BME280_REG_RESET, BME280_CMD_SOFT_RESET);
|
||||||
|
if (err < 0) {
|
||||||
|
LOG_DBG("Soft-reset failed: %d", err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
err = bme280_read_compensation(dev);
|
err = bme280_read_compensation(dev);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
return err;
|
return err;
|
||||||
|
@ -380,6 +386,8 @@ static int bme280_chip_init(const struct device *dev)
|
||||||
LOG_DBG("CONFIG write failed: %d", err);
|
LOG_DBG("CONFIG write failed: %d", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
/* Wait for the sensor to be ready */
|
||||||
|
k_sleep(K_MSEC(1));
|
||||||
|
|
||||||
#ifdef CONFIG_PM_DEVICE
|
#ifdef CONFIG_PM_DEVICE
|
||||||
/* Set power state to ACTIVE */
|
/* Set power state to ACTIVE */
|
||||||
|
|
|
@ -63,6 +63,7 @@ extern const struct bme280_bus_io bme280_bus_io_i2c;
|
||||||
#define BME280_REG_CTRL_MEAS 0xF4
|
#define BME280_REG_CTRL_MEAS 0xF4
|
||||||
#define BME280_REG_CTRL_HUM 0xF2
|
#define BME280_REG_CTRL_HUM 0xF2
|
||||||
#define BME280_REG_STATUS 0xF3
|
#define BME280_REG_STATUS 0xF3
|
||||||
|
#define BME280_REG_RESET 0xE0
|
||||||
|
|
||||||
#define BMP280_CHIP_ID_SAMPLE_1 0x56
|
#define BMP280_CHIP_ID_SAMPLE_1 0x56
|
||||||
#define BMP280_CHIP_ID_SAMPLE_2 0x57
|
#define BMP280_CHIP_ID_SAMPLE_2 0x57
|
||||||
|
@ -72,6 +73,7 @@ extern const struct bme280_bus_io bme280_bus_io_i2c;
|
||||||
#define BME280_MODE_FORCED 0x01
|
#define BME280_MODE_FORCED 0x01
|
||||||
#define BME280_MODE_NORMAL 0x03
|
#define BME280_MODE_NORMAL 0x03
|
||||||
#define BME280_SPI_3W_DISABLE 0x00
|
#define BME280_SPI_3W_DISABLE 0x00
|
||||||
|
#define BME280_CMD_SOFT_RESET 0xB6
|
||||||
|
|
||||||
#if defined CONFIG_BME280_MODE_NORMAL
|
#if defined CONFIG_BME280_MODE_NORMAL
|
||||||
#define BME280_MODE BME280_MODE_NORMAL
|
#define BME280_MODE BME280_MODE_NORMAL
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue