diff --git a/subsys/task_wdt/CMakeLists.txt b/subsys/task_wdt/CMakeLists.txt index 6f94461d203f0..827a6f2bf68c7 100644 --- a/subsys/task_wdt/CMakeLists.txt +++ b/subsys/task_wdt/CMakeLists.txt @@ -1,4 +1,12 @@ # SPDX-License-Identifier: Apache-2.0 -zephyr_sources_ifdef(CONFIG_TASK_WDT task_wdt.c) +if (CONFIG_TASK_WDT_TEST) + zephyr_sources(task_wdt_test.c) + message(WARNING " + Warning: the test Task Watchdog is enabled and provides only a dummy + implementation.") +else() + zephyr_sources_ifdef(CONFIG_TASK_WDT task_wdt.c) +endif() + zephyr_sources_ifdef(CONFIG_TASK_WDT_SHELL task_wdt_shell.c) diff --git a/subsys/task_wdt/Kconfig b/subsys/task_wdt/Kconfig index 92198a90e6e74..3584716518ca8 100644 --- a/subsys/task_wdt/Kconfig +++ b/subsys/task_wdt/Kconfig @@ -13,6 +13,14 @@ menuconfig TASK_WDT per thread, even if the hardware supports only a single watchdog. if TASK_WDT + +config TASK_WDT_TEST + bool "Dummy implementation for tests" + help + Allow the code to use all Task Watchdog APIs but does nothing. + This can be useful to temporarily disable the Task Watchdog while + debugging. + config TASK_WDT_CHANNELS int "Maximum number of task watchdog channels" default 5 diff --git a/subsys/task_wdt/task_wdt_test.c b/subsys/task_wdt/task_wdt_test.c new file mode 100644 index 0000000000000..065331e921b97 --- /dev/null +++ b/subsys/task_wdt/task_wdt_test.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 BayLibre SAS + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include + +LOG_MODULE_REGISTER(task_wdt); + +int task_wdt_init(const struct device *hw_wdt) +{ + ARG_UNUSED(hw_wdt); + + LOG_INF("The test Task Watchdog is enabled and provides only a dummy implementation."); + + return 0; +} + +int task_wdt_add(uint32_t reload_period, task_wdt_callback_t callback, + void *user_data) +{ + ARG_UNUSED(reload_period); + ARG_UNUSED(callback); + ARG_UNUSED(user_data); + + return 0; +} + +int task_wdt_delete(int channel_id) +{ + ARG_UNUSED(channel_id); + + return 0; +} + +int task_wdt_feed(int channel_id) +{ + ARG_UNUSED(channel_id); + + return 0; +} + +void task_wdt_suspend(void) +{ +} + +void task_wdt_resume(void) +{ +}