47 #include "contiki-conf.h" 52 #ifndef ETIMER_CONF_SYNC 53 #define ETIMER_CONF_SYNC 0 56 static struct etimer *timerlist;
57 static clock_time_t next_expiration;
59 PROCESS(etimer_process,
"Event timer");
68 if (timerlist == NULL) {
74 tdist = t->timer.start + t->timer.interval - now;
75 for(t = t->next; t != NULL; t = t->next) {
76 if(t->timer.start + t->timer.interval - now < tdist) {
77 tdist = t->timer.start + t->timer.interval - now;
80 next_expiration = now + tdist;
81 if (next_expiration == 0)
84 #ifdef CLOCK_CONF_TICKLESS 100 if(ev == PROCESS_EVENT_EXITED) {
101 struct process *p =
data;
103 while(timerlist != NULL && timerlist->p == p) {
104 timerlist = timerlist->next;
107 if(timerlist != NULL) {
109 while(t->next != NULL) {
110 if(t->next->p == p) {
111 t->next = t->next->next;
117 }
else if(ev != PROCESS_EVENT_POLL) {
125 for(t = timerlist; t != NULL; t = t->next) {
127 #if !(ETIMER_CONF_SYNC) 146 struct process *p = t->p;
167 #ifdef ECLIPSE_STUB_CODE_ANALYSE 185 if(timer->p != PROCESS_NONE) {
186 for(t = timerlist; t != NULL; t = t->next) {
198 timer->next = timerlist;
228 et->timer.start += timediff;
235 return et->p == PROCESS_NONE;
241 return et->timer.start + et->timer.interval;
247 return et->timer.start;
253 return timerlist != NULL;
268 if(et == timerlist) {
269 timerlist = timerlist->next;
274 for(t = timerlist; t != NULL && t->next != et; t = t->next);
289 et->p = PROCESS_NONE;
#define PROCESS(name, strname)
void etimer_stop(struct etimer *et)
Stop a pending event timer.
CCIF clock_time_t clock_time(void)
void process_poll(struct process *p)
void etimer_restart(struct etimer *et)
Restart an event timer from the current point in time.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
clock_time_t etimer_start_time(struct etimer *et)
Get the start time for the event timer.
void etimer_reset(struct etimer *et)
Reset an event timer with the same interval as was previously set.
void timer_reset(struct timer *t)
void timer_set(struct timer *t, clock_time_t interval)
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
#define PROCESS_ERR_OK
Return value indicating that an operation was successful.
#define PROCESS_CURRENT()
int process_post(struct process *p, process_event_t ev, process_data_t data)
int etimer_expired(struct etimer *et)
Check if an event timer has expired.
int etimer_pending(void)
Check if there are any non-expired event timers.
void timer_restart(struct timer *t)
void etimer_adjust(struct etimer *et, int timediff)
Adjust the expiration time for an event timer.
uint8_t data[USBNET_RX_BUF_SIZE]
void etimer_set(struct etimer *et, clock_time_t interval)
Set an event timer.
#define PROCESS_THREAD(name, ev, data)
int timer_expired(struct timer *t)
void process_post_synch(struct process *p, process_event_t ev, process_data_t data)
clock_time_t etimer_expiration_time(struct etimer *et)
Get the expiration time for the event timer.