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) {
102 clock_time_t endticks = current_clock + t;
103 while ((
signed long)(current_clock - endticks) < 0) {;}
114 if(howlong<2)
return;
117 volatile register uint32_t i=*MACA_CLK+howlong/4;
118 while (i > *MACA_CLK) ;
123 volatile register uint32_t i=4000*howlong/2301;
144 if(howlong--)
return;
153 seconds+=howmany/CLOCK_CONF_SECOND;
155 if(((current_clock % CLOCK_CONF_SECOND) + (howmany % CLOCK_CONF_SECOND)) >= CLOCK_CONF_SECOND) seconds++;
157 current_clock+=howmany;
Header file for the real-time timer module.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
#define RTIMER_NOW()
Get the current clock time.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
int etimer_pending(void)
Check if there are any non-expired event timers.
clock_time_t clock_time(void)
Get the current clock time.
Default definitions of C compiler quirk work-arounds.
void clock_init()
Initialize the clock library.
void clock_delay_msec(uint16_t howlong)
Delay up to 65535 milliseconds.
#define NULL
The null pointer.
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.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
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.
void clock_adjust_ticks(clock_time_t howmany)
Adjust the system current clock time.
Representation of a real-time task.
void clock_delay_usec(uint16_t usec)
Delay a given number of microseconds.
#define RTIMER_TIME(task)
Get the time that a task last was executed.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.