X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Ftimer_lm3s.c;h=096bff92cbb6c6bc98d6e7c375a1db87b9f14e11;hb=3b1451f6e3161b0f1b16e9be49dd46649b03a9d9;hp=2d6ee89ac554519d29e6a5455a6da83548ee0235;hpb=73a7e9cb144007905b5b9de8e3086423e79b6d71;p=bertos.git diff --git a/bertos/cpu/cortex-m3/drv/timer_lm3s.c b/bertos/cpu/cortex-m3/drv/timer_lm3s.c index 2d6ee89a..096bff92 100644 --- a/bertos/cpu/cortex-m3/drv/timer_lm3s.c +++ b/bertos/cpu/cortex-m3/drv/timer_lm3s.c @@ -37,22 +37,14 @@ #include #include -#include "io/lm3s.h" - -#include "irq_lm3s.h" +#include +#include #include "timer_lm3s.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++; + HWREG(NVIC_ST_RELOAD) = period - 1; } static void timer_hw_enable(void) @@ -68,8 +60,8 @@ static void timer_hw_disable(void) void timer_hw_init(void) { - timer_hw_setPeriod(1000000); - sysirq_setHandler(FAULT_SYSTICK, timer_hw_handler); + timer_hw_setPeriod(CPU_FREQ / TIMER_TICKS_PER_SEC); + sysirq_setHandler(FAULT_SYSTICK, timer_handler); timer_hw_enable(); }