Skip to content

include: zephyr: task_wdt: Easily disable Task Watchdog #93672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion subsys/task_wdt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions subsys/task_wdt/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions subsys/task_wdt/task_wdt_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2025 BayLibre SAS
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/logging/log.h>
#include <zephyr/task_wdt/task_wdt.h>

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)
{
}