From a00657d2aef15e1f4bd17f96b2bad0f5e44781dc Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 15 Feb 2019 22:13:28 -0500 Subject: [PATCH] atsamd: Don't clear the watchdog if a clear is still in progress Clearing the watchdog while it is in progress can cause bus stalls on the SAMD21. It appears that clearing the watchdog on the SAMD51 can cause lockups of the watchdog device. Signed-off-by: Kevin O'Connor --- src/atsamd/samd51_watchdog.c | 3 ++- src/atsamd/watchdog.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/atsamd/samd51_watchdog.c b/src/atsamd/samd51_watchdog.c index 899b521f6..8c970dba9 100644 --- a/src/atsamd/samd51_watchdog.c +++ b/src/atsamd/samd51_watchdog.c @@ -10,7 +10,8 @@ void watchdog_reset(void) { - WDT->CLEAR.reg = 0xa5; + if (!(WDT->SYNCBUSY.reg & WDT_SYNCBUSY_CLEAR)) + WDT->CLEAR.reg = 0xa5; } DECL_TASK(watchdog_reset); diff --git a/src/atsamd/watchdog.c b/src/atsamd/watchdog.c index aacf8fb7f..9e11c279a 100644 --- a/src/atsamd/watchdog.c +++ b/src/atsamd/watchdog.c @@ -10,7 +10,8 @@ void watchdog_reset(void) { - WDT->CLEAR.reg = 0xa5; + if (!(WDT->STATUS.reg & WDT_STATUS_SYNCBUSY)) + WDT->CLEAR.reg = 0xa5; } DECL_TASK(watchdog_reset);