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 #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
66 ENERGEST_ON(ENERGEST_TYPE_IRQ);
74 while(TACTL & MC1 && TACCR1 - read_tar() == 1);
76 last_tar = read_tar();
78 while(!CLOCK_LT(last_tar, TACCR1)) {
86 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
87 #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
88 #error Change CLOCK_CONF_SECOND in contiki-conf.h.
90 if(count % CLOCK_CONF_SECOND == 0) {
94 last_tar = read_tar();
110 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
125 clock_set(clock_time_t clock, clock_time_t fclock)
128 TACCR1 = fclock + INTERVAL;
145 return (
unsigned short) (TAR - t);
162 #if INTERVAL==32768/CLOCK_SECOND
163 TACTL = TASSEL0 | TACLR;
164 #elif INTERVAL==16384/CLOCK_SECOND
165 TACTL = TASSEL0 | TACLR | ID_1;
167 #error NEED TO UPDATE clock.c to match interval!
208 while(
clock_time() - start < (clock_time_t)i);
223 unsigned long t1, t2;
234 rtimer_clock_t t1, t2;
void watchdog_start(void)
Starts the WDT in watchdog mode if enabled by user configuration, maximum interval.
void clock_init(void)
Initialize the clock library.
Header file for the energy estimation mechanism
CCIF clock_time_t clock_time(void)
Get the current clock time.
void watchdog_stop(void)
In watchdog mode, the WDT can not be stopped.
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.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.
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.
void clock_wait(clock_time_t t)
Wait for a given number of ticks.
int clock_fine_max(void)
Deprecated platform-specific routines.