aboutsummaryrefslogtreecommitdiff
path: root/accel.c
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-02-10 12:33:58 +0100
committerLars-Dominik Braun <lars@6xq.net>2015-02-10 12:33:58 +0100
commit92ec11b505a5b68c33e6158dbc68cea1d23cbd35 (patch)
tree737a0ac5a0574388d515ae15923e104c5b0e10f2 /accel.c
parent708e9eb417ddf41ec345f2be70c4a32721608e4c (diff)
downloadhourglass-92ec11b505a5b68c33e6158dbc68cea1d23cbd35.tar.gz
hourglass-92ec11b505a5b68c33e6158dbc68cea1d23cbd35.tar.bz2
hourglass-92ec11b505a5b68c33e6158dbc68cea1d23cbd35.zip
Reduce CPU frequency
Also reduces PWM frequency. The speakers resonance frequency is 2kHz, with 1MHz clock speed and prescaler 256 we get pretty close.
Diffstat (limited to 'accel.c')
-rw-r--r--accel.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/accel.c b/accel.c
index 9f38e8e..77126d4 100644
--- a/accel.c
+++ b/accel.c
@@ -163,22 +163,20 @@ bool accelProcess () {
if (reading && shouldWakeup (WAKE_I2C)) {
disableWakeup (WAKE_I2C);
reading = false;
- if (twr.status == TWST_OK) {
- accelProcessHorizon ();
-
- /* calculate normalized z (i.e. without earth gravity component) */
- if (horizonSign == HORIZON_NEG) {
- zvalnormal = zval - (-ACCEL_1G);
- } else if (horizonSign == HORIZON_POS) {
- zvalnormal = zval - ACCEL_1G;
- }
-
- accelProcessShake ();
- /* new data transfered */
- return true;
- } else if (twr.status == TWST_ERR) {
- assert (0);
+ /* the bus might be in use again already */
+ //assert (twr.status == TWST_OK);
+ accelProcessHorizon ();
+
+ /* calculate normalized z (i.e. without earth gravity component) */
+ if (horizonSign == HORIZON_NEG) {
+ zvalnormal = zval - (-ACCEL_1G);
+ } else if (horizonSign == HORIZON_POS) {
+ zvalnormal = zval - ACCEL_1G;
}
+
+ accelProcessShake ();
+ /* new data transfered */
+ return true;
} else {
if (shouldWakeup (WAKE_ACCEL) && twr.status == TWST_OK) {
/* new data available in device buffer and bus is free */