X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Ftimer.c;h=0d78d198aaa3a6bb5690bab53f2ad59e49acb80f;hb=46b32fefc02b4b8fc3a9ee1e7225f3053b514a02;hp=4ddf06057503ff1370c59a7907810566a898a780;hpb=11da44352fcd4d33b173c976db45293ac1a87cca;p=bertos.git diff --git a/bertos/drv/timer.c b/bertos/drv/timer.c index 4ddf0605..0d78d198 100644 --- a/bertos/drv/timer.c +++ b/bertos/drv/timer.c @@ -27,20 +27,20 @@ * the GNU General Public License. * * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/) - * Copyright 2000 Bernardo Innocenti - * + * Copyright 2000, 2008 Bernie Innocenti * --> * * \brief Hardware independent timer driver (implementation) * * \version $Id$ - * \author Bernardo Innocenti + * \author Bernie Innocenti */ #include "timer.h" -#include -#include +#include "cfg/cfg_timer.h" +#include "cfg/cfg_wdt.h" +#include "cfg/cfg_kern.h" #include #include #include @@ -74,10 +74,6 @@ #endif #if CONFIG_KERNEL - #include - #if CONFIG_KERN_PREEMPTIVE - #include - #endif #if CONFIG_KERN_SIGNALS #include /* sig_wait(), sig_check() */ #include /* proc_current() */ @@ -163,7 +159,10 @@ void timer_add(Timer *timer) /** - * Remove a timer from the timer queue before it has expired. + * Remove a timer from the timers queue before it has expired. + * + * \note Attempting to remove a timer already expired cause + * undefined behaviour. */ Timer *timer_abort(Timer *timer) { @@ -181,10 +180,8 @@ Timer *timer_abort(Timer *timer) */ void timer_delayTicks(ticks_t delay) { -#if defined(IRQ_ENABLED) /* We shouldn't sleep with interrupts disabled */ - ASSERT(IRQ_ENABLED()); -#endif + ASSERT_IRQ_ENABLED(); #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS Timer t; @@ -338,3 +335,19 @@ void timer_init(void) MOD_INIT(timer); } + + +#if (ARCH & ARCH_EMUL) +/** + * Stop timer (only used by emulator) + */ +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 */