Skip to content

Commit 0a6f769

Browse files
authored
Merge pull request #14555 from OpenNuvoton/nuvoton_wdt_stop-n-kick
Nuvoton: Fix hal_watchdog_kick() with WDT stopped
2 parents 1f57702 + d489c92 commit 0a6f769

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

targets/TARGET_NUVOTON/TARGET_M451/watchdog_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
125125

126126
void hal_watchdog_kick(void)
127127
{
128+
/* If a watchdog is not running, this function does nothing */
129+
if (!(WDT->CTL & WDT_CTL_WDTEN_Msk)) {
130+
return;
131+
}
132+
128133
wdt_timeout_rmn_clk = NU_MS2WDTCLK(wdt_timeout_reload_ms);
129134
watchdog_setup_cascade_timeout();
130135
}

targets/TARGET_NUVOTON/TARGET_M480/watchdog_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
126126

127127
void hal_watchdog_kick(void)
128128
{
129+
/* If a watchdog is not running, this function does nothing */
130+
if (!(WDT->CTL & WDT_CTL_WDTEN_Msk)) {
131+
return;
132+
}
133+
129134
wdt_timeout_rmn_clk = NU_MS2WDTCLK(wdt_timeout_reload_ms);
130135
watchdog_setup_cascade_timeout();
131136
}

targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
123123

124124
void hal_watchdog_kick(void)
125125
{
126+
/* If a watchdog is not running, this function does nothing */
127+
if (!(WDT->CTL & WDT_CTL_WTE_Msk)) {
128+
return;
129+
}
130+
126131
wdt_timeout_rmn_clk = NU_MS2WDTCLK(wdt_timeout_reload_ms);
127132
watchdog_setup_cascade_timeout();
128133
}

targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
124124

125125
void hal_watchdog_kick(void)
126126
{
127+
/* If a watchdog is not running, this function does nothing */
128+
if (!(WDT->CTL & WDT_CTL_WDTEN_Msk)) {
129+
return;
130+
}
131+
127132
wdt_timeout_rmn_clk = NU_MS2WDTCLK(wdt_timeout_reload_ms);
128133
watchdog_setup_cascade_timeout();
129134
}

0 commit comments

Comments
 (0)