]> www.fi.muni.cz Git - bike-lights.git/blob - firmware/tmr.c
d1f1b2300bfe7e05233481948947fea330130b77
[bike-lights.git] / firmware / tmr.c
1 #include <avr/io.h>
2 #include <avr/interrupt.h>
3 #include <avr/wdt.h>
4
5 #include "lights.h"
6
7 volatile uint16_t jiffies;
8
9 void init_tmr()
10 {
11         WDTCR = _BV(WDIE) | _BV(WDP1); // interrupt mode, 64 ms
12 }
13
14 void susp_tmr()
15 {
16         wdt_disable();
17 }
18
19 ISR(WDT_vect) {
20         ++jiffies;
21
22         timer_check_buttons();
23         patterns_next_tick();
24         timer_start_slow_adcs();
25
26         if ((jiffies & 0x7FF) == 0)
27                 ambient_log_min_max();
28 }
29