3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
11 #define BIT(n) (1<<(n))
13 static void timer_start(uint8_t num, uint32_t period)
28 else if(period<0x4000)
30 cs = BIT(CS01) | BIT(CS00);
33 else if(period<0x10000)
40 cs = BIT(CS02) | BIT(CS00);
56 else if(period<0x80000)
61 else if(period<0x400000)
63 cs = BIT(CS11) | BIT(CS10);
66 else if(period<0x1000000)
73 cs = BIT(CS12) | BIT(CS10);
79 TCCR1B = BIT(WGM12) | cs;
86 void timer_start_hz(uint8_t num, uint32_t freq_p, uint8_t freq_q)
88 timer_start(num, F_CPU*freq_q/freq_p);
91 void timer_start_us(uint8_t num, uint32_t us)
93 timer_start(num, F_CPU/1000000*us);
96 void timer_stop(uint8_t num)