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 /common.h | |
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 'common.h')
-rw-r--r-- | common.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -23,5 +23,27 @@ } \ } +#include <stdbool.h> + +/* global wakeup flag, incremented by functions that interact with the main + * loop (i.e. not pwm) */ +extern volatile uint8_t wakeup; + +/* wakeup sources */ +enum { + WAKE_ACCEL = 0, + WAKE_GYRO = 1, + WAKE_I2C = 2, + WAKE_TIMER = 3, +}; + +#define shouldWakeup(x) (wakeup & (1 << x)) +#define enableWakeup(x) wakeup |= 1 << x; +#include <util/atomic.h> +#define disableWakeup(x) \ + ATOMIC_BLOCK (ATOMIC_FORCEON) { \ + wakeup &= ~(1 << x); \ + } + #endif /* COMMON_H */ |