4 #define BIT(n) (1<<(n))
6 static void timer_start(uint8_t num, uint32_t period)
21 else if(period<0x4000)
23 cs = BIT(CS01) | BIT(CS00);
26 else if(period<0x10000)
33 cs = BIT(CS02) | BIT(CS00);
49 else if(period<0x80000)
54 else if(period<0x400000)
56 cs = BIT(CS11) | BIT(CS10);
59 else if(period<0x1000000)
66 cs = BIT(CS12) | BIT(CS10);
72 TCCR1B = BIT(WGM12) | cs;
79 void timer_start_hz(uint8_t num, uint32_t freq_p, uint8_t freq_q)
81 timer_start(num, F_CPU*freq_q/freq_p);
84 void timer_start_us(uint8_t num, uint32_t us)
86 timer_start(num, F_CPU/1000000*us);
89 void timer_stop(uint8_t num)