BeRTOS
|
00001 00039 #include "cfg/cfg_timer.h" 00040 #include <cfg/macros.h> // BV() 00041 #include <cfg/debug.h> // BV() 00042 00043 #include <drv/vic_lpc2.h> 00044 #include <io/lpc23xx.h> 00045 #include "timer_lpc2.h" 00046 00048 #if (CONFIG_TIMER == TIMER0_COMPARE0) 00049 #define TIMER0_ID 4 00050 void timer_hw_init(void) 00051 { 00052 /* Power on timer0 */ 00053 PCONP |= BV(1); 00054 00055 /* Set TIMER0 clk to CPU_FREQ */ 00056 PCLKSEL0 &= ~0x0C; 00057 PCLKSEL0 |= 0x04; 00058 00059 /* reset prescaler counter */ 00060 T0PR = 0; 00061 00062 /* Set match register 0 */ 00063 T0MR0 = TIMER_HW_CNT; 00064 /* IRQ and reset counter on compare match 0 */ 00065 T0MCR &= ~0x03; 00066 T0MCR |= 0x03; 00067 /* Reset timer0 counter and prescaler */ 00068 T0TCR = 0x02; 00069 00070 vic_setVector(TIMER0_ID, timer_handler); 00071 vic_enable(TIMER0_ID); 00072 00073 /* Start timer0 */ 00074 T0TCR = 0x01; 00075 } 00076 00077 00078 #else 00079 #error Unimplemented value for CONFIG_TIMER 00080 #endif /* CONFIG_TIMER */ 00081