00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <aversive/timers.h>
00023 #include <timer.h>
00024 #include <timer_intr.h>
00025 #include <timer_prescaler.h>
00026
00027 #include <timer_config.h>
00028
00030 void timer_init(void)
00031 {
00032 uint8_t flags;
00033
00034 IRQ_LOCK(flags);
00035 timer_intr_init();
00036
00037 #if defined TIMER0_ENABLED && defined TIMER0_AVAILABLE
00038 CS00_REG = __timer0_div_to_reg(TIMER0_PRESCALER_DIV) << CS00 ;
00039 TCNT0 = 0;
00040 #endif
00041 #if defined TIMER1_ENABLED && defined TIMER1_AVAILABLE
00042 CS10_REG = __timer1_div_to_reg(TIMER1_PRESCALER_DIV) << CS10 ;
00043 TCNT1 = 0;
00044 #endif
00045 #if defined TIMER2_ENABLED && defined TIMER2_AVAILABLE
00046 CS20_REG = __timer2_div_to_reg(TIMER2_PRESCALER_DIV) << CS20 ;
00047 TCNT2 = 0;
00048 #endif
00049 #if defined TIMER3_ENABLED && defined TIMER3_AVAILABLE
00050 CS30_REG = __timer3_div_to_reg(TIMER3_PRESCALER_DIV) << CS30 ;
00051 TCNT3 = 0;
00052 #endif
00053 #if defined TIMER4_ENABLED && defined TIMER4_AVAILABLE
00054 CS40_REG = __timer4_div_to_reg(TIMER4_PRESCALER_DIV) << CS40 ;
00055 TCNT4 = 0;
00056 #endif
00057 #if defined TIMER5_ENABLED && defined TIMER5_AVAILABLE
00058 CS50_REG = __timer5_div_to_reg(TIMER5_PRESCALER_DIV) << CS50 ;
00059 TCNT5 = 0;
00060 #endif
00061 IRQ_UNLOCK(flags);
00062 }