mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-04 05:29:04 +00:00
added fix to enable start of ctimers before etimer process has started
This commit is contained in:
parent
d8717c264a
commit
44480fc7b7
@ -33,7 +33,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: ctimer.c,v 1.4 2007/03/31 18:31:27 adamdunkels Exp $
|
* $Id: ctimer.c,v 1.5 2007/11/13 15:13:03 nifi Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
LIST(ctimer_list);
|
LIST(ctimer_list);
|
||||||
|
|
||||||
|
static char initialized;
|
||||||
|
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -65,7 +67,10 @@ PROCESS_THREAD(ctimer_process, ev, data)
|
|||||||
struct ctimer *c;
|
struct ctimer *c;
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
list_init(ctimer_list);
|
for(c = list_head(ctimer_list); c != NULL; c = c->next) {
|
||||||
|
etimer_set(&c->etimer, c->etimer.timer.interval);
|
||||||
|
}
|
||||||
|
initialized = 1;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_TIMER);
|
PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_TIMER);
|
||||||
@ -87,6 +92,8 @@ PROCESS_THREAD(ctimer_process, ev, data)
|
|||||||
void
|
void
|
||||||
ctimer_init(void)
|
ctimer_init(void)
|
||||||
{
|
{
|
||||||
|
initialized = 0;
|
||||||
|
list_init(ctimer_list);
|
||||||
process_start(&ctimer_process, NULL);
|
process_start(&ctimer_process, NULL);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
@ -98,10 +105,13 @@ ctimer_set(struct ctimer *c, clock_time_t t,
|
|||||||
c->p = PROCESS_CURRENT();
|
c->p = PROCESS_CURRENT();
|
||||||
c->f = f;
|
c->f = f;
|
||||||
c->ptr = ptr;
|
c->ptr = ptr;
|
||||||
|
if(initialized) {
|
||||||
PROCESS_CONTEXT_BEGIN(&ctimer_process);
|
PROCESS_CONTEXT_BEGIN(&ctimer_process);
|
||||||
etimer_set(&c->etimer, t);
|
etimer_set(&c->etimer, t);
|
||||||
PROCESS_CONTEXT_END(&ctimer_process);
|
PROCESS_CONTEXT_END(&ctimer_process);
|
||||||
|
} else {
|
||||||
|
c->etimer.timer.interval = t;
|
||||||
|
}
|
||||||
|
|
||||||
list_remove(ctimer_list, c);
|
list_remove(ctimer_list, c);
|
||||||
list_add(ctimer_list, c);
|
list_add(ctimer_list, c);
|
||||||
@ -110,9 +120,11 @@ ctimer_set(struct ctimer *c, clock_time_t t,
|
|||||||
void
|
void
|
||||||
ctimer_reset(struct ctimer *c)
|
ctimer_reset(struct ctimer *c)
|
||||||
{
|
{
|
||||||
PROCESS_CONTEXT_BEGIN(&ctimer_process);
|
if(initialized) {
|
||||||
etimer_reset(&c->etimer);
|
PROCESS_CONTEXT_BEGIN(&ctimer_process);
|
||||||
PROCESS_CONTEXT_END(&ctimer_process);
|
etimer_reset(&c->etimer);
|
||||||
|
PROCESS_CONTEXT_END(&ctimer_process);
|
||||||
|
}
|
||||||
|
|
||||||
list_remove(ctimer_list, c);
|
list_remove(ctimer_list, c);
|
||||||
list_add(ctimer_list, c);
|
list_add(ctimer_list, c);
|
||||||
@ -121,7 +133,12 @@ ctimer_reset(struct ctimer *c)
|
|||||||
void
|
void
|
||||||
ctimer_stop(struct ctimer *c)
|
ctimer_stop(struct ctimer *c)
|
||||||
{
|
{
|
||||||
etimer_stop(&c->etimer);
|
if(initialized) {
|
||||||
|
etimer_stop(&c->etimer);
|
||||||
|
} else {
|
||||||
|
c->etimer.next = NULL;
|
||||||
|
c->etimer.p = PROCESS_NONE;
|
||||||
|
}
|
||||||
list_remove(ctimer_list, c);
|
list_remove(ctimer_list, c);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
Loading…
Reference in New Issue
Block a user