55 #include <sys/clock.h>
60 static volatile clock_time_t ticks;
61 static volatile unsigned long seconds;
73 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
74 #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
75 #error Change CLOCK_CONF_SECOND in contiki-conf.h.
101 #define CLOCK_INIT(XX) \
107 pic32_timer##XX##_init(CLOCK_SECOND);\
108 pic32_timer##XX##_enable_irq(); \
109 pic32_timer##XX##_start(); \
112 #if PIC32_TIMER_CLOCK == 1
114 #elif PIC32_TIMER_CLOCK == 2
116 #elif PIC32_TIMER_CLOCK == 3
118 #elif PIC32_TIMER_CLOCK == 4
120 #elif PIC32_TIMER_CLOCK == 5
131 asm volatile(
"mfc0 %0, $9" :
"=r"(now));
138 asm volatile(
"mfc0 %0, $9" :
"=r"(now));
139 if((int32_t)(now - stop) >= 0) {
156 #if PIC32_TIMER_CLOCK == 1
157 TIMER_INTERRUPT(1, clock_callback);
158 #elif PIC32_TIMER_CLOCK == 2
159 TIMER_INTERRUPT(2, clock_callback);
160 #elif PIC32_TIMER_CLOCK == 3
161 TIMER_INTERRUPT(3, clock_callback);
162 #elif PIC32_TIMER_CLOCK == 4
163 TIMER_INTERRUPT(4, clock_callback);
164 #elif PIC32_TIMER_CLOCK == 5
165 TIMER_INTERRUPT(5, clock_callback);