aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32f4/watchdog.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-07-26 08:36:11 -0400
committerKevin O'Connor <kevin@koconnor.net>2019-07-26 08:36:11 -0400
commit73709984b0eba1282473751427daa160e1a5c9f4 (patch)
treea88e901803ef7459c5023e946b895ea8481f68d4 /src/stm32f4/watchdog.c
parent899b6726fa0eada0253bccb72cab7c3b61274076 (diff)
downloadkutter-73709984b0eba1282473751427daa160e1a5c9f4.tar.gz
kutter-73709984b0eba1282473751427daa160e1a5c9f4.tar.xz
kutter-73709984b0eba1282473751427daa160e1a5c9f4.zip
stm32f4: Add support for watchdog
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32f4/watchdog.c')
-rw-r--r--src/stm32f4/watchdog.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/stm32f4/watchdog.c b/src/stm32f4/watchdog.c
new file mode 100644
index 00000000..1f642616
--- /dev/null
+++ b/src/stm32f4/watchdog.c
@@ -0,0 +1,25 @@
+// Watchdog handler on STM32F4
+//
+// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include "internal.h" // IWDG
+#include "sched.h" // DECL_TASK
+
+void
+watchdog_reset(void)
+{
+ IWDG->KR = 0xAAAA;
+}
+DECL_TASK(watchdog_reset);
+
+void
+watchdog_init(void)
+{
+ IWDG->KR = 0x5555;
+ IWDG->PR = 0;
+ IWDG->RLR = 0x0FFF; // 512ms timeout
+ IWDG->KR = 0xCCCC;
+}
+DECL_INIT(watchdog_init);