34 #include "sys/clock.h"
36 #include "rtimer-arch.h"
37 #include "dev/watchdog.h"
38 #include "isr_compat.h"
40 #define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND)
42 #define MAX_TICKS (~((clock_time_t)0) / 2)
44 static volatile unsigned long seconds;
46 static volatile clock_time_t count = 0;
48 static volatile uint16_t last_tar = 0;
50 ISR(TIMER1_A1, timera1)
52 ENERGEST_ON(ENERGEST_TYPE_IRQ);
60 while(TA1CTL & MC1 && TA1CCR1 - TA1R == 1);
71 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
72 #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
73 #error Change CLOCK_CONF_SECOND in contiki-conf.h.
75 if(count % CLOCK_CONF_SECOND == 0) {
79 }
while((TA1CCR1 - TA1R) > INTERVAL);
96 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
111 clock_set(clock_time_t clock, clock_time_t fclock)
114 TA1CCR1 = fclock + INTERVAL;
131 return (
unsigned short) (TA1R - t);
145 #if INTERVAL==32768/CLOCK_SECOND
146 TA1CTL = TASSEL0 | TACLR;
147 #elif INTERVAL==16384/CLOCK_SECOND
148 TA1CTL = TASSEL0 | TACLR | ID_1;
150 #error NEED TO UPDATE clock.c to match interval!
191 while(
clock_time() - start < (clock_time_t)i);
206 unsigned long t1, t2;
217 rtimer_clock_t t1, t2;