summaryrefslogtreecommitdiff
path: root/src/arch/arduino-nano/driver
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-16 12:58:24 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-16 12:58:24 +0200
commitf6972a43581b24281b322a6f8d2bf02dafbe4433 (patch)
tree7ab50ae57739d8df9cc4a898b80c8b5c4ba9ceee /src/arch/arduino-nano/driver
parent7343085df78d0fabedcdd69b207b2c04962cf98a (diff)
configurable i2c bitrate on arduino nano
Diffstat (limited to 'src/arch/arduino-nano/driver')
-rw-r--r--src/arch/arduino-nano/driver/i2c.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/arch/arduino-nano/driver/i2c.cc b/src/arch/arduino-nano/driver/i2c.cc
index cfbea59..0a2f595 100644
--- a/src/arch/arduino-nano/driver/i2c.cc
+++ b/src/arch/arduino-nano/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)
{
TWCR = twcr_values | _BV(TWINT) | _BV(TWIE);
@@ -99,7 +103,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;
}