aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-misc.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-07-31 14:54:28 -0600
committerSelene ToyKeeper2019-07-31 14:54:28 -0600
commit51ea1b126516865b93d7cb8cabfc96910ff12ed0 (patch)
treea4896bb59a3a5cfa20c95cd8f5903a9b00e67d2b /spaghetti-monster/fsm-misc.c
parentmf01-mini: enable aux LED low mode (diff)
parentensure muggle thermal step-down can't overflow or wrap around (diff)
downloadanduril-51ea1b126516865b93d7cb8cabfc96910ff12ed0.tar.gz
anduril-51ea1b126516865b93d7cb8cabfc96910ff12ed0.tar.bz2
anduril-51ea1b126516865b93d7cb8cabfc96910ff12ed0.zip
merged from upstream fsm branch to get factory reset function and other updates
Diffstat (limited to 'spaghetti-monster/fsm-misc.c')
-rw-r--r--spaghetti-monster/fsm-misc.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c
index 9f953fa..eced482 100644
--- a/spaghetti-monster/fsm-misc.c
+++ b/spaghetti-monster/fsm-misc.c
@@ -154,4 +154,21 @@ uint8_t triangle_wave(uint8_t phase) {
}
#endif
+#ifdef USE_REBOOT
+void reboot() {
+ #if 1 // WDT method, safer but larger
+ cli();
+ WDTCR = 0xD8 | WDTO_15MS;
+ sei();
+ wdt_reset();
+ while (1) {}
+ #else // raw assembly method, doesn't reset registers or anything
+ __asm__ __volatile__ (
+ "cli" "\n\t"
+ "rjmp 0x00" "\n\t"
+ );
+ #endif
+}
+#endif
+
#endif