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;
#define NULL
The null pointer.
Default definitions of C compiler quirk work-arounds.
void clock_init(void)
Initialize the clock library.
CCIF clock_time_t clock_time(void)
Get the current clock time.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
CCIF unsigned long clock_seconds(void)
Get the current value of the platform seconds.
int etimer_pending(void)
Check if there are any non-expired event timers.
void clock_delay(unsigned int delay)
Obsolete delay function but we implement it here since some code still uses it.
#define CLOCK_SECOND
A second, measured in system clock time.