~toykeeper/flashlight-firmware/lume1

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/fsm-misc.c

  • Committer: Selene Scriven
  • Date: 2020-04-28 00:44:49 UTC
  • mfrom: (433.2.8 k1-12v)
  • Revision ID: bzr@toykeeper.net-20200428004449-ezsg5p6bf2eoj33d
merged Noctigon KR4 and K1-12V (XHP35) branches
(also includes some minor thermal updates to make it faster, more stable, and easier to tweak per host)
(and some code to prevent eeprom corruption while turning power chips on/off)
(and enables reboot function on tiny1634)
(and makes rainbow aux RGB mode speed configurable per host)
(and calibrates the original K1 a bit better)

Show diffs side-by-side

added added

removed removed

Lines of Context:
231
231
 
232
232
#ifdef USE_REBOOT
233
233
void reboot() {
234
 
    #if 1  // WDT method, safer but larger
 
234
    // put the WDT in hard reset mode, then trigger it
235
235
    cli();
236
 
    WDTCR = 0xD8 | WDTO_15MS;
 
236
    #if (ATTINY == 25) || (ATTINY == 45) || (ATTINY == 85)
 
237
        WDTCR = 0xD8 | WDTO_15MS;
 
238
    #elif (ATTINY == 1634)
 
239
        // allow protected configuration changes for next 4 clock cycles
 
240
        CCP = 0xD8;  // magic number
 
241
        // reset (WDIF + WDE), no WDIE, fastest (16ms) timing (0000)
 
242
        // (DS section 8.5.2 and table 8-4)
 
243
        WDTCSR = 0b10001000;
 
244
    #endif
237
245
    sei();
238
246
    wdt_reset();
239
247
    while (1) {}
240
 
    #else  // raw assembly method, doesn't reset registers or anything
241
 
    __asm__ __volatile__ (
242
 
            "cli" "\n\t"
243
 
            "rjmp 0x00" "\n\t"
244
 
            );
245
 
    #endif
246
248
}
247
249
#endif
248
250