Skip to content

Commit 8fd797e

Browse files
RICCIARDI-Adriennashif
authored andcommitted
task_wdt: Add dummy implementation
The introduced CONFIG_TASK_WDT_DUMMY Kconfig symbol allows to easily disable the Task Watchdog by providing a dummy implementation. The Task Watchdog can fire when a board is halted on a breakpoint during a debugging session, so this new feature can turn useful in this case. Signed-off-by: Adrien Ricciardi <[email protected]>
1 parent 5539a22 commit 8fd797e

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

subsys/task_wdt/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
zephyr_sources_ifdef(CONFIG_TASK_WDT task_wdt.c)
3+
if (CONFIG_TASK_WDT_DUMMY)
4+
zephyr_sources(task_wdt_dummy.c)
5+
message(WARNING "Dummy Task Watchdog implementation is enabled.")
6+
else()
7+
zephyr_sources_ifdef(CONFIG_TASK_WDT task_wdt.c)
8+
endif()
9+
410
zephyr_sources_ifdef(CONFIG_TASK_WDT_SHELL task_wdt_shell.c)

subsys/task_wdt/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ menuconfig TASK_WDT
1313
per thread, even if the hardware supports only a single watchdog.
1414

1515
if TASK_WDT
16+
17+
config TASK_WDT_DUMMY
18+
bool "Dummy implementation for testing"
19+
help
20+
Allows the code to use all Task Watchdog APIs, but does nothing.
21+
This can be useful to temporarily disable the Task Watchdog while
22+
debugging.
23+
1624
config TASK_WDT_CHANNELS
1725
int "Maximum number of task watchdog channels"
1826
default 5

subsys/task_wdt/task_wdt_dummy.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2025 BayLibre SAS
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <zephyr/logging/log.h>
7+
#include <zephyr/task_wdt/task_wdt.h>
8+
9+
LOG_MODULE_REGISTER(task_wdt);
10+
11+
int task_wdt_init(const struct device *hw_wdt)
12+
{
13+
ARG_UNUSED(hw_wdt);
14+
15+
LOG_WRN("Dummy Task Watchdog implementation enabled.");
16+
17+
return 0;
18+
}
19+
20+
int task_wdt_add(uint32_t reload_period, task_wdt_callback_t callback,
21+
void *user_data)
22+
{
23+
ARG_UNUSED(reload_period);
24+
ARG_UNUSED(callback);
25+
ARG_UNUSED(user_data);
26+
27+
return 0;
28+
}
29+
30+
int task_wdt_delete(int channel_id)
31+
{
32+
ARG_UNUSED(channel_id);
33+
34+
return 0;
35+
}
36+
37+
int task_wdt_feed(int channel_id)
38+
{
39+
ARG_UNUSED(channel_id);
40+
41+
return 0;
42+
}
43+
44+
void task_wdt_suspend(void)
45+
{
46+
}
47+
48+
void task_wdt_resume(void)
49+
{
50+
}

0 commit comments

Comments
 (0)