at query is not NULL when receiving xmit status
[protos/xbee-avr.git] / timer_init.c
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2006)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: timer_init.c,v 1.1.2.4 2009-01-30 20:18:36 zer0 Exp $
19  *
20  */
21
22 #include <aversive.h>
23 #include <aversive/parts.h>
24 #include <aversive/timers.h>
25 #include <timer.h>
26 #include <timer_intr.h>
27 #include <timer_prescaler.h>
28
29 #include <timer_config.h>
30
31 /** Init of all timers with static configutaion (see timer_config.h) */
32 void timer_init(void)
33 {
34         uint8_t flags;
35         
36         IRQ_LOCK(flags);
37         timer_intr_init();
38
39 #if defined TIMER0_ENABLED && defined TIMER0_AVAILABLE
40         CS00_REG = __timer0_div_to_reg(TIMER0_PRESCALER_DIV) << CS00 ;
41         TCNT0 = 0;
42 #endif
43 #if defined TIMER1_ENABLED && defined TIMER1_AVAILABLE
44         CS10_REG = __timer1_div_to_reg(TIMER1_PRESCALER_DIV) << CS10 ;
45         TCNT1 = 0;
46 #endif
47 #if defined TIMER2_ENABLED && defined TIMER2_AVAILABLE
48         CS20_REG = __timer2_div_to_reg(TIMER2_PRESCALER_DIV) << CS20 ;
49         TCNT2 = 0;
50 #endif
51 #if defined TIMER3_ENABLED && defined TIMER3_AVAILABLE
52         CS30_REG = __timer3_div_to_reg(TIMER3_PRESCALER_DIV) << CS30 ;
53         TCNT3 = 0;
54 #endif
55 #if defined TIMER4_ENABLED && defined TIMER4_AVAILABLE
56         CS40_REG = __timer4_div_to_reg(TIMER4_PRESCALER_DIV) << CS40 ;
57         TCNT4 = 0;
58 #endif
59 #if defined TIMER5_ENABLED && defined TIMER5_AVAILABLE
60         CS50_REG = __timer5_div_to_reg(TIMER5_PRESCALER_DIV) << CS50 ;
61         TCNT5 = 0;
62 #endif
63         IRQ_UNLOCK(flags);
64 }