From ed0c9e21d5351d60074a58da6dafc52a7ebb7e35 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 9 Aug 2018 10:54:38 +0200 Subject: blinkenrocket i2c: Add optional no-interrupt I2C --- src/arch/blinkenrocket/driver/i2c.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/arch/blinkenrocket') diff --git a/src/arch/blinkenrocket/driver/i2c.cc b/src/arch/blinkenrocket/driver/i2c.cc index cfbea59..8979fbb 100644 --- a/src/arch/blinkenrocket/driver/i2c.cc +++ b/src/arch/blinkenrocket/driver/i2c.cc @@ -5,10 +5,16 @@ inline void await_twint(unsigned char twcr_values) { +#if 1 TWCR = twcr_values | _BV(TWINT) | _BV(TWIE); while (!(TWCR & _BV(TWINT))) { arch.idle(); } +#endif +#if 0 + TWCR = twcr_values | _BV(TWINT); + while (!(TWCR & _BV(TWINT))) ; +#endif } /* @@ -21,8 +27,8 @@ static signed char i2c_start_read(unsigned char addr) if (!(TWSR & 0x18)) // 0x08 == START ok, 0x10 == RESTART ok return -1; - // Note: The R byte ("... | 1") causes the TWI momodule to switch to - // Master Receive mode + // Note: An adress with read bit set ("... | 1") causes the TWI momodule + // to switch to Master Receive mode TWDR = (addr << 1) | 1; await_twint(_BV(TWEN)); if (TWSR != 0x40) // 0x40 == SLA+R transmitted, ACK receveid @@ -55,6 +61,7 @@ static signed char i2c_start_write(unsigned char addr) static signed char i2c_stop() { TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); + return 0; } /* -- cgit v1.2.3