aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/stm32f4/Makefile2
-rw-r--r--src/stm32f4/watchdog.c25
2 files changed, 26 insertions, 1 deletions
diff --git a/src/stm32f4/Makefile b/src/stm32f4/Makefile
index 4263208f..6ed6a52b 100644
--- a/src/stm32f4/Makefile
+++ b/src/stm32f4/Makefile
@@ -11,7 +11,7 @@ CFLAGS += -Ilib/cmsis-core -Ilib/stm32f4/include
CFLAGS += -DSTM32F446xx
# Add source files
-src-y += stm32f4/main.c stm32f4/clock.c stm32f4/gpio.c
+src-y += stm32f4/main.c stm32f4/clock.c stm32f4/watchdog.c stm32f4/gpio.c
src-y += generic/crc16_ccitt.c generic/alloc.c
src-y += generic/armcm_irq.c generic/armcm_timer.c
src-y += ../lib/stm32f4/system_stm32f4xx.c
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);