BeRTOS
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 #include <cpu/detect.h>
00044 #include <cpu/irq.h>
00045 
00046 #if CPU_CM3_LM3S
00047     #include <io/lm3s.h>
00048 #elif CPU_CM3_STM32
00049     #include <io/stm32.h>
00050 #elif CPU_CM3_SAM3
00051     #include <io/sam3.h>
00052 /*#elif  Add other families here */
00053 #else
00054     #error Unknown CPU
00055 #endif
00056 
00064 #define TIMER_ON_GPTM  1
00065 
00066 #define TIMER_DEFAULT  TIMER_ON_GPTM ///< Default system timer
00067 
00068 #if (CONFIG_TIMER == TIMER_ON_GPTM)
00069     /* Ticks frequency (HZ) */
00070     #define TIMER_TICKS_PER_SEC 1000
00071 
00072     /* Frequency of the hardware high-precision timer. */
00073     #define TIMER_HW_HPTICKS_PER_SEC (CPU_FREQ)
00074 
00075     /* Maximum value of the high-precision hardware counter register */
00076     #define TIMER_HW_CNT (CPU_FREQ / TIMER_TICKS_PER_SEC)
00077 
00079     typedef uint32_t hptime_t;
00080     #define SIZEOF_HPTIME_T 4
00081 
00082     /* Timer ISR prototype */
00083     ISR_PROTO_CONTEXT_SWITCH(timer_handler);
00084     #define DEFINE_TIMER_ISR DECLARE_ISR_CONTEXT_SWITCH(timer_handler)
00085 
00086     INLINE void timer_hw_irq(void)
00087     {
00088     }
00089 
00090 
00091     INLINE bool timer_hw_triggered(void)
00092     {
00093         return true;
00094     }
00095 
00096     INLINE hptime_t timer_hw_hpread(void)
00097     {
00098         return (TIMER_HW_CNT - NVIC_ST_CURRENT_R);
00099     }
00100 
00101 #else
00102 
00103     #error Unimplemented value for CONFIG_TIMER
00104 #endif /* CONFIG_TIMER */
00105 
00106 void timer_hw_init(void);
00107 void timer_hw_exit(void);
00108 
00109 #endif /* TIMER_CM3_H */