aboutsummaryrefslogtreecommitdiffstats
path: root/src/avr/timer.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-07-27 12:19:09 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-08-08 00:27:27 -0400
commit6a63c27542fc7b432ed438ce1d62243b5aebc3da (patch)
treeddcbb04f33248fdff3153c6fb4ea54711e9840ba /src/avr/timer.c
parent62f77f6bc56e0fcffdcdd4dcf2cfd6a7669099f2 (diff)
downloadkutter-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/timer.c')
-rw-r--r--src/avr/timer.c16
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;