timer_cm3.h

Go to the documentation of this file.
00001 
00038 #ifndef TIMER_CM3_H
00039 #define TIMER_CM3_H
00040 
00041 #include "cfg/cfg_timer.h"     /* CONFIG_TIMER */
00042 
00043 #if CPU_CM3_LM3S
00044     #include <io/lm3s.h>
00045 #elif CPU_CM3_STM32
00046     #include <io/stm32.h>
00047 /*#elif  Add other families here */
00048 #else
00049     #error Unknown CPU
00050 #endif
00051 
00059 #define TIMER_ON_GPTM  1
00060 
00061 #define TIMER_DEFAULT  TIMER_ON_GPTM ///< Default system timer
00062 
00063 #if (CONFIG_TIMER == TIMER_ON_GPTM)
00064     /* Ticks frequency (HZ) */
00065     #define TIMER_TICKS_PER_SEC 1000
00066 
00067     /* Frequency of the hardware high-precision timer. */
00068     #define TIMER_HW_HPTICKS_PER_SEC (CPU_FREQ)
00069 
00070     /* Maximum value of the high-precision hardware counter register */
00071     #define TIMER_HW_CNT (CPU_FREQ / TIMER_TICKS_PER_SEC)
00072 
00074     typedef uint32_t hptime_t;
00075     #define SIZEOF_HPTIME_T 4
00076 
00077     /* Timer ISR prototype */
00078     ISR_PROTO_CONTEXT_SWITCH(timer_handler);
00079     #define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(timer_handler)
00080 
00081     INLINE void timer_hw_irq(void)
00082     {
00083     }
00084 
00085 
00086     INLINE bool timer_hw_triggered(void)
00087     {
00088         return true;
00089     }
00090 
00091     INLINE hptime_t timer_hw_hpread(void)
00092     {
00093         return (TIMER_HW_CNT - NVIC_ST_CURRENT_R);
00094     }
00095 
00096 #else
00097 
00098     #error Unimplemented value for CONFIG_TIMER
00099 #endif /* CONFIG_TIMER */
00100 
00101 void timer_hw_init(void);
00102 void timer_hw_exit(void);
00103 
00104 #endif /* TIMER_CM3_H */