timer: Cleanup and warning removal from driver and test
[bertos.git] / bertos / drv / timer.c
index 942726399b1e47b0ebb102acd06b308592494ec7..f282478aa361a42e77e69762ffab5f8fbabbf968 100644 (file)
@@ -27,8 +27,7 @@
  * the GNU General Public License.
  *
  * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
+ * Copyright 2000, 2008 Bernie Innocenti <bernie@codewiz.org>
  * -->
  *
  * \brief Hardware independent timer driver (implementation)
@@ -75,9 +74,6 @@
 #endif
 
 #if CONFIG_KERNEL
-       #if CONFIG_KERN_PREEMPTIVE
-               #include <hw/switch.h>
-       #endif
        #if CONFIG_KERN_SIGNALS
                #include <kern/signal.h> /* sig_wait(), sig_check() */
                #include <kern/proc.h>   /* proc_current() */
 volatile ticks_t _clock;
 
 
-#ifndef CONFIG_TIMER_DISABLE_EVENTS
+#if CONFIG_TIMER_EVENTS
 
 /**
  * List of active asynchronous timers.
@@ -164,6 +160,7 @@ void timer_add(Timer *timer)
 
 /**
  * Remove a timer from the timers queue before it has expired.
+ *
  * \note Attempting to remove a timer already expired cause
  *       undefined behaviour.
  */
@@ -175,7 +172,7 @@ Timer *timer_abort(Timer *timer)
        return timer;
 }
 
-#endif /* CONFIG_TIMER_DISABLE_EVENTS */
+#endif /* CONFIG_TIMER_EVENTS */
 
 
 /**
@@ -183,17 +180,14 @@ Timer *timer_abort(Timer *timer)
  */
 void timer_delayTicks(ticks_t delay)
 {
-#if defined(IRQ_ENABLED) && (!(ARCH & ARCH_EMUL))
        /* We shouldn't sleep with interrupts disabled */
-       ASSERT(IRQ_ENABLED());
-#endif
-
+       ASSERT_IRQ_ENABLED();
 
 #if defined(CONFIG_KERN_SIGNALS) && CONFIG_KERN_SIGNALS
        Timer t;
 
        ASSERT(!sig_check(SIG_SINGLE));
-       timer_set_event_signal(&t, proc_current(), SIG_SINGLE);
+       timer_setSignal(&t, proc_current(), SIG_SINGLE);
        timer_setDelay(&t, delay);
        timer_add(&t);
        sig_wait(SIG_SINGLE);
@@ -214,7 +208,7 @@ void timer_delayTicks(ticks_t delay)
 }
 
 
-#ifndef CONFIG_TIMER_DISABLE_UDELAY
+#if CONFIG_TIMER_UDELAY
 
 /**
  * Busy wait until the specified amount of high-precision ticks have elapsed.
@@ -260,7 +254,7 @@ void timer_delayHp(hptime_t delay)
 
        timer_busyWait(delay);
 }
-#endif /* CONFIG_TIMER_DISABLE_UDELAY */
+#endif /* CONFIG_TIMER_UDELAY */
 
 
 /**
@@ -278,9 +272,10 @@ DEFINE_TIMER_ISR
        #pragma interrupt saveall
        #endif
 
-#ifndef CONFIG_TIMER_DISABLE_EVENTS
+#if CONFIG_TIMER_EVENTS
        Timer *timer;
 #endif
+
        /*
         * On systems sharing IRQ line and vector, this check is needed
         * to ensure that IRQ is generated by timer source.
@@ -296,7 +291,7 @@ DEFINE_TIMER_ISR
        /* Update the master ms counter */
        ++_clock;
 
-#ifndef CONFIG_TIMER_DISABLE_EVENTS
+#if CONFIG_TIMER_EVENTS
        /*
         * Check the first timer request in the list and process
         * it when it has expired. Repeat this check until the
@@ -317,7 +312,7 @@ DEFINE_TIMER_ISR
                /* Execute the associated event */
                event_do(&timer->expire);
        }
-#endif /* CONFIG_TIMER_DISABLE_EVENTS */
+#endif /* CONFIG_TIMER_EVENTS */
 
        TIMER_STROBE_OFF;
 }
@@ -331,7 +326,7 @@ void timer_init(void)
 {
        TIMER_STROBE_INIT;
 
-#ifndef CONFIG_TIMER_DISABLE_EVENTS
+#if CONFIG_TIMER_EVENTS
        LIST_INIT(&timers_queue);
 #endif