37 #include "sys/clock.h"
39 #include "rtimer-arch.h"
42 #define INTERVAL (RTIMER_ARCH_SECOND / CLOCK_SECOND)
44 #define MAX_TICKS (~((clock_time_t)0) / 2)
46 static volatile unsigned long seconds;
48 static volatile clock_time_t count = 0;
50 static volatile uint16_t last_tar = 0;
52 #ifdef __IAR_SYSTEMS_ICC__
53 #pragma vector=TIMERA1_VECTOR
56 interrupt(TIMERA1_VECTOR)
59 ENERGEST_ON(ENERGEST_TYPE_IRQ);
67 while(TACTL & MC1 && TACCR1 - TAR == 1);
78 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
79 #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
80 #error Change CLOCK_CONF_SECOND in contiki-conf.h.
82 if(count % CLOCK_CONF_SECOND == 0) {
86 }
while((TACCR1 - TAR) > INTERVAL);
103 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
118 clock_set(clock_time_t clock, clock_time_t fclock)
121 TACCR1 = fclock + INTERVAL;
138 return (
unsigned short) (TAR - t);
153 TACTL = TASSEL0 | TACLR;
201 while(
clock_time() - start < (clock_time_t)i);
205 clock_set_seconds(
unsigned long sec)
213 unsigned long t1, t2;