diff --git a/i2c.c b/i2c.c index c9acacb..9a03f5d 100644 --- a/i2c.c +++ b/i2c.c @@ -255,17 +255,33 @@ void i2c_write(uint8_t data, uint8_t last_byte) { Bit 0 (TWIE) enables TWI interrupt. */ +//#define TWI_INTERRUPT_DEBUG +#ifdef TWI_INTERRUPT_DEBUG + #include "serial.h" + #include "sendf.h" +#endif ISR(TWI_vect) { + uint8_t status = TWSR & TW_STATUS_MASK; - switch (TWSR & TW_STATUS_MASK) { + #ifdef TWI_INTERRUPT_DEBUG + serial_writechar('.'); + #endif + + switch (status) { case TW_BUS_ERROR: // A hardware error was detected. + #ifdef TWI_INTERRUPT_DEBUG + serial_writechar('1'); + #endif i2c_state |= I2C_ERROR_BUS_FAIL; // Send stop condition. TWCR = (1<