X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fcpu%2Fcortex-m3%2Fdrv%2Ftimer_lm3s.c;h=ed432e9f6e7b1ef4fa42464997b50159a9d910e2;hb=5b8c7d324c8934f7686aeb4c23454cebbfd1f83f;hp=2d6ee89ac554519d29e6a5455a6da83548ee0235;hpb=bcc49085f310cc8f30075b0f8577767f1668c860;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..ed432e9f 100644 --- a/bertos/cpu/cortex-m3/drv/timer_lm3s.c +++ b/bertos/cpu/cortex-m3/drv/timer_lm3s.c @@ -42,17 +42,12 @@ #include "irq_lm3s.h" #include "timer_lm3s.h" -unsigned long ticks; +ISR_PROTO_CONTEXT_SWITCH(timer_handler); 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 +63,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(); }