Restructure SW watchdog and fix bug for >3 channels

The feed function considered max. number of channels and not actual number
of registered channels, which resulted in undefined behavior if not all
channels were used.

Also introducing more simple API to hide the software implementation.
This commit is contained in:
Martin Jäger
2020-07-23 17:34:41 +02:00
parent ed374e8e99
commit 3b486f3193
4 changed files with 66 additions and 67 deletions
+4 -5
View File
@@ -73,7 +73,6 @@ void main(void)
// wait until all threads are spawned before activating the watchdog
k_sleep(K_MSEC(2500));
watchdog_start();
sw_watchdog_start();
while (true) {
charger.discharge_control(&bat_conf);
@@ -96,13 +95,13 @@ void main(void)
void control_thread()
{
uint32_t last_call = 0;
int wdt_channel = sw_watchdog_register(200);
int wdt_channel = watchdog_register(200);
while (true) {
bool charging = false;
sw_watchdog_feed(wdt_channel);
watchdog_feed(wdt_channel);
// convert ADC readings to meaningful measurement values
daq_update();
@@ -175,14 +174,14 @@ void control_thread()
void ext_mgr_thread()
{
uint32_t last_call = 0;
int wdt_channel = sw_watchdog_register(3000);
int wdt_channel = watchdog_register(3000);
// quite long watchdog timeout as we might be dealing with slow communication (e.g. modems
// using AT commands via serial interface)
while (true) {
sw_watchdog_feed(wdt_channel);
watchdog_feed(wdt_channel);
uint32_t now = k_uptime_get() / 1000;
ext_mgr.process_asap(); // approx. every millisecond