Fix trivial warning and errors.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 8 Oct 2007 17:04:29 +0000 (17:04 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 8 Oct 2007 17:04:29 +0000 (17:04 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@836 38d2e660-2303-0410-9eaa-f027e97ec537

drv/at91/sysirq.c
drv/at91/sysirq.h
drv/at91/timer.c
drv/at91/timer.h

index fc9f687fc188ddd002de35d75d4f39bf1913bf21..6b7a006274121ac650f6648160e070cbe4593af4 100644 (file)
@@ -18,7 +18,7 @@
  * independently.
  * However, there are a few sources called "system sources" that
  * share a common IRQ line and vector, called "system IRQ".
- * So a unique system IRQ handler is implemented here.
+ * So a unique system IRQ dispatcher is implemented here.
  * This module also contains an interface to manage every source
  * independently. It is possible to assign to every system IRQ
  * a specific IRQ handler.
  */
 
 #include "sysirq.h"
-#include "at91.h"
+#include "at91sam7s.h"
 #include <cfg/cpu.h>
-
-#warning Very untested!
+#include <cfg/module.h>
+#include <cfg/macros.h>
 
 /**
  * Enable/disable the Periodic Interrupt Timer
  * interrupt.
  */
-INLINE static void pit_setEnable(bool enable)
+INLINE void pit_setEnable(bool enable)
 {
        if (enable)
                PIT_MR |= BV(PITIEN);
@@ -72,7 +72,7 @@ STATIC_ASSERT(countof(sysirq_tab) == SYSIRQ_CNT);
 static void sysirq_dispatcher(void)
 {
        #warning TODO add IRQ prologue/epilogue
-       for (int i = 0; i < countof(sysirq_tab); i++)
+       for (unsigned i = 0; i < countof(sysirq_tab); i++)
        {
                if (sysirq_tab[i].enabled
                 && sysirq_tab[i].handler)
@@ -95,13 +95,13 @@ void sysirq_init(void)
        IRQ_SAVE_DISABLE(flags);
 
        /* Disable all system interrupts */
-       for (int i = 0; i < countof(sysirq_tab); i++)
+       for (unsigned i = 0; i < countof(sysirq_tab); i++)
                sysirq_tab[i].setEnable(false);
 
        /* Set the vector. */
-       AIC_SVR(SYSC_ID) = sysirq_handler;
+       AIC_SVR(SYSC_ID) = sysirq_dispatcher;
        /* Initialize to edge triggered with defined priority. */
-       AIC_SMR(SYSC_ID) = BV(AIC_SRCTYPE_INT_EDGE_TRIGGERED) | SYSIRQ_PRIORITY;
+       AIC_SMR(SYSC_ID) = AIC_SRCTYPE_INT_EDGE_TRIGGERED | SYSIRQ_PRIORITY;
        /* Clear interrupt */
        AIC_ICCR = BV(SYSC_ID);
 
@@ -129,7 +129,7 @@ void sysirq_setEnable(sysirq_t irq, bool enable)
        ASSERT(irq < SYSIRQ_CNT);
 
        sysirq_tab[irq].setEnable(enable);
-       sysirq_enabled = enable;
+       sysirq_tab[irq].enabled = enable;
 }
 
 /**
@@ -139,5 +139,6 @@ bool sysirq_enabled(sysirq_t irq)
 {
        ASSERT(irq >= 0);
        ASSERT(irq < SYSIRQ_CNT);
+
        return sysirq_tab[irq].enabled;
 }
index 44f17005bf18a1507cf489298eb965b775539c29..301e9f5a8bd6b64a3f70cf52c8739feaacefca77 100644 (file)
@@ -15,6 +15,8 @@
 #ifndef DRV_AT91_SYSIRQ_H
 #define DRV_AT91_SYSIRQ_H
 
+#include <cfg/compiler.h>
+
 typedef void (* sysirq_handler_t)(void);   ///< Type for system irq handler.
 typedef void (* sysirq_setEnable_t)(bool); ///< Type for system irq enable/disable function.
 
index d4de6a3b4d2611ac68cf3042cd8d8d8ee09c6407..e40bb0ac2de6e19224579780e6055927af8bef97 100644 (file)
  * \brief Low-level timer module for Atmel AT91 (inplementation).
  */
 
-#include <drv/timer_at91.h>
-#include <cfg/macros.h> // BV()
+#include "timer.h"
+#include "at91sam7s.h"
+#include "sysirq.h"
 
+#include <cfg/macros.h> // BV()
+#include <cfg/module.h>
 #include <cfg/cpu.h>
 
 
 /** HW dependent timer initialization  */
 #if (CONFIG_TIMER == TIMER_ON_PIT)
-       #warning Very untested!
-       INLINE static void timer_hw_irq(void)
+       INLINE void timer_hw_irq(void)
        {
                /* Reset counters, this is needed to reset timer and interrupt flags */
-               volatile uint32_t dummy = PIT_PIVR;
+               uint32_t dummy = PIVR;
+               (void) dummy;
        }
 
-       INLINE static bool timer_hw_triggered(void)
+       INLINE bool timer_hw_triggered(void)
        {
                return PIT_SR & BV(PITS);
        }
 
-       INLINE static void timer_hw_init(void)
+       INLINE void timer_hw_init(void)
        {
                cpuflags_t flags;
+
+               MOD_CHECK(sysirq);
+
                IRQ_SAVE_DISABLE(flags);
 
-               PIT_MR = CLOCK_FREQ / (16 * TIMER_TICKS_PER_SEC) - 1;
+               PIT_MR = TIMER_HW_CNT;
                /* Register system interrupt handler. */
                sysirq_setHandler(SYSIRQ_PIT, timer_handler);
 
                /* Enable interval timer and interval timer interrupts */
-               PIT_MR |= BV(PIT_PITEN);
+               PIT_MR |= BV(PITEN);
                sysirq_setEnable(SYSIRQ_PIT, true);
 
                /* Reset counters, this is needed to start timer and interrupt flags */
-               volatile uint32_t dummy = PIT_PIVR;
+               uint32_t dummy = PIVR;
+               (void) dummy;
 
                IRQ_RESTORE(flags);
        }
 
-       INLINE static hptime_t timer_hw_hpread(void)
+       INLINE hptime_t timer_hw_hpread(void)
        {
                /* In the upper part of PIT_PIIR there is unused data */
-               return PIT_PIIR & 0xfffff;
+               return PIIR & CPIV_MASK;
        }
 
 #else
index ca3ccdfc455d14142d3ef6d02f436734bb4c0f00..4d6d1e1f45abea093284486ab29243ce0d0e5bd8 100644 (file)
  */
 #if (CONFIG_TIMER == TIMER_ON_PIT)
 
+       void timer_handler(void);
+
        #define DEFINE_TIMER_ISR     void timer_handler(void)
        #define TIMER_TICKS_PER_SEC  1000
-       #define TIMER_HW_CNT         FIXME
+       #define TIMER_HW_CNT         (CLOCK_FREQ / (16 * TIMER_TICKS_PER_SEC) - 1)
+
+       /** Frequency of the hardware high-precision timer. */
+       #define TIMER_HW_HPTICKS_PER_SEC (CLOCK_FREQ / 16)
 
        /// Type of time expressed in ticks of the hardware high-precision timer
        typedef uint32_t hptime_t;
@@ -47,7 +52,5 @@
        #error Unimplemented value for CONFIG_TIMER
 #endif /* CONFIG_TIMER */
 
-/** Frequency of the hardware high-precision timer. */
-#define TIMER_HW_HPTICKS_PER_SEC FIXME
 
 #endif /* DRV_TIMER_AT91_H */