From 6708da2661d693f855b6f56d69af1e2fb8502463 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 23 Sep 2014 17:24:57 +0200 Subject: Add wakeup source mechanism Should reduce amount of cpu wakeups with expensive computations. --- timer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'timer.c') diff --git a/timer.c b/timer.c index ce30b60..8de6157 100644 --- a/timer.c +++ b/timer.c @@ -22,13 +22,17 @@ ISR(TIMER1_COMPA_vect) { time += OCR1A * US_PER_TICK; if (hits == maxhits-1) { OCR1A = lastcount; + } else if (hits >= maxhits) { + enableWakeup (WAKE_TIMER); } } /* Check if timer was hit, return time since last restart or 0 if not hit yet */ uint32_t timerHit () { - if (hits >= maxhits) { + if (shouldWakeup (WAKE_TIMER)) { + disableWakeup (WAKE_TIMER); + const uint32_t ret = time; /* reset timer, start again */ hits = 0; -- cgit v1.2.3