aboutsummaryrefslogtreecommitdiff
path: root/common.h
diff options
context:
space:
mode:
Diffstat (limited to 'common.h')
-rw-r--r--common.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/common.h b/common.h
index 5957da3..fb53d4d 100644
--- a/common.h
+++ b/common.h
@@ -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 */