1 #include "rtimer-arch.h"
2 #include <AT91SAM7S64.h>
3 #include "rtimer-arch-interrupt.h"
8 #define PRINTF(...) printf(__VA_ARGS__)
13 static rtimer_clock_t offset;
16 rtimer_arch_init(
void)
19 RTIMER_ARCH_TIMER_BASE->TC_CMR =
20 (AT91C_TC_WAVE | AT91C_TC_WAVESEL_UP | AT91C_TC_CLKS_TIMER_DIV5_CLOCK);
21 RTIMER_ARCH_TIMER_BASE->TC_RA = 0xffff;
22 RTIMER_ARCH_TIMER_BASE->TC_IER = AT91C_TC_CPAS;
23 *AT91C_PMC_PCER = (1 << RTIMER_ARCH_TIMER_ID);
24 AT91C_AIC_SMR[RTIMER_ARCH_TIMER_ID] =
25 AT91C_AIC_SRCTYPE_INT_POSITIVE_EDGE | 6;
26 AT91C_AIC_SVR[RTIMER_ARCH_TIMER_ID] = (
unsigned long)rtimer_interrupt;
27 *AT91C_AIC_IECR = (1 << RTIMER_ARCH_TIMER_ID);
28 RTIMER_ARCH_TIMER_BASE->TC_CCR = AT91C_TC_SWTRG | AT91C_TC_CLKEN;
29 PRINTF(
"rtimer_arch_init: Done\n");
33 rtimer_arch_schedule(rtimer_clock_t t)
35 RTIMER_ARCH_TIMER_BASE->TC_RA = t + offset;
36 PRINTF(
"rtimer_arch_schedule: %d\n",t);
40 rtimer_arch_set(rtimer_clock_t t)
42 offset = t - RTIMER_ARCH_TIMER_BASE->TC_CV;
48 return RTIMER_ARCH_TIMER_BASE->TC_CV + offset;