projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add handy functions for handling non recurrent timeouts.
[bertos.git]
/
bertos
/
drv
/
timer.c
diff --git
a/bertos/drv/timer.c
b/bertos/drv/timer.c
index d75f15abcf85324e525444bd3ad060404f196c56..a64a839ca76ea5415b5f488c3edaefd0695e10cd 100644
(file)
--- a/
bertos/drv/timer.c
+++ b/
bertos/drv/timer.c
@@
-127,10
+127,6
@@
INLINE void timer_addToList(Timer *timer, List *queue)
ASSERT(timer->magic != TIMER_MAGIC_ACTIVE);
DB(timer->magic = TIMER_MAGIC_ACTIVE;)
ASSERT(timer->magic != TIMER_MAGIC_ACTIVE);
DB(timer->magic = TIMER_MAGIC_ACTIVE;)
-
- /* Calculate expiration time for this timer */
- timer->tick = _clock + timer->_delay;
-
/*
* Search for the first node whose expiration time is
* greater than the timer we want to add.
/*
* Search for the first node whose expiration time is
* greater than the timer we want to add.
@@
-162,7
+158,12
@@
INLINE void timer_addToList(Timer *timer, List *queue)
*/
void timer_add(Timer *timer)
{
*/
void timer_add(Timer *timer)
{
- ATOMIC(timer_addToList(timer, &timers_queue));
+ ATOMIC(
+ /* Calculate expiration time for this timer */
+ timer->tick = _clock + timer->_delay;
+
+ timer_addToList(timer, &timers_queue);
+ );
}
/**
}
/**
@@
-212,9
+213,18
@@
INLINE void timer_poll(List *queue)
*/
void synctimer_add(Timer *timer, List *queue)
{
*/
void synctimer_add(Timer *timer, List *queue)
{
+ timer->tick = timer_clock() + timer->_delay;
+
+ timer_addToList(timer, queue);
+}
+
+void synctimer_readd(Timer *timer, List *queue)
+{
+ timer->tick += timer->_delay;
timer_addToList(timer, queue);
}
timer_addToList(timer, queue);
}
+
/**
* Simple synchronous timer based scheduler polling routine.
*
/**
* Simple synchronous timer based scheduler polling routine.
*
@@
-252,7
+262,7
@@
void timer_delayTicks(ticks_t delay)
#if CONFIG_KERN_SIGNALS
Timer t;
#if CONFIG_KERN_SIGNALS
Timer t;
-
+ DB(t.magic = TIMER_MAGIC_INACTIVE;)
if (proc_preemptAllowed())
{
ASSERT(!sig_check(SIG_SINGLE));
if (proc_preemptAllowed())
{
ASSERT(!sig_check(SIG_SINGLE));
@@
-401,17
+411,14
@@
void timer_init(void)
}
}
-#if (ARCH & ARCH_EMUL)
+#if (ARCH & ARCH_EMUL)
|| (CPU_ARM_AT91)
/**
/**
- * Stop timer
(only used by emulator)
+ * Stop timer
*/
void timer_cleanup(void)
{
MOD_CLEANUP(timer);
timer_hw_cleanup();
*/
void timer_cleanup(void)
{
MOD_CLEANUP(timer);
timer_hw_cleanup();
-
- // Hmmm... apparently, the demo app does not cleanup properly
- //ASSERT(LIST_EMPTY(&timers_queue));
}
}
-#endif
/* ARCH_EMUL */
+#endif