From 68c180f2aba4471483e1786556c2bc2a94a7d2a7 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Tue, 8 Apr 2014 11:28:54 +0200 Subject: Increase CPU and UART speed Re-enable interrupt based accel. --- i2c.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'i2c.c') diff --git a/i2c.c b/i2c.c index 57ee551..7855e88 100644 --- a/i2c.c +++ b/i2c.c @@ -3,6 +3,7 @@ #include #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; -- cgit v1.2.3