From: arighi Date: Fri, 26 Mar 2010 16:12:44 +0000 (+0000) Subject: lm3s1968: low-level timer driver (systick). X-Git-Tag: 2.5.0~624 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=bd4c9a2c047db476ac34649ccf16970ad34343ce;p=bertos.git lm3s1968: low-level timer driver (systick). git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3279 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/cortex-m3/drv/timer.c b/bertos/cpu/cortex-m3/drv/timer.c new file mode 100644 index 00000000..70135694 --- /dev/null +++ b/bertos/cpu/cortex-m3/drv/timer.c @@ -0,0 +1,80 @@ +/** + * \file + * + * + * \brief Low-level timer driver for LM3S1968. + * + * \author Andrea Righi + */ + +#include +#include +#include "io/lm3s.h" + +#include "irq.h" +#include "timer.h" + +unsigned long ticks; + +INLINE void timer_hw_setPeriod(unsigned long period) +{ + ASSERT(period < (1 << 24)); + HWREG(NVIC_ST_RELOAD) = period; +} + +static void timer_hw_handler(void) +{ + ticks++; +} + +static void timer_hw_enable(void) +{ + HWREG(NVIC_ST_CTRL) |= + NVIC_ST_CTRL_CLK_SRC | NVIC_ST_CTRL_ENABLE | NVIC_ST_CTRL_INTEN; +} + +static void timer_hw_disable(void) +{ + HWREG(NVIC_ST_CTRL) &= ~(NVIC_ST_CTRL_ENABLE | NVIC_ST_CTRL_INTEN); +} + +void timer_hw_init(void) +{ + timer_hw_setPeriod(100000); + sysirq_setHandler(FAULT_SYSTICK, timer_hw_handler); + timer_hw_enable(); +} + +void timer_hw_exit(void) +{ + timer_hw_disable(); + sysirq_freeHandler(FAULT_SYSTICK); +} diff --git a/bertos/cpu/cortex-m3/drv/timer.h b/bertos/cpu/cortex-m3/drv/timer.h new file mode 100644 index 00000000..53fdd02f --- /dev/null +++ b/bertos/cpu/cortex-m3/drv/timer.h @@ -0,0 +1,44 @@ +/** + * \file + * + * + * \brief Low-level timer driver for LM3S1968. + * + * \author Andrea Righi + */ + +#ifndef DRV_CORTEX_M3_TIMER_H +#define DRV_CORTEX_M3_TIMER_H + +void timer_hw_init(void); +void timer_hw_exit(void); + +#endif /* DRV_CORTEX_M3_TIMER_H */