/** * \file * * * \author Francesco Sacchi * * \brief Low-level timer module for Atmel AT91 (inplementation). */ #include "timer_at91.h" #include #include "sysirq_at91.h" #include // BV() #include #include #include /** HW dependent timer initialization */ #if (CONFIG_TIMER == TIMER_ON_PIT) ISR_PROTO_CONTEXT_SWITCH(timer_handler); void timer_hw_init(void) { sysirq_init(); cpu_flags_t flags; MOD_CHECK(sysirq); IRQ_SAVE_DISABLE(flags); PIT_MR = TIMER_HW_CNT; /* Register system interrupt handler. */ sysirq_setHandler(SYSIRQ_PIT, timer_handler); /* Enable interval timer and interval timer interrupts */ PIT_MR |= BV(PITEN); sysirq_setEnable(SYSIRQ_PIT, true); /* Reset counters, this is needed to start timer and interrupt flags */ uint32_t dummy = PIVR; (void) dummy; IRQ_RESTORE(flags); } #else #error Unimplemented value for CONFIG_TIMER #endif /* CONFIG_TIMER */