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/avr | |
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/avr')
-rw-r--r-- | src/avr/timer.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/avr/timer.c b/src/avr/timer.c index e32a0b42..a87ae206 100644 --- a/src/avr/timer.c +++ b/src/avr/timer.c @@ -1,6 +1,6 @@ // AVR timer interrupt scheduling code. // -// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net> +// Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net> // // This file may be distributed under the terms of the GNU GPLv3 license. @@ -10,7 +10,7 @@ #include "board/misc.h" // timer_from_us #include "command.h" // shutdown #include "irq.h" // irq_save -#include "sched.h" // sched_timer_kick +#include "sched.h" // sched_timer_dispatch /**************************************************************** @@ -77,16 +77,13 @@ timer_repeat_set(uint16_t next) TIFR1 = 1<<OCF1B; } -// Reset the timer - clear settings and dispatch next timer immediately +// Activate timer dispatch as soon as possible void -timer_reset(void) +timer_kick(void) { - uint16_t now = timer_get(); - timer_set(now + 50); + timer_set(timer_get() + 50); TIFR1 = 1<<OCF1A; - timer_repeat_set(now + 50); } -DECL_SHUTDOWN(timer_reset); void timer_init(void) @@ -97,7 +94,8 @@ timer_init(void) TCCR1B = 1<<CS10; // Setup for first irq irqstatus_t flag = irq_save(); - timer_reset(); + timer_kick(); + timer_repeat_set(timer_get() + 50); TIFR1 = 1<<TOV1; // enable interrupt TIMSK1 = 1<<OCIE1A; |