diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-07-27 12:19:09 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-08-08 00:27:27 -0400 |
commit | 6a63c27542fc7b432ed438ce1d62243b5aebc3da (patch) | |
tree | ddcbb04f33248fdff3153c6fb4ea54711e9840ba /src/pru | |
parent | 62f77f6bc56e0fcffdcdd4dcf2cfd6a7669099f2 (diff) | |
download | kutter-6a63c27542fc7b432ed438ce1d62243b5aebc3da.tar.gz kutter-6a63c27542fc7b432ed438ce1d62243b5aebc3da.tar.xz kutter-6a63c27542fc7b432ed438ce1d62243b5aebc3da.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'src/pru')
-rw-r--r-- | src/pru/main.c | 26 |
1 files changed, 14 insertions, 12 deletions
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) { @@ -87,23 +100,12 @@ irq_poll(void) } 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); |