armcm_timer: Support micro-controllers faster than 160Mhz
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
4e5ddff00b
commit
79bd13dba7
|
@ -68,6 +68,25 @@ udelay(uint32_t usecs)
|
|||
;
|
||||
}
|
||||
|
||||
// On fast cpus, schedule a recurring timer so SysTick doesn't overflow
|
||||
static uint_fast8_t
|
||||
timer_wrap_event(struct timer *t)
|
||||
{
|
||||
t->waketime += 0xffffff;
|
||||
return SF_RESCHEDULE;
|
||||
}
|
||||
static struct timer wrap_timer = {
|
||||
.func = timer_wrap_event,
|
||||
.waketime = 0xffffff,
|
||||
};
|
||||
void
|
||||
timer_reset(void)
|
||||
{
|
||||
if (CONFIG_CLOCK_FREQ > 0xffffff * 10)
|
||||
sched_add_timer(&wrap_timer);
|
||||
}
|
||||
DECL_SHUTDOWN(timer_reset);
|
||||
|
||||
void
|
||||
timer_init(void)
|
||||
{
|
||||
|
@ -76,6 +95,9 @@ timer_init(void)
|
|||
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
|
||||
DWT->CYCCNT = 0;
|
||||
|
||||
// Schedule a recurring timer on fast cpus
|
||||
timer_reset();
|
||||
|
||||
// Enable SysTick
|
||||
irqstatus_t flag = irq_save();
|
||||
NVIC_SetPriority(SysTick_IRQn, 2);
|
||||
|
|
Loading…
Reference in New Issue