From 061225f72d8dcb545cf12938f6280dad633a654b Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 3 Apr 2016 21:08:18 +0200 Subject: [PATCH] I2C: get rid of these unimplemented error handlers. Naively restarting I2C immediately is certainly not the solution and just leads to an interrupt flood. As I2C is currently meant to drive displays, where successful data transmission isn't crucial, we now simply stop transmission on errors. This saves another 80 bytes binary size: FLASH : 23094 bytes RAM : 2051 bytes EEPROM : 32 bytes --- i2c.c | 53 +++++++++++++++-------------------------------------- i2c.h | 19 +------------------ mendel.c | 2 +- 3 files changed, 17 insertions(+), 57 deletions(-) diff --git a/i2c.c b/i2c.c index 133ff97..ea08c04 100644 --- a/i2c.c +++ b/i2c.c @@ -59,12 +59,8 @@ uint8_t i2c_byte_count; uint8_t *i2c_buffer; #endif /* I2C_SLAVE_MODE */ -I2C_HANDLER i2c_master_func = &i2c_do_nothing; -I2C_HANDLER i2c_slave_func = &i2c_do_nothing; -I2C_HANDLER i2c_error_func = &i2c_do_nothing; - -void i2c_init(uint8_t address, I2C_HANDLER func) { +void i2c_init(uint8_t address) { i2c_address = address; @@ -74,8 +70,6 @@ void i2c_init(uint8_t address, I2C_HANDLER func) { I2C_PORT |= (1 << I2C_SCL_PIN) | (1 << I2C_SDA_PIN); #endif /* I2C_ENABLE_PULLUPS */ - i2c_master_func = func; - /** TWI Bit Rate register SCL_freq = CPU_freq / (16 + 2 * TWBR) @@ -92,7 +86,6 @@ void i2c_init(uint8_t address, I2C_HANDLER func) { #endif /* I2C_MASTER_MODE */ #ifdef I2C_SLAVE_MODE - i2c_slave_func = func; TWAR = i2c_address; // We listen to broadcasts if lowest bit is set. TWCR = (0<