Remove bogus Doxygen markup.
[bertos.git] / drv / timer.c
index b123f1b9bcba62d03787b6a90ea3137607ddfcde..b2caf90d9706526aed8ba8f065c40a2a7e5c4ee6 100755 (executable)
 
 /*
  * $Log$
- * Revision 1.7  2004/07/18 21:54:53  bernie
+ * Revision 1.13  2004/08/10 06:59:09  bernie
+ * timer_gettick(): Rename to timer_ticks() and add backwards compatibility inline.
+ *
+ * Revision 1.12  2004/08/08 05:59:37  bernie
+ * Remove a few useless casts.
+ *
+ * Revision 1.11  2004/08/02 20:20:29  aleph
+ * Merge from project_ks
+ *
+ * Revision 1.10  2004/07/30 14:15:53  rasky
+ * Nuovo supporto unificato per detect della CPU
+ *
+ * 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.
  *
  * Revision 1.6  2004/06/07 18:10:06  aleph
 #include "hw.h"
 #include "kdebug.h"
 #include "timer.h"
+#include CPU_HEADER(timer)
 
 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
        #include <kern/proc.h>
 #endif
 
-#if defined(ARCH_EMUL) && (ARCH & ARCH_EMUL)
-       #error To be recoded
-#elif defined(__AVR__)
-       #include "timer_avr.h"
-#elif defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__) /* 80C196 */
-       #include "timer_i196.h"
-#elif defined (__m56800__)
-       #include "timer_dsp56k.h"
-#else
-       #error Unknown system
-#endif
-
-
 //! 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;
 
 
 /*!
@@ -88,7 +97,7 @@ void timer_add(Timer *timer)
        node = (Timer *)timers_queue.head;
        while (node->link.succ)
        {
-               /* Stop just after the insert point */
+               /* Stop just after the insertion point */
                if (node->tick > timer->tick)
                        break;
 
@@ -97,7 +106,7 @@ void timer_add(Timer *timer)
        }
 
        /* Enqueue timer request into the list */
-       INSERTBEFORE((Node *)timer, (Node *)node);
+       INSERTBEFORE(&timer->link, &node->link);
 
        ENABLE_IRQRESTORE(flags);
 }
@@ -110,12 +119,14 @@ Timer *timer_abort(Timer *timer)
 {
        cpuflags_t flags;
        DISABLE_IRQSAVE(flags);
-       REMOVE((Node *)timer);
+       REMOVE(&timer->link);
        ENABLE_IRQRESTORE(flags);
 
        return timer;
 }
 
+#endif /* CONFIG_TIMER_DISABLE_EVENTS */
+
 
 /*!
  * Wait for the specified amount of time (expressed in ms)
@@ -133,15 +144,16 @@ void timer_delay(time_t time)
 
 #else /* !CONFIG_KERN_SIGNALS */
 
-       time_t start = timer_gettick();
+       time_t start = timer_ticks();
 
        /* Busy wait */
-       while (timer_gettick() - start < time) { /* nop */ }
+       while (timer_ticks() - start < time) { /* nop */ }
 
 #endif /* !CONFIG_KERN_SIGNALS */
 }
 
 
+#ifndef CONFIG_TIMER_DISABLE_UDELAY
 /*!
  * Wait for the specified amount of time (expressed in microseconds)
  *
@@ -151,7 +163,7 @@ void timer_delay(time_t time)
  */
 void timer_udelay(utime_t usec_delay)
 {
-       if (usec_delay > 1000)
+       if (UNLIKELY(usec_delay > 1000))
        {
                timer_delay(usec_delay / 1000);
                usec_delay %= 1000;
@@ -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
@@ -204,11 +222,12 @@ DEFINE_TIMER_ISR
                        break;
 
                /* Retreat the expired timer */
-               REMOVE((Node *)timer);
+               REMOVE(&timer->link);
 
                /* Execute the associated event */
-               event_doIntr(&timer->expire);
+               event_do(&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;