From: Nathael Pajani Date: Mon, 16 Sep 2024 18:00:10 +0000 (+0200) Subject: Update watchdog feeding to prevent some deadlocks X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=3d5b078a581887c4a1ad4ef3a83cb32c6ec72106;p=soft%2Flpc122x%2Fscialys Update watchdog feeding to prevent some deadlocks --- diff --git a/v10/main.c b/v10/main.c index 8d5e66f..421d2fe 100644 --- a/v10/main.c +++ b/v10/main.c @@ -636,8 +636,32 @@ int main(void) status_led(green_only); while (1) { - /* Feed the dog */ - if ((solar_prod_value != 0) && (home_conso_value != 0) && (water_centi_degrees < ABSOLUTE_MAX_WATER_TEMP)) { + /* Feed the dog if sensor values are relevant */ + int allow_wd_feed = 1; + if ((solar_prod_value == 0) || (home_conso_value == 0)) { + allow_wd_feed = 0; + } + if ((water_centi_degrees < 0) || (water_centi_degrees > (ABSOLUTE_MAX_WATER_TEMP + 200))) { + allow_wd_feed = 0; + } + /* Blocked in overvoltage mode */ + if ((mode == mode_overvoltage) && (overvoltage == 0)) { + allow_wd_feed = 0; + } + /* Blocked in overtemperature mode */ + if (mode == mode_overtemp) { + if ((mosfet_temp_shutdown == 0) && (internal_temp_error_shutdown >= 0)) { + allow_wd_feed = 0; + } + } + /* Blocked in water critical temperature mode */ + if (mode == mode_water_critical) { + if (water_centi_degrees < ABSOLUTE_MAX_WATER_TEMP) { + allow_wd_feed = 0; + } + } + /* Otherwise, feed the dog */ + if (allow_wd_feed == 1) { watchdog_feed(); }