Prevent deep sleep during BMP280 communication

This commit is contained in:
Thomas Kolb 2022-10-15 21:48:15 +02:00
parent 5c6497fb82
commit 1cbe0ce410

View file

@ -369,19 +369,21 @@ int main(void)
charge_control_update(timebase_ms, &meas_data); charge_control_update(timebase_ms, &meas_data);
// deep sleep control // deep sleep control
if(charge_control_is_idle()) { if(bmp280_state != BMP280_MEASURING) { // general blockers
if(!charge_control_was_idle) { if(charge_control_is_idle()) {
charge_control_was_idle = true; if(!charge_control_was_idle) {
charge_control_idle_since = timebase_ms; charge_control_was_idle = true;
} else { charge_control_idle_since = timebase_ms;
// charge control already idle } else {
if((timebase_ms - charge_control_idle_since) > FLASH_CONFIG_DEEPSLEEP_DELAY) { // charge control already idle
low_power_mode(FLASH_CONFIG_DEEPSLEEP_DURATION); if((timebase_ms - charge_control_idle_since) > FLASH_CONFIG_DEEPSLEEP_DELAY) {
charge_control_was_idle = false; low_power_mode(FLASH_CONFIG_DEEPSLEEP_DURATION);
charge_control_was_idle = false;
}
} }
} else {
charge_control_was_idle = false;
} }
} else {
charge_control_was_idle = false;
} }
} }