4 #include <debug-uart.h>
6 #include <AT91SAM7S64.h>
7 #include <sys-interrupt.h>
9 #define PIV ((MCK/CLOCK_SECOND/16)-1)
11 static volatile clock_time_t current_clock = 0;
12 static volatile unsigned long current_seconds = 0;
16 static int pit_handler_func()
18 if (!(*AT91C_PITC_PISR & AT91C_PITC_PITS))
return 0;
26 if (--second_countdown == 0) {
30 (void)*AT91C_PITC_PIVR;
34 static SystemInterruptHandler pit_handler = {
NULL, pit_handler_func};
39 sys_interrupt_append_handler(&pit_handler);
40 *AT91C_PITC_PIMR = (AT91C_PITC_PITIEN |
43 sys_interrupt_enable();
55 #define SPIN_COUNT (((MCK*SPIN_TIME/1000000)-5)/4)
57 #ifndef __MAKING_DEPS__
63 asm volatile(
"1: mov r1,%2\n2:\tsub r1,#1\n\tbne 2b\n\tsub %0,#1\n\tbne 1b\n":
"=l"(t):
"0"(t),
"l"(SPIN_COUNT));
65 #error Must be compiled in thumb mode
72 return current_seconds;