aboutsummaryrefslogtreecommitdiffstats
path: root/src/sam3x8e/timer.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-03-28 11:25:11 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-03-30 11:25:23 -0400
commiteb4eeb6f7313cbae93f7f996de283e9c28cb16ff (patch)
treed4e0ee02774ce4045237a9f2194d07ade47f8006 /src/sam3x8e/timer.c
parent69885079986c94f3a8e93fb29243976fe89af834 (diff)
downloadkutter-eb4eeb6f7313cbae93f7f996de283e9c28cb16ff.tar.gz
kutter-eb4eeb6f7313cbae93f7f996de283e9c28cb16ff.tar.xz
kutter-eb4eeb6f7313cbae93f7f996de283e9c28cb16ff.zip
timer_irq: Integrate timer_try_set_next() into timer_dispatch_many()
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/sam3x8e/timer.c')
-rw-r--r--src/sam3x8e/timer.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/sam3x8e/timer.c b/src/sam3x8e/timer.c
index d156588a..8548400a 100644
--- a/src/sam3x8e/timer.c
+++ b/src/sam3x8e/timer.c
@@ -11,19 +11,8 @@
#include "sam3x8e.h" // TC0
#include "sched.h" // sched_timer_kick
-// IRQ handler
-void __visible
-TC0_Handler(void)
-{
- irq_disable();
- uint32_t status = TC0->TC_CHANNEL[0].TC_SR; // read to clear irq pending
- if (likely(status & TC_SR_CPAS))
- timer_dispatch_many();
- irq_enable();
-}
-
// Set the next irq time
-void
+static void
timer_set(uint32_t value)
{
TC0->TC_CHANNEL[0].TC_RA = value;
@@ -63,3 +52,16 @@ timer_shutdown(void)
TC0->TC_CHANNEL[0].TC_SR; // read to clear irq pending
}
DECL_SHUTDOWN(timer_shutdown);
+
+// IRQ handler
+void __visible
+TC0_Handler(void)
+{
+ irq_disable();
+ uint32_t status = TC0->TC_CHANNEL[0].TC_SR; // read to clear irq pending
+ if (likely(status & TC_SR_CPAS)) {
+ uint32_t next = timer_dispatch_many();
+ timer_set(next);
+ }
+ irq_enable();
+}