From e4067dc23558138fd2b7eacf6e4f02e06fbbabb8 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 3 Apr 2016 19:59:48 +0200 Subject: [PATCH] I2C: use avr-libc bus status names. No need to reinvent the wheel. --- i2c.c | 54 +++++++++++++++++++++++++++--------------------------- i2c.h | 30 ------------------------------ 2 files changed, 27 insertions(+), 57 deletions(-) diff --git a/i2c.c b/i2c.c index baaa033..2bd7491 100644 --- a/i2c.c +++ b/i2c.c @@ -26,6 +26,7 @@ #include #include +#include #if defined I2C_MASTER_MODE && defined I2C_SLAVE_MODE @@ -158,14 +159,14 @@ void i2c_do_nothing(void) { */ ISR(TWI_vect) { - switch (TWSR & 0xF8) { // Cut the prescaler bits out. - case I2C_STATE_BUS_FAIL: + switch (TWSR & TW_STATUS_MASK) { + case TW_BUS_ERROR: // A hardware error was detected. i2c_state |= I2C_ERROR_BUS_FAIL; TWCR = (1<