From 6a63c27542fc7b432ed438ce1d62243b5aebc3da Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 27 Jul 2017 12:19:09 -0400 Subject: sched: Support adding timers to the start of timer_list If sched_add_timer() is called on a timer that would make it the new head of the list, then add it and signal the board code that the timer should be rescheduled. Signed-off-by: Kevin O'Connor --- src/pru/main.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'src/pru') diff --git a/src/pru/main.c b/src/pru/main.c index 1b54e42a..3c2a2725 100644 --- a/src/pru/main.c +++ b/src/pru/main.c @@ -51,24 +51,37 @@ irq_wait(void) asm("slp 1"); } +// Set the next timer wake up time static void timer_set(uint32_t value) { CT_IEP.TMR_CMP0 = value; } +// Return the next scheduled wake up time uint32_t timer_get_next(void) { return CT_IEP.TMR_CMP0; } +// Return the current time (in absolute clock ticks). uint32_t timer_read_time(void) { return CT_IEP.TMR_CNT; } +// Activate timer dispatch as soon as possible +void +timer_kick(void) +{ + timer_set(timer_read_time() + 50); + CT_IEP.TMR_CMP_STS = 0xff; + __delay_cycles(4); + CT_INTC.SECR0 = 1 << IEP_EVENT; +} + static void _irq_poll(void) { @@ -86,24 +99,13 @@ irq_poll(void) _irq_poll(); } -void -timer_shutdown(void) -{ - // Reenable timer irq - timer_set(timer_read_time() + 50); - CT_IEP.TMR_CMP_STS = 0xff; - __delay_cycles(4); - CT_INTC.SECR0 = 1 << IEP_EVENT; -} -DECL_SHUTDOWN(timer_shutdown); - void timer_init(void) { CT_IEP.TMR_CMP_CFG = 0x01 << 1; CT_IEP.TMR_GLB_CFG = 0x11; CT_IEP.TMR_CNT = 0; - timer_shutdown(); + timer_kick(); } DECL_INIT(timer_init); -- cgit v1.2.3-70-g09d2