36 #include <sys/clock.h>
41 #include "contiki-conf.h"
44 #define MAX_TICKS (~((clock_time_t)0) / 2)
46 static volatile clock_time_t current_clock = 0;
48 volatile unsigned long seconds = 0;
50 static struct rtimer rt_clock;
55 rt_do_clock(
struct rtimer *t,
void *ptr)
58 (rtimer_callback_t)rt_do_clock, ptr);
62 if((current_clock % CLOCK_CONF_SECOND) == 0) {
96 clock_time_t endticks = current_clock + t;
97 while ((
signed long)(current_clock - endticks) < 0) {;}
108 if(howlong<2)
return;
111 volatile register uint32_t i=*MACA_CLK+howlong/4;
112 while (i > *MACA_CLK) ;
117 volatile register uint32_t i=4000*howlong/2301;
138 if(howlong--)
return;
147 seconds+=howmany/CLOCK_CONF_SECOND;
149 if(((current_clock % CLOCK_CONF_SECOND) + (howmany % CLOCK_CONF_SECOND)) >= CLOCK_CONF_SECOND) seconds++;
151 current_clock+=howmany;
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
int rtimer_set(struct rtimer *rtimer, rtimer_clock_t time, rtimer_clock_t duration, rtimer_callback_t func, void *ptr)
Post a real-time task.
#define RTIMER_TIME(task)
Get the time that a task last was executed.
void clock_delay_msec(uint16_t howlong)
Delay up to 65535 milliseconds.
#define NULL
The null pointer.
Default definitions of C compiler quirk work-arounds.
void clock_init(void)
Initialize the clock library.
void clock_adjust_ticks(clock_time_t howmany)
Adjust the system current clock time.
CCIF clock_time_t clock_time(void)
Get the current clock time.
Header file for the real-time timer module.
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.
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.
#define RTIMER_NOW()
Get the current clock time.
Representation of a real-time task.
void clock_wait(clock_time_t t)
Wait for a given number of ticks.