diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2014-04-08 11:28:54 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2014-04-22 16:51:13 +0200 |
commit | 68c180f2aba4471483e1786556c2bc2a94a7d2a7 (patch) | |
tree | 13fd0790193e9e9fe8a745b58cfe34bc108b9b22 /i2c.c | |
parent | e3897565c342bee4765f921240b7ca91cd9b23f1 (diff) | |
download | hourglass-68c180f2aba4471483e1786556c2bc2a94a7d2a7.tar.gz hourglass-68c180f2aba4471483e1786556c2bc2a94a7d2a7.tar.bz2 hourglass-68c180f2aba4471483e1786556c2bc2a94a7d2a7.zip |
Increase CPU and UART speed
Re-enable interrupt based accel.
Diffstat (limited to 'i2c.c')
-rw-r--r-- | i2c.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -3,6 +3,7 @@ #include <avr/interrupt.h> #include "i2c.h" +#include "common.h" volatile twReq twr; @@ -42,9 +43,21 @@ static bool twWriteRaw (const uint8_t data) { } void twInit () { - /* set scl to 3.6 kHz (at 1Mhz CPU speed)*/ +#if F_CPU == 1000000 + /* set scl to 3.6 kHz */ TWBR = 2; TWSR |= 0x3; /* set prescaler to 64 */ +#elif F_CPU == 4000000 + /* set scl to 50 kHz ? */ + TWBR = 32; + TWSR |= 0x0; /* set prescaler to 0 */ +#elif F_CPU == 8000000 + /* set scl to 100 kHz */ + TWBR = 32; + TWSR |= 0x0; /* set prescaler to 0 */ +#else +#error "cpu speed not supported" +#endif twr.mode = TWM_INVALID; twr.status = TWST_ERR; |