From 1da31e2b251edb8174ea591b67da33b1ac27b554 Mon Sep 17 00:00:00 2001 From: bernie Date: Wed, 21 Jul 2004 00:15:13 +0000 Subject: [PATCH 1/1] Put timer driver on diet. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@75 38d2e660-2303-0410-9eaa-f027e97ec537 --- drv/timer.c | 29 +++++++++++++++++++++++++---- drv/timer.h | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 53 insertions(+), 13 deletions(-) diff --git a/drv/timer.c b/drv/timer.c index 64eaf944..06213368 100755 --- a/drv/timer.c +++ b/drv/timer.c @@ -15,6 +15,9 @@ /* * $Log$ + * Revision 1.9 2004/07/21 00:15:13 bernie + * Put timer driver on diet. + * * Revision 1.8 2004/07/18 21:57:07 bernie * Fix preprocessor warning with potentially undefined symbol. * @@ -62,7 +65,13 @@ //! Master system clock (1ms accuracy) volatile time_t _clock; -REGISTER static List timers_queue; /*!< Active timers */ + +#ifndef CONFIG_TIMER_DISABLE_EVENTS + +/*! + * List of active asynchronous timers. + */ +REGISTER static List timers_queue; /*! @@ -116,6 +125,8 @@ Timer *timer_abort(Timer *timer) return timer; } +#endif /* CONFIG_TIMER_DISABLE_EVENTS */ + /*! * Wait for the specified amount of time (expressed in ms) @@ -142,6 +153,7 @@ void timer_delay(time_t time) } +#ifndef CONFIG_TIMER_DISABLE_UDELAY /*! * Wait for the specified amount of time (expressed in microseconds) * @@ -166,6 +178,7 @@ void timer_udelay(utime_t usec_delay) while (timer_hw_hpread() - start < delay) {} } +#endif /* CONFIG_TIMER_DISABLE_UDELAY */ /*! @@ -174,14 +187,18 @@ void timer_udelay(utime_t usec_delay) */ DEFINE_TIMER_ISR { - /* With the Metrowerks compiler, the only way to force the compiler generate - an interrupt service routine is to put a pragma directive within the function - body. */ + /* + * With the Metrowerks compiler, the only way to force the compiler generate + * an interrupt service routine is to put a pragma directive within the function + * body. + */ #ifdef __MWERKS__ #pragma interrupt saveall #endif +#ifndef CONFIG_TIMER_DISABLE_EVENTS Timer *timer; +#endif TIMER_STROBE_ON; @@ -190,6 +207,7 @@ DEFINE_TIMER_ISR /* Update the master ms counter */ ++_clock; +#ifndef CONFIG_TIMER_DISABLE_EVENTS /* * Check the first timer request in the list and process * it when it has expired. Repeat this check until the @@ -209,6 +227,7 @@ DEFINE_TIMER_ISR /* Execute the associated event */ event_doIntr(&timer->expire); } +#endif /* CONFIG_TIMER_DISABLE_EVENTS */ TIMER_STROBE_OFF; } @@ -221,7 +240,9 @@ void timer_init(void) { TIMER_STROBE_INIT; +#ifndef CONFIG_TIMER_DISABLE_EVENTS INITLIST(&timers_queue); +#endif _clock = 0; diff --git a/drv/timer.h b/drv/timer.h index 5a9c93e2..da5a5d1c 100755 --- a/drv/timer.h +++ b/drv/timer.h @@ -15,6 +15,9 @@ /* * $Log$ + * Revision 1.10 2004/07/21 00:13:57 bernie + * Put timer driver on diet. + * * Revision 1.9 2004/07/20 23:45:01 bernie * Finally remove redundant protos. * @@ -50,15 +53,33 @@ #include "compiler.h" #include +/*! Number of timer ticks per second. */ +#define TICKS_PER_SEC 1000 + +/* Function protos */ +extern void timer_init(void); +extern void timer_delay(time_t time); + +#ifndef CONFIG_TIMER_DISABLE_UDELAY +extern void timer_udelay(utime_t utime); +#endif + + +#ifndef CONFIG_TIMER_DISABLE_EVENTS + #ifdef CONFIG_KERNEL #include #else #include #endif -/*! Number of timer ticks per second. */ -#define TICKS_PER_SEC 1000 - +/*! + * The timer driver supports multiple ssynchronous timers + * that can trigger an event when they expire. + * + * \sa timer_add() + * \sa timer_abort() + */ typedef struct Timer { Node link; /*!< Link into timers queue */ @@ -67,12 +88,8 @@ typedef struct Timer Event expire; /*!< Event to execute when the timer expires */ } Timer; -/* Function protos */ -extern void timer_init(void); extern void timer_add(Timer *timer); extern Timer *timer_abort(Timer *timer); -extern void timer_delay(time_t time); -extern void timer_udelay(utime_t utime); #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS @@ -96,6 +113,7 @@ INLINE void timer_set_delay(Timer* timer, time_t delay) timer->delay = delay; } +#endif /* CONFIG_TIMER_DISABLE_EVENTS */ extern volatile time_t _clock; @@ -140,8 +158,9 @@ INLINE time_t timer_tick(void) /*! - * Like \c timer_tick, faster version to be called - * from interrupt context only. + * Faster version of timer_tick(), to be called only when the timer + * interrupt is disabled (DISABLE_INTS) or overridden by a + * higher-priority or non-nesting interrupt. * * \sa timer_tick */ -- 2.25.1