From 73824f0c4decd971f44936ef1ef8ed114bf8768d Mon Sep 17 00:00:00 2001 From: Chun-Chieh Li Date: Thu, 30 Apr 2020 11:32:31 +0800 Subject: [PATCH] Nuvoton: Fix watchdog reset failure on meeting Hard Fault Original implementation doesn't enable watchdog reset in pieces of cascaded timeout, except the last one. This is to guarantee re-configuration can be in time, but in interrupt disabled scenario e.g. Hard Fault, watchdog reset can cease to be effective. This change enables watchdog reset all the way of cascaded timeout. With trade-off, guaranteed watchdog reset function is more significant than re-configuration in time. --- targets/TARGET_NUVOTON/TARGET_M451/watchdog_api.c | 2 +- targets/TARGET_NUVOTON/TARGET_M480/watchdog_api.c | 2 +- targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c | 2 +- targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/TARGET_NUVOTON/TARGET_M451/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_M451/watchdog_api.c index cf54a405d2..513df812a4 100644 --- a/targets/TARGET_NUVOTON/TARGET_M451/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M451/watchdog_api.c @@ -188,7 +188,7 @@ static void watchdog_setup_cascade_timeout(void) WDT_CTL_WKEN_Msk | // Enable wake-up on timeout WDT_CTL_IF_Msk | // Clear interrupt flag WDT_CTL_RSTF_Msk | // Clear reset flag - (wdt_timeout_rmn_clk ? 0 : WDT_CTL_RSTEN_Msk) | // Enable reset on last cascaded timeout + WDT_CTL_RSTEN_Msk | // Enable reset always to address cascaded timeout failure in interrupt disabled scenario e.g. Hard Fault WDT_CTL_RSTCNT_Msk; // Reset watchdog timer SYS_LockReg(); diff --git a/targets/TARGET_NUVOTON/TARGET_M480/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_M480/watchdog_api.c index dfc52bba97..7989780903 100644 --- a/targets/TARGET_NUVOTON/TARGET_M480/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_M480/watchdog_api.c @@ -190,7 +190,7 @@ static void watchdog_setup_cascade_timeout(void) WDT_CTL_WKEN_Msk | // Enable wake-up on timeout WDT_CTL_IF_Msk | // Clear interrupt flag WDT_CTL_RSTF_Msk | // Clear reset flag - (wdt_timeout_rmn_clk ? 0 : WDT_CTL_RSTEN_Msk) | // Enable reset on last cascaded timeout + WDT_CTL_RSTEN_Msk | // Enable reset always to address cascaded timeout failure in interrupt disabled scenario e.g. Hard Fault WDT_CTL_RSTCNT_Msk; // Reset watchdog timer SYS_LockReg(); diff --git a/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c index 288e9367fb..5fde964827 100644 --- a/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NANO100/watchdog_api.c @@ -193,7 +193,7 @@ static void watchdog_setup_cascade_timeout(void) wdt_timeout_clk_toutsel | // Timeout interval WDT_CTL_WTE_Msk | // Enable watchdog timer WDT_CTL_WTWKE_Msk | // Enable wake-up on timeout - (wdt_timeout_rmn_clk ? 0 : WDT_CTL_WTRE_Msk) | // Enable reset on last cascaded timeout + WDT_CTL_WTRE_Msk | // Enable reset always to address cascaded timeout failure in interrupt disabled scenario e.g. Hard Fault WDT_CTL_WTR_Msk; // Reset watchdog timer SYS_LockReg(); diff --git a/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c b/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c index 01fb436b2e..5910e758fe 100644 --- a/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c +++ b/targets/TARGET_NUVOTON/TARGET_NUC472/watchdog_api.c @@ -187,7 +187,7 @@ static void watchdog_setup_cascade_timeout(void) WDT_CTL_WKEN_Msk | // Enable wake-up on timeout WDT_CTL_IF_Msk | // Clear interrupt flag WDT_CTL_RSTF_Msk | // Clear reset flag - (wdt_timeout_rmn_clk ? 0 : WDT_CTL_RSTEN_Msk) | // Enable reset on last cascaded timeout + WDT_CTL_RSTEN_Msk | // Enable reset always to address cascaded timeout failure in interrupt disabled scenario e.g. Hard Fault WDT_CTL_RSTCNT_Msk; // Reset watchdog timer SYS_LockReg();