drivers: sensor: ccs811: bypass APP_START when not in boot mode
The CCS811 can be in either boot mode (after powerup) or application mode, and these modes have distinct register maps that share only some content. The register written to switch from boot mode to application mode is not available in application mode, so don't write to it in that case. Also respect the required timeout between APP_START and next I2C operation. Signed-off-by: Peter A. Bigot <pab@pabigot.com>
This commit is contained in:
parent
59d41669b9
commit
463bec1749
1 changed files with 7 additions and 0 deletions
|
@ -158,6 +158,12 @@ static int switch_to_app_mode(struct device *i2c)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Check if already in application mode */
|
||||
if (status & CCS811_STATUS_FW_MODE) {
|
||||
LOG_DBG("CCS811 Already in application mode");
|
||||
return 0;
|
||||
}
|
||||
|
||||
buf = CCS811_REG_APP_START;
|
||||
/* Set the device to application mode */
|
||||
if (i2c_write(i2c, &buf, 1, DT_INST_0_AMS_CCS811_BASE_ADDRESS) < 0) {
|
||||
|
@ -165,6 +171,7 @@ static int switch_to_app_mode(struct device *i2c)
|
|||
return -EIO;
|
||||
}
|
||||
|
||||
k_sleep(1); /* t_APP_START */
|
||||
if (i2c_reg_read_byte(i2c, DT_INST_0_AMS_CCS811_BASE_ADDRESS,
|
||||
CCS811_REG_STATUS, &status) < 0) {
|
||||
LOG_ERR("Failed to read Status register");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue