aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-02-15 22:13:28 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-02-15 22:13:28 -0500
commita00657d2aef15e1f4bd17f96b2bad0f5e44781dc (patch)
tree395bf961793c27433042ac462dbccefb8d7c1a06
parent00e0a70a94a208c73962c1f762195b2818ae98b2 (diff)
downloadkutter-a00657d2aef15e1f4bd17f96b2bad0f5e44781dc.tar.gz
kutter-a00657d2aef15e1f4bd17f96b2bad0f5e44781dc.tar.xz
kutter-a00657d2aef15e1f4bd17f96b2bad0f5e44781dc.zip
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 <kevin@koconnor.net>
-rw-r--r--src/atsamd/samd51_watchdog.c3
-rw-r--r--src/atsamd/watchdog.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/atsamd/samd51_watchdog.c b/src/atsamd/samd51_watchdog.c
index 899b521f..8c970dba 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 aacf8fb7..9e11c279 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);