]> www.fi.muni.cz Git - bike-lights.git/commitdiff
tmr.c: combine watchdog IRQ and watchdog reset
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Tue, 28 May 2013 20:29:06 +0000 (22:29 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Tue, 28 May 2013 20:29:06 +0000 (22:29 +0200)
Fortunately, WDT reset can be combined with WDT interrupt. The procedure
is to reenable WDIE each time, or the next WDT timeout will be reset.

firmware/tmr.c

index d1f1b2300bfe7e05233481948947fea330130b77..2e61db859d2570b23b00ecd6eb5a460a3138ae16 100644 (file)
@@ -8,7 +8,8 @@ volatile uint16_t jiffies;
 
 void init_tmr()
 {
-       WDTCR = _BV(WDIE) | _BV(WDP1); // interrupt mode, 64 ms
+       wdt_enable(WDTO_60MS);
+       WDTCR |= _BV(WDIE); // interrupt mode, 64 ms
 }
 
 void susp_tmr()
@@ -25,5 +26,7 @@ ISR(WDT_vect) {
 
        if ((jiffies & 0x7FF) == 0)
                ambient_log_min_max();
+
+       WDTCR |= _BV(WDIE); // avoid WDT reset next time
 }