From: arighi Date: Wed, 14 Apr 2010 10:47:27 +0000 (+0000) Subject: CM3: generic timer (Systick) driver implementation. X-Git-Tag: 2.5.0~473 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=476b69eb75e5eca105bb4b3474df19e6cfdbed68;p=bertos.git CM3: generic timer (Systick) driver implementation. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3435 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/cpu/cortex-m3/drv/timer_cm3.c b/bertos/cpu/cortex-m3/drv/timer_cm3.c new file mode 100644 index 00000000..a4d96689 --- /dev/null +++ b/bertos/cpu/cortex-m3/drv/timer_cm3.c @@ -0,0 +1,71 @@ +/** + * \file + * + * + * \brief Low-level timer driver (SysTick) for LM3S1968. + * + * \author Andrea Righi + */ + +#include +#include +#include +#include "timer_cm3.h" + +INLINE void timer_hw_setPeriod(unsigned long period) +{ + ASSERT(period < (1 << 24)); + HWREG(NVIC_ST_RELOAD) = period - 1; +} + +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(CPU_FREQ / TIMER_TICKS_PER_SEC); + sysirq_setHandler(FAULT_SYSTICK, timer_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_cm3.h b/bertos/cpu/cortex-m3/drv/timer_cm3.h index 0418a45b..6cfaf8cf 100644 --- a/bertos/cpu/cortex-m3/drv/timer_cm3.h +++ b/bertos/cpu/cortex-m3/drv/timer_cm3.h @@ -30,9 +30,9 @@ * * --> * - * \author Francesco Sacchi + * \author Andrea Righi * - * \brief Low-level timer module for Cortex-M3 (interface). + * \brief Low-level timer driver (SysTick) for Cortex-M3. */ #include diff --git a/bertos/cpu/cortex-m3/drv/timer_lm3s.c b/bertos/cpu/cortex-m3/drv/timer_lm3s.c deleted file mode 100644 index 49b9fa8e..00000000 --- a/bertos/cpu/cortex-m3/drv/timer_lm3s.c +++ /dev/null @@ -1,72 +0,0 @@ -/** - * \file - * - * - * \brief Low-level timer driver for LM3S1968. - * - * \author Andrea Righi - */ - -#include -#include -#include -#include -#include "timer_lm3s.h" - -INLINE void timer_hw_setPeriod(unsigned long period) -{ - ASSERT(period < (1 << 24)); - HWREG(NVIC_ST_RELOAD) = period - 1; -} - -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(CPU_FREQ / TIMER_TICKS_PER_SEC); - sysirq_setHandler(FAULT_SYSTICK, timer_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_lm3s.h b/bertos/cpu/cortex-m3/drv/timer_lm3s.h index 3d7c979f..00c532f2 100644 --- a/bertos/cpu/cortex-m3/drv/timer_lm3s.h +++ b/bertos/cpu/cortex-m3/drv/timer_lm3s.h @@ -30,7 +30,7 @@ * * --> * - * \brief Low-level timer driver for LM3S1968. + * \brief Low-level timer driver (SysTick) for LM3S1968. * * \author Andrea Righi */ diff --git a/examples/lm3s1968/lm3s1968.mk b/examples/lm3s1968/lm3s1968.mk index 475bdb47..4d71d0da 100644 --- a/examples/lm3s1968/lm3s1968.mk +++ b/examples/lm3s1968/lm3s1968.mk @@ -43,11 +43,11 @@ lm3s1968_CSRC = \ bertos/kern/preempt.c \ bertos/kern/signal.c \ bertos/cpu/cortex-m3/drv/gpio_lm3s.c \ - bertos/cpu/cortex-m3/drv/timer_lm3s.c \ bertos/cpu/cortex-m3/drv/clock_lm3s.c \ bertos/cpu/cortex-m3/drv/ser_lm3s.c \ bertos/cpu/cortex-m3/drv/kdebug_lm3s.c \ bertos/cpu/cortex-m3/drv/ssi_lm3s.c \ + bertos/cpu/cortex-m3/drv/timer_cm3.c \ bertos/cpu/cortex-m3/drv/irq_cm3.c \ bertos/cpu/cortex-m3/hw/switch_ctx_cm3.c \ bertos/cpu/cortex-m3/hw/init_lm3s.c @@ -70,7 +70,7 @@ lm3s1968_PROGRAMMER_CPU = lm3s1968 lm3s1968_PROGRAMMER_TYPE = lm3s1968 lm3s1968_FLASH_SCRIPT = bertos/prg_scripts/arm/flash-cortex.sh lm3s1968_STOPFLASH_SCRIPT = bertos/prg_scripts/arm/stopopenocd.sh -lm3s1968_DEBUG_SCRIPT = bertos/prg_scripts/arm/debug.sh +lm3s1968_DEBUG_SCRIPT = bertos/prg_scripts/arm/debug-cortex.sh lm3s1968_STOPDEBUG_SCRIPT = bertos/prg_scripts/arm/stopopenocd.sh ifeq ($(lm3s1968_DEBUG),0)