Software watchdog for multiple threads

This commit is contained in:
Rhushabh
2020-06-23 15:59:31 +02:00
committed by Martin Jäger
parent 54bc5eaee8
commit 1dc5cdd7ef
5 changed files with 78 additions and 15 deletions
+7 -4
View File
@@ -74,6 +74,7 @@ void main(void)
// wait until all threads are spawned before activating the watchdog
k_sleep(K_MSEC(2500));
watchdog_start();
sw_watchdog_start();
while (1) {
charger.discharge_control(&bat_conf);
@@ -96,12 +97,13 @@ void main(void)
void control_thread()
{
uint32_t last_call = 0;
int wdt_channel = watchdog_register(200);
int wdt_channel = sw_watchdog_register(200);
while (1) {
bool charging = false;
watchdog_feed(wdt_channel);
sw_watchdog_feed(wdt_channel);
// convert ADC readings to meaningful measurement values
daq_update();
@@ -174,13 +176,14 @@ void control_thread()
void ext_mgr_thread()
{
uint32_t last_call = 0;
int wdt_channel = sw_watchdog_register(3000);
// quite long watchdog timeout as we might be dealing with slow communication (e.g. modems
// using AT commands via serial interface)
int wdt_channel = watchdog_register(3000);
while (1) {
watchdog_feed(wdt_channel);
sw_watchdog_feed(wdt_channel);
uint32_t now = k_uptime_get() / 1000;
ext_mgr.process_asap(); // approx. every millisecond