summaryrefslogtreecommitdiff
path: root/src/arch/blinkenrocket/driver
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-16 09:14:56 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-16 09:14:56 +0200
commit7343085df78d0fabedcdd69b207b2c04962cf98a (patch)
tree33f7e530f45253826512195df82f721d30033c9e /src/arch/blinkenrocket/driver
parent720d72a7dc083835475f6cd3e82a1800d43a6671 (diff)
Blinkenrocket: Configurable I2C speed
Diffstat (limited to 'src/arch/blinkenrocket/driver')
-rw-r--r--src/arch/blinkenrocket/driver/i2c.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/arch/blinkenrocket/driver/i2c.cc b/src/arch/blinkenrocket/driver/i2c.cc
index 487c60e..df275ff 100644
--- a/src/arch/blinkenrocket/driver/i2c.cc
+++ b/src/arch/blinkenrocket/driver/i2c.cc
@@ -3,6 +3,10 @@
#include <avr/io.h>
#include <avr/interrupt.h>
+#ifndef F_I2C
+#define F_I2C 100000UL
+#endif
+
inline void await_twint(unsigned char twcr_values)
{
#if 1
@@ -27,7 +31,7 @@ static signed char i2c_start_read(unsigned char addr)
if (!(TWSR & 0x18)) // 0x08 == START ok, 0x10 == RESTART ok
return -1;
- // Note: An adress with read bit set ("... | 1") causes the TWI momodule
+ // Note: An adress with read bit set ("... | 1") causes the TWI module
// to switch to Master Receive mode
TWDR = (addr << 1) | 1;
await_twint(_BV(TWEN));
@@ -106,7 +110,7 @@ static signed char i2c_receive(uint8_t len, uint8_t *data)
signed char I2C::setup()
{
TWSR = 0;
- TWBR = ((F_CPU / 100000UL) - 16) / 2;
+ TWBR = ((F_CPU / F_I2C) - 16) / 2;
return 0;
}