From 61ab29e6b6a63bdbbf2b70ea00b4e52e94a6f2de Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 3 Apr 2016 22:23:20 +0200 Subject: [PATCH] I2C: no need to initialise with an address in master mode. --- i2c.c | 10 ++++++++-- mendel.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/i2c.c b/i2c.c index 234752d..b5ff2f3 100644 --- a/i2c.c +++ b/i2c.c @@ -89,9 +89,14 @@ uint8_t i2c_byte_count; #endif /* I2C_SLAVE_MODE */ -void i2c_init(uint8_t address) { +/** + Inititalise the I2C/TWI subsystem. - i2c_address = address; + \param address Address the system should listen to in slave mode, unused + when configured for master mode. In master mode, receiver + address is given to the send command. +*/ +void i2c_init(uint8_t address) { #ifdef I2C_MASTER_MODE #ifdef I2C_ENABLE_PULLUPS @@ -117,6 +122,7 @@ void i2c_init(uint8_t address) { #endif /* I2C_MASTER_MODE */ #ifdef I2C_SLAVE_MODE + i2c_address = address; TWAR = i2c_address; // We listen to broadcasts if lowest bit is set. TWCR = (0<