aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-02-15 22:10:41 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-02-15 22:10:41 -0500
commit00e0a70a94a208c73962c1f762195b2818ae98b2 (patch)
tree0a88ee431a02762d78cb9d711417ede22c4fd35b /src
parent021264a6f50ae7e78875da1b8a61270aef0b2913 (diff)
downloadkutter-00e0a70a94a208c73962c1f762195b2818ae98b2.tar.gz
kutter-00e0a70a94a208c73962c1f762195b2818ae98b2.tar.xz
kutter-00e0a70a94a208c73962c1f762195b2818ae98b2.zip
atsamd: Move watchdog code to its own files
Move the watchdog code from main.c to watchdog.c and samd51_watchdog.c. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/atsamd/Makefile2
-rw-r--r--src/atsamd/main.c32
-rw-r--r--src/atsamd/samd51_watchdog.c23
-rw-r--r--src/atsamd/watchdog.c23
4 files changed, 49 insertions, 31 deletions
diff --git a/src/atsamd/Makefile b/src/atsamd/Makefile
index 79a664df..06be77c2 100644
--- a/src/atsamd/Makefile
+++ b/src/atsamd/Makefile
@@ -28,8 +28,10 @@ src-$(CONFIG_HAVE_GPIO_ADC) += atsamd/adc.c
src-$(CONFIG_HAVE_GPIO_I2C) += atsamd/i2c.c
src-$(CONFIG_HAVE_GPIO_SPI) += atsamd/spi.c
src-$(CONFIG_HAVE_GPIO_HARD_PWM) += atsamd/hard_pwm.c
+src-$(CONFIG_MACH_SAMD21) += atsamd/watchdog.c
src-$(CONFIG_MACH_SAMD21) += atsamd/clock.c atsamd/timer.c generic/timer_irq.c
src-$(CONFIG_MACH_SAMD21) += ../lib/samd21/samd21a/gcc/gcc/startup_samd21.c
+src-$(CONFIG_MACH_SAMD51) += atsamd/samd51_watchdog.c
src-$(CONFIG_MACH_SAMD51) += atsamd/samd51_clock.c generic/armcm_timer.c
src-$(CONFIG_MACH_SAMD51) += ../lib/samd51/samd51a/gcc/gcc/startup_samd51.c
diff --git a/src/atsamd/main.c b/src/atsamd/main.c
index 5cd85d44..9233662f 100644
--- a/src/atsamd/main.c
+++ b/src/atsamd/main.c
@@ -5,41 +5,11 @@
// This file may be distributed under the terms of the GNU GPLv3 license.
#include "command.h" // DECL_CONSTANT
-#include "internal.h" // WDT
+#include "internal.h" // NVIC_SystemReset
#include "sched.h" // sched_main
DECL_CONSTANT(MCU, CONFIG_MCU);
-
-/****************************************************************
- * watchdog handler
- ****************************************************************/
-
-void
-watchdog_reset(void)
-{
- WDT->CLEAR.reg = 0xa5;
-}
-DECL_TASK(watchdog_reset);
-
-void
-watchdog_init(void)
-{
-#if CONFIG_MACH_SAMD21
- WDT->CONFIG.reg = WDT_CONFIG_PER_16K; // 500ms timeout
- WDT->CTRL.reg = WDT_CTRL_ENABLE;
-#elif CONFIG_MACH_SAMD51
- WDT->CONFIG.reg = WDT_CONFIG_PER(6); // 500ms timeout
- WDT->CTRLA.reg = WDT_CTRLA_ENABLE;
-#endif
-}
-DECL_INIT(watchdog_init);
-
-
-/****************************************************************
- * misc functions
- ****************************************************************/
-
void
command_reset(uint32_t *args)
{
diff --git a/src/atsamd/samd51_watchdog.c b/src/atsamd/samd51_watchdog.c
new file mode 100644
index 00000000..899b521f
--- /dev/null
+++ b/src/atsamd/samd51_watchdog.c
@@ -0,0 +1,23 @@
+// Watchdog handler on SAMD21 boards
+//
+// Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include "internal.h" // WDT
+#include "sched.h" // DECL_TASK
+
+void
+watchdog_reset(void)
+{
+ WDT->CLEAR.reg = 0xa5;
+}
+DECL_TASK(watchdog_reset);
+
+void
+watchdog_init(void)
+{
+ WDT->CONFIG.reg = WDT_CONFIG_PER(6); // 500ms timeout
+ WDT->CTRLA.reg = WDT_CTRLA_ENABLE;
+}
+DECL_INIT(watchdog_init);
diff --git a/src/atsamd/watchdog.c b/src/atsamd/watchdog.c
new file mode 100644
index 00000000..aacf8fb7
--- /dev/null
+++ b/src/atsamd/watchdog.c
@@ -0,0 +1,23 @@
+// Watchdog handler on SAMD21 boards
+//
+// Copyright (C) 2018-2019 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include "internal.h" // WDT
+#include "sched.h" // DECL_TASK
+
+void
+watchdog_reset(void)
+{
+ WDT->CLEAR.reg = 0xa5;
+}
+DECL_TASK(watchdog_reset);
+
+void
+watchdog_init(void)
+{
+ WDT->CONFIG.reg = WDT_CONFIG_PER_16K; // 500ms timeout
+ WDT->CTRL.reg = WDT_CTRL_ENABLE;
+}
+DECL_INIT(watchdog_init);