47 #include "contiki-conf.h"
52 static struct etimer *timerlist;
53 static clock_time_t next_expiration;
55 PROCESS(etimer_process,
"Event timer");
64 if (timerlist ==
NULL) {
70 tdist = t->timer.start + t->timer.interval - now;
71 for(t = t->next; t !=
NULL; t = t->next) {
72 if(t->timer.start + t->timer.interval - now < tdist) {
73 tdist = t->timer.start + t->timer.interval - now;
76 next_expiration = now + tdist;
91 if(ev == PROCESS_EVENT_EXITED) {
92 struct process *p = data;
94 while(timerlist !=
NULL && timerlist->p == p) {
95 timerlist = timerlist->next;
98 if(timerlist !=
NULL) {
100 while(t->next !=
NULL) {
101 if(t->next->p == p) {
102 t->next = t->next->next;
108 }
else if(ev != PROCESS_EVENT_POLL) {
116 for(t = timerlist; t !=
NULL; t = t->next) {
157 if(timer->p != PROCESS_NONE) {
158 for(t = timerlist; t !=
NULL; t = t->next) {
170 timer->next = timerlist;
200 et->timer.start += timediff;
207 return et->p == PROCESS_NONE;
213 return et->timer.start + et->timer.interval;
219 return et->timer.start;
225 return timerlist !=
NULL;
240 if(et == timerlist) {
241 timerlist = timerlist->next;
246 for(t = timerlist; t !=
NULL && t->next != et; t = t->next);
261 et->p = PROCESS_NONE;
#define PROCESS_CURRENT()
Get a pointer to the currently running process.
clock_time_t etimer_expiration_time(struct etimer *et)
Get the expiration time for the event timer.
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
void process_poll(struct process *p)
Request a process to be polled.
clock_time_t etimer_start_time(struct etimer *et)
Get the start time for the event timer.
void timer_restart(struct timer *t)
Restart the timer from the current point in time.
#define PROCESS_BEGIN()
Define the beginning of a process.
#define PROCESS_ERR_OK
Return value indicating that an operation was successful.
void timer_set(struct timer *t, clock_time_t interval)
Set a timer.
void etimer_adjust(struct etimer *et, int timediff)
Adjust the expiration time for an event timer.
#define NULL
The null pointer.
int process_post(struct process *p, process_event_t ev, process_data_t data)
Post an asynchronous event.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
CCIF clock_time_t clock_time(void)
Get the current clock time.
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.
#define PROCESS(name, strname)
Declare a process.
void etimer_reset(struct etimer *et)
Reset an event timer with the same interval as was previously set.
int etimer_pending(void)
Check if there are any non-expired event timers.
void etimer_stop(struct etimer *et)
Stop a pending event timer.
#define PROCESS_YIELD()
Yield the currently running process.
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
void etimer_restart(struct etimer *et)
Restart an event timer from the current point in time.
Header file for the Contiki process interface.
int timer_expired(struct timer *t)
Check if a timer has expired.
void timer_reset(struct timer *t)
Reset the timer with the same interval.