diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-09-23 17:24:57 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-09-30 15:15:01 +0200 |
commit | 6708da2661d693f855b6f56d69af1e2fb8502463 (patch) | |
tree | 5b8eac0f6f40932417519cbdcd229caeabd8eee8 /timer.c | |
parent | 69cb10f51321a2443a3314c40fb2b8556aa804c0 (diff) | |
download | hourglass-6708da2661d693f855b6f56d69af1e2fb8502463.tar.gz hourglass-6708da2661d693f855b6f56d69af1e2fb8502463.tar.bz2 hourglass-6708da2661d693f855b6f56d69af1e2fb8502463.zip |
Add wakeup source mechanism
Should reduce amount of cpu wakeups with expensive computations.
Diffstat (limited to 'timer.c')
-rw-r--r-- | timer.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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; |