From 6ca9bffe48df1d8bedc4c1d040011ecf26e50a90 Mon Sep 17 00:00:00 2001 From: Adrien Ricciardi Date: Sat, 1 Mar 2025 18:38:36 +0100 Subject: [PATCH] task_wdt: Kconfig: Allow to pause the hardware watchdog in sleep The hardware watchdog optionally used by the Task Watchdog can support being automatically paused when the system enters a sleep power state. Add a Kconfig flag to enable such feature. Signed-off-by: Adrien Ricciardi --- subsys/task_wdt/Kconfig | 10 ++++++++++ subsys/task_wdt/task_wdt.c | 6 +++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/subsys/task_wdt/Kconfig b/subsys/task_wdt/Kconfig index b78894a0b3b..92198a90e6e 100644 --- a/subsys/task_wdt/Kconfig +++ b/subsys/task_wdt/Kconfig @@ -58,6 +58,16 @@ config TASK_WDT_HW_FALLBACK_DELAY kernel timer. This is especially important if the hardware watchdog is clocked by an inaccurate low-speed RC oscillator. +config TASK_WDT_HW_FALLBACK_PAUSE_IN_SLEEP + bool "Pause the hardware watchdog in system sleep" + depends on TASK_WDT_HW_FALLBACK + help + Configure the hardware watchdog to automatically pause when the + system reaches a sleep power state. When the system is resumed, the + watchdog is also automatically resumed. + Note that this feature is supported only by a subset of hardware + watchdogs. + config TASK_WDT_SHELL bool "Task watchdog shell utilities" depends on SHELL diff --git a/subsys/task_wdt/task_wdt.c b/subsys/task_wdt/task_wdt.c index 361acc0e156..83e80ea91c2 100644 --- a/subsys/task_wdt/task_wdt.c +++ b/subsys/task_wdt/task_wdt.c @@ -179,7 +179,11 @@ int task_wdt_add(uint32_t reload_period, task_wdt_callback_t callback, if (!hw_wdt_started && hw_wdt_dev) { /* also start fallback hw wdt */ wdt_setup(hw_wdt_dev, - WDT_OPT_PAUSE_HALTED_BY_DBG); + WDT_OPT_PAUSE_HALTED_BY_DBG +#ifdef CONFIG_TASK_WDT_HW_FALLBACK_PAUSE_IN_SLEEP + | WDT_OPT_PAUSE_IN_SLEEP +#endif + ); hw_wdt_started = true; } #endif