diff --git a/lib/errors/errors_tests.c b/lib/errors/errors_tests.c index eb4f031d..51964c5d 100644 --- a/lib/errors/errors_tests.c +++ b/lib/errors/errors_tests.c @@ -100,6 +100,15 @@ trigger_z_oops(void) } #endif +#ifdef CONFIG_ORB_LIB_WATCHDOG +static bool +watchdog_feed_callback(void) +{ + /* Deliberately prevent feeding the watchdog */ + return false; +} +#endif + void fatal_errors_trigger(enum error_case_e type) { @@ -153,7 +162,7 @@ fatal_errors_trigger(enum error_case_e type) #endif #ifdef CONFIG_ORB_LIB_WATCHDOG case FATAL_WATCHDOG: - (void)watchdog_init(NULL); + (void)watchdog_init(watchdog_feed_callback); break; #endif diff --git a/lib/watchdog/watchdog.c b/lib/watchdog/watchdog.c index 40743dd2..64c2d132 100644 --- a/lib/watchdog/watchdog.c +++ b/lib/watchdog/watchdog.c @@ -29,8 +29,13 @@ static void watchdog_thread() { while (wdt_channel_id >= 0) { - if (watchdog_callback()) { + // Allow null callback + if (watchdog_callback == NULL) { wdt_feed(watchdog_dev, wdt_channel_id); + } else { + if (watchdog_callback() == true) { + wdt_feed(watchdog_dev, wdt_channel_id); + } } k_sleep(K_MSEC(WATCHDOG_RELOAD_MS)); } @@ -41,10 +46,6 @@ watchdog_thread() int watchdog_init(bool (*callback)(void)) { - if (callback == NULL) { - return RET_ERROR_INVALID_PARAM; - } - watchdog_callback = callback; int err_code;