From 7134924ce13956770ff07ae5da978b6f2061b00e Mon Sep 17 00:00:00 2001 From: Selene ToyKeeper Date: Fri, 20 Mar 2020 00:07:34 -0600 Subject: added reboot() support for tiny1634 --- spaghetti-monster/fsm-misc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/spaghetti-monster/fsm-misc.c b/spaghetti-monster/fsm-misc.c index 152f047..82be745 100644 --- a/spaghetti-monster/fsm-misc.c +++ b/spaghetti-monster/fsm-misc.c @@ -231,18 +231,20 @@ uint8_t triangle_wave(uint8_t phase) { #ifdef USE_REBOOT void reboot() { - #if 1 // WDT method, safer but larger + // put the WDT in hard reset mode, then trigger it cli(); - WDTCR = 0xD8 | WDTO_15MS; + #if (ATTINY == 25) || (ATTINY == 45) || (ATTINY == 85) + WDTCR = 0xD8 | WDTO_15MS; + #elif (ATTINY == 1634) + // allow protected configuration changes for next 4 clock cycles + CCP = 0xD8; // magic number + // reset (WDIF + WDE), no WDIE, fastest (16ms) timing (0000) + // (DS section 8.5.2 and table 8-4) + WDTCSR = 0b10001000; + #endif 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 -- cgit v1.2.3