CM3: kernel preemption.
[bertos.git] / bertos / cpu / cortex-m3 / drv / timer_lm3s.h
index 53fdd02ffa68f1b82bdfa3ac8a4feb10e35b51ac..3d7c979fcd3a052834833d1eb8f3e6e543f9ed2d 100644 (file)
 #ifndef DRV_CORTEX_M3_TIMER_H
 #define DRV_CORTEX_M3_TIMER_H
 
+#include <io/lm3s.h>
+
+/* 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);