From 1eecdfdefd523e5d412f5569f99a37cd2760ed0f Mon Sep 17 00:00:00 2001 From: arighi Date: Tue, 4 May 2010 08:55:01 +0000 Subject: [PATCH] CM3: unify timer driver for Cortex-M3 processors. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3603 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/cortex-m3/drv/timer_cm3.h | 43 ++++++++++++++- bertos/cpu/cortex-m3/drv/timer_lm3s.h | 77 --------------------------- 2 files changed, 41 insertions(+), 79 deletions(-) delete mode 100644 bertos/cpu/cortex-m3/drv/timer_lm3s.h diff --git a/bertos/cpu/cortex-m3/drv/timer_cm3.h b/bertos/cpu/cortex-m3/drv/timer_cm3.h index 6cfaf8cf..b81df0bf 100644 --- a/bertos/cpu/cortex-m3/drv/timer_cm3.h +++ b/bertos/cpu/cortex-m3/drv/timer_cm3.h @@ -35,11 +35,50 @@ * \brief Low-level timer driver (SysTick) for Cortex-M3. */ -#include +#ifndef TIMER_CM3_H +#define TIMER_CM3_H #if CPU_CM3_LM3S - #include "timer_lm3s.h" + #include +#elif CPU_CM3_STM32 + #include /*#elif Add other families here */ #else #error Unknown CPU #endif + +/* Ticks frequency (HZ) */ +#define TIMER_TICKS_PER_SEC 1000 + +/* Frequency of the hardware high-precision timer. */ +#define TIMER_HW_HPTICKS_PER_SEC (CPU_FREQ) + +/* Maximum value of the high-precision hardware counter register */ +#define TIMER_HW_CNT (CPU_FREQ / TIMER_TICKS_PER_SEC) + +/** Type of time expressed in ticks of the hardware high-precision timer */ +typedef uint32_t hptime_t; +#define SIZEOF_HPTIME_T 4 + +/* Timer ISR prototype */ +ISR_PROTO_CONTEXT_SWITCH(timer_handler); +#define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(timer_handler) + +INLINE void timer_hw_irq(void) +{ +} + +INLINE bool timer_hw_triggered(void) +{ + return true; +} + +INLINE hptime_t timer_hw_hpread(void) +{ + return HWREG(NVIC_ST_CURRENT); +} + +void timer_hw_init(void); +void timer_hw_exit(void); + +#endif /* TIMER_CM3_H */ diff --git a/bertos/cpu/cortex-m3/drv/timer_lm3s.h b/bertos/cpu/cortex-m3/drv/timer_lm3s.h deleted file mode 100644 index 00c532f2..00000000 --- a/bertos/cpu/cortex-m3/drv/timer_lm3s.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * \file - * - * - * \brief Low-level timer driver (SysTick) for LM3S1968. - * - * \author Andrea Righi - */ - -#ifndef DRV_CORTEX_M3_TIMER_H -#define DRV_CORTEX_M3_TIMER_H - -#include - -/* Ticks frequency (HZ) */ -#define TIMER_TICKS_PER_SEC 1000 - -/* Frequency of the hardware high-precision timer. */ -#define TIMER_HW_HPTICKS_PER_SEC (CPU_FREQ) - -/* Maximum value of the high-precision hardware counter register */ -#define TIMER_HW_CNT (CPU_FREQ / TIMER_TICKS_PER_SEC) - -/** Type of time expressed in ticks of the hardware high-precision timer */ -typedef uint32_t hptime_t; -#define SIZEOF_HPTIME_T 4 - -/* Timer ISR prototype */ -ISR_PROTO_CONTEXT_SWITCH(timer_handler); -#define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(timer_handler) - -INLINE void timer_hw_irq(void) -{ -} - -INLINE bool timer_hw_triggered(void) -{ - return true; -} - -INLINE hptime_t timer_hw_hpread(void) -{ - return HWREG(NVIC_ST_CURRENT); -} - -void timer_hw_init(void); -void timer_hw_exit(void); - -#endif /* DRV_CORTEX_M3_TIMER_H */ -- 2.25.1