Loading src/arch/blinkenrocket/Makefile.inc +4 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,10 @@ else ifneq ($(findstring i2c,${arch_drivers}), ) TARGETS += src/arch/blinkenrocket/driver/i2c.cc endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif OBJECTS = ${TARGETS:.cc=.o} .cc.o: Loading src/arch/blinkenrocket/driver/i2c.cc +6 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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)); Loading Loading @@ -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; } Loading Loading
src/arch/blinkenrocket/Makefile.inc +4 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,10 @@ else ifneq ($(findstring i2c,${arch_drivers}), ) TARGETS += src/arch/blinkenrocket/driver/i2c.cc endif ifneq (${i2c_freq}, ) COMMON_FLAGS += -DF_I2C=${i2c_freq} endif OBJECTS = ${TARGETS:.cc=.o} .cc.o: Loading
src/arch/blinkenrocket/driver/i2c.cc +6 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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)); Loading Loading @@ -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; } Loading