Refactor timer to not include cpu specific C files.
authorbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 17 Apr 2009 15:15:31 +0000 (15:15 +0000)
committerbatt <batt@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 17 Apr 2009 15:15:31 +0000 (15:15 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2546 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/arm/drv/timer_at91.c
bertos/cpu/arm/drv/timer_at91.h
bertos/cpu/avr/drv/timer_avr.c
bertos/cpu/avr/drv/timer_avr.h
bertos/drv/timer.c

index b3db6a0fd3d5f37aa94da2ba6bf2869bc6553987..f1c2887e2b0fe47b850a9ba803b1b2b7a6e91251 100644 (file)
 
 /** HW dependent timer initialization  */
 #if (CONFIG_TIMER == TIMER_ON_PIT)
-       INLINE void timer_hw_irq(void)
-       {
-               /* Reset counters, this is needed to reset timer and interrupt flags */
-               uint32_t dummy = PIVR;
-               (void) dummy;
-       }
-
-       INLINE bool timer_hw_triggered(void)
-       {
-               return PIT_SR & BV(PITS);
-       }
 
-       INLINE void timer_hw_init(void)
+       void timer_hw_init(void)
        {
                sysirq_init();
 
                IRQ_RESTORE(flags);
        }
 
-       INLINE hptime_t timer_hw_hpread(void)
-       {
-               /* In the upper part of PIT_PIIR there is unused data */
-               return PIIR & CPIV_MASK;
-       }
-
 #else
        #error Unimplemented value for CONFIG_TIMER
 #endif /* CONFIG_TIMER */
index eca205c504a22c43c2f95eb80de78142958847f8..54ba6e37f37f6d693e981b5693aba5954b161eb5 100644 (file)
 #ifndef DRV_AT91_TIMER_H
 #define DRV_AT91_TIMER_H
 
-#include <hw/hw_cpufreq.h>            /* CPU_FREQ */
+#include <hw/hw_cpufreq.h>     /* CPU_FREQ */
 
 #include "cfg/cfg_timer.h"     /* CONFIG_TIMER */
 #include <cfg/compiler.h>      /* uint8_t */
+#include <cfg/macros.h>        /* BV */
+
+#include <io/arm.h>
 
 /**
  * \name Values for CONFIG_TIMER.
        /** Frequency of the hardware high-precision timer. */
        #define TIMER_HW_HPTICKS_PER_SEC (CPU_FREQ / 16)
 
-       /// Type of time expressed in ticks of the hardware high-precision timer
+       /** Type of time expressed in ticks of the hardware high-precision timer */
        typedef uint32_t hptime_t;
+
+       INLINE void timer_hw_irq(void)
+       {
+               /* Reset counters, this is needed to reset timer and interrupt flags */
+               uint32_t dummy = PIVR;
+               (void) dummy;
+       }
+
+       INLINE bool timer_hw_triggered(void)
+       {
+               return PIT_SR & BV(PITS);
+       }
+
+       INLINE hptime_t timer_hw_hpread(void)
+       {
+               /* In the upper part of PIT_PIIR there is unused data */
+               return PIIR & CPIV_MASK;
+       }
+
 #else
 
        #error Unimplemented value for CONFIG_TIMER
 #endif /* CONFIG_TIMER */
 
+void timer_hw_init(void);
+
 
 #endif /* DRV_TIMER_AT91_H */
index 4920934756467a5b271be1c04610ce0cb80060b4..53a5c007211fc526d25270906b1ef92a087ae609 100644 (file)
@@ -48,7 +48,6 @@
 #include <cpu/types.h>
 #include <cpu/irq.h>
 
-#include <avr/interrupt.h>
 #include <avr/io.h>
 
 #if CPU_AVR_ATMEGA1281 || CPU_AVR_ATMEGA168
 /** HW dependent timer initialization  */
 #if (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE0)
 
-       static void timer_hw_init(void)
+       void timer_hw_init(void)
        {
                cpu_flags_t flags;
                IRQ_SAVE_DISABLE(flags);
                IRQ_RESTORE(flags);
        }
 
-       INLINE hptime_t timer_hw_hpread(void)
-       {
-               return TCNT0;
-       }
-
 #elif (CONFIG_TIMER == TIMER_ON_OVERFLOW1)
 
-       static void timer_hw_init(void)
+       void timer_hw_init(void)
        {
                cpu_flags_t flags;
                IRQ_SAVE_DISABLE(flags);
                IRQ_RESTORE(flags);
        }
 
-       INLINE hptime_t timer_hw_hpread(void)
-       {
-               return TCNT1;
-       }
-
 #elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2)
-       static void timer_hw_init(void)
+       void timer_hw_init(void)
        {
                cpu_flags_t flags;
                IRQ_SAVE_DISABLE(flags);
                IRQ_RESTORE(flags);
        }
 
-       INLINE hptime_t timer_hw_hpread(void)
-       {
-               return TCNT2;
-       }
 #elif (CONFIG_TIMER == TIMER_ON_OVERFLOW3)
 
-       static void timer_hw_init(void)
+       void timer_hw_init(void)
        {
                cpu_flags_t flags;
                IRQ_SAVE_DISABLE(flags);
                IRQ_RESTORE(flags);
        }
 
-       INLINE hptime_t timer_hw_hpread(void)
-       {
-               return TCNT3;
-       }
-
 #else
        #error Unimplemented value for CONFIG_TIMER
 #endif /* CONFIG_TIMER */
index 96d05082b83f978b8c27815c1d601e36385aae2c..89d0dd76d134c9d5ff8ebb595838e4e0fa9fa2b2 100644 (file)
 #ifndef DRV_TIMER_AVR_H
 #define DRV_TIMER_AVR_H
 
-#include <hw/hw_cpufreq.h>        /* CPU_FREQ */
+#include <hw/hw_cpufreq.h>   /* CPU_FREQ */
 
-#include "cfg/cfg_timer.h"     /* CONFIG_TIMER */
-#include <cfg/compiler.h>  /* uint8_t */
-#include <cfg/macros.h>    /* DIV_ROUND */
+#include "cfg/cfg_timer.h"   /* CONFIG_TIMER */
+#include <cfg/compiler.h>    /* uint8_t */
+#include <cfg/macros.h>      /* DIV_ROUND */
 
+#include <avr/io.h>
+#include <avr/interrupt.h>
 
 /**
  * \name Values for CONFIG_TIMER.
        /// Type of time expressed in ticks of the hardware high-precision timer
        typedef uint8_t hptime_t;
 
+       INLINE hptime_t timer_hw_hpread(void)
+       {
+               return TCNT0;
+       }
+
 #elif (CONFIG_TIMER == TIMER_ON_OVERFLOW1)
 
        #define TIMER_PRESCALER      1
        /// Type of time expressed in ticks of the hardware high precision timer
        typedef uint16_t hptime_t;
 
+       INLINE hptime_t timer_hw_hpread(void)
+       {
+               return TCNT1;
+       }
+
 #elif (CONFIG_TIMER == TIMER_ON_OUTPUT_COMPARE2)
 
        #define TIMER_PRESCALER      64
        /** Value for OCR register in output-compare based timers. */
        #define TIMER_HW_CNT         OCR_DIVISOR
 
-
        /// Type of time expressed in ticks of the hardware high precision timer
        typedef uint8_t hptime_t;
 
+       INLINE hptime_t timer_hw_hpread(void)
+       {
+               return TCNT2;
+       }
+
 #elif (CONFIG_TIMER == TIMER_ON_OVERFLOW3)
 
        #define TIMER_PRESCALER      1
 
        /// Type of time expressed in ticks of the hardware high precision timer
        typedef uint16_t hptime_t;
+
+       INLINE hptime_t timer_hw_hpread(void)
+       {
+               return TCNT3;
+       }
+
 #else
 
        #error Unimplemented value for CONFIG_TIMER
 /** Not needed, timer IRQ handler called only for timer source */
 #define timer_hw_triggered() (true)
 
+void timer_hw_init(void);
 
 #endif /* DRV_TIMER_AVR_H */
index 7e99d78ee8822b9e6eeaadbdd434b09c221fc8ac..694b37eea2b34c0b451b9317c25f9f878ce0a850 100644 (file)
@@ -58,8 +58,6 @@
 #if OS_HOSTED
        //#include OS_CSOURCE(timer)
        #include <emul/timer_posix.c>
-#else
-       #include CPU_CSOURCE(timer)
 #endif
 
 /*