]> www.fi.muni.cz Git - bike-lights.git/blob - tmr.c
gpio.c: gpio leds and other tools
[bike-lights.git] / tmr.c
1 #include <avr/io.h>
2 #include <avr/interrupt.h>
3
4 #include "lights.h"
5
6 volatile uint16_t jiffies;
7
8 void init_tmr()
9 {
10         TCCR0A = _BV(WGM00);
11         TCCR0B = _BV(CS02) | _BV(CS00); // CLK/1024 = 1 kHz
12         OCR0A = 10; // 100 Hz
13         TIMSK |= _BV(OCIE0A);
14
15         jiffies = 0;
16 }
17
18 ISR(TIMER0_COMPA_vect)
19 {
20         ++jiffies;
21
22         // patterns_next_tick();
23         timer_start_adcs();
24 }
25