From d670f8bd6a5bdfdbe55f787528a101ec23193a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20J=C3=A4ger?= Date: Wed, 9 Feb 2022 16:31:55 +0100 Subject: [PATCH] DC/DC: Fix startup mode check The allowed mode of the DC/DC is fixed at compile-time (in setup.cpp). The start conditions have to match this mode. --- app/src/dcdc.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/src/dcdc.cpp b/app/src/dcdc.cpp index 416bac0..5694b58 100644 --- a/app/src/dcdc.cpp +++ b/app/src/dcdc.cpp @@ -152,9 +152,9 @@ int Dcdc::perturb_observe_controller() __weak DcdcOperationMode Dcdc::check_start_conditions() { - if (enable == false || hvb->voltage > hs_voltage_max - || // also critical for buck mode because of ringing - lvb->voltage > ls_voltage_max || lvb->voltage < ls_voltage_min + if (enable == false + || hvb->voltage > hs_voltage_max // also critical for buck mode because of ringing + || lvb->voltage > ls_voltage_max || lvb->voltage < ls_voltage_min || dev_stat.has_error(ERR_BAT_UNDERVOLTAGE | ERR_BAT_OVERVOLTAGE) || (int)uptime() < (off_timestamp + (int)restart_interval)) { @@ -226,8 +226,10 @@ __weak void Dcdc::control() int startup_mode = check_start_conditions(); - if (startup_mode != DCDC_MODE_OFF) { - + if ((startup_mode == DCDC_MODE_BUCK && mode == DCDC_MODE_BUCK) + || (startup_mode == DCDC_MODE_BOOST && mode == DCDC_MODE_BOOST) + || (startup_mode != DCDC_MODE_OFF && mode == DCDC_MODE_AUTO)) + { output_hvs_enable(); // startup allowed, but we need to wait until voltages settle