]> www.fi.muni.cz Git - bike-lights.git/blobdiff - firmware/tmr.c
pwm.c: channels running - visible from the outside
[bike-lights.git] / firmware / tmr.c
index d1f1b2300bfe7e05233481948947fea330130b77..7a31f19e486e2ab5edd720d36f5ea88255e273e5 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()
@@ -21,9 +22,12 @@ ISR(WDT_vect) {
 
        timer_check_buttons();
        patterns_next_tick();
+       pwm_disable_if_not_needed();
        timer_start_slow_adcs();
 
        if ((jiffies & 0x7FF) == 0)
                ambient_log_min_max();
+
+       WDTCR |= _BV(WDIE); // avoid WDT reset next time
 }