33 #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 #define CLOCK_LT(a, b) ((int16_t)((a)-(b)) < 0) 46 static volatile unsigned long seconds;
48 static volatile clock_time_t count = 0;
50 static volatile uint16_t last_tar = 0;
52 static inline uint16_t
64 ISR(TIMER1_A1, timera1)
72 while(TA1CTL & MC1 && TA1CCR1 - TA1R == 1);
74 last_tar = read_tar();
76 while(!CLOCK_LT(last_tar, TA1CCR1)) {
84 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0 85 #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...). 86 #error Change CLOCK_CONF_SECOND in contiki-conf.h. 88 if(count % CLOCK_CONF_SECOND == 0) {
92 last_tar = read_tar();
121 clock_set(clock_time_t clock, clock_time_t fclock)
124 TA1CCR1 = fclock + INTERVAL;
141 return (
unsigned short) (TA1R - t);
155 #if INTERVAL==32768/CLOCK_SECOND 156 TA1CTL = TASSEL0 | TACLR;
157 #elif INTERVAL==16384/CLOCK_SECOND 158 TA1CTL = TASSEL0 | TACLR | ID_1;
160 #error NEED TO UPDATE clock.c to match interval! 201 while(
clock_time() - start < (clock_time_t)i);
216 unsigned long t1, t2;
227 rtimer_clock_t t1, t2;
static bool start(void)
Start measurement.
Header file for the energy estimation mechanism
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
int clock_fine_max(void)
Deprecated platform-specific routines.
int etimer_pending(void)
Check if there are any non-expired event timers.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
clock_time_t clock_time(void)
Get the current clock time.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.
void clock_init(void)
Arch-specific implementation of clock_init for the cc2538.