From 53972f12b69a4979fb2f09d05c6661702eddf952 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Wed, 19 Nov 2014 22:38:37 -0500 Subject: Wire: release the bus on error --- libraries/Wire/Wire.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'libraries') diff --git a/libraries/Wire/Wire.cpp b/libraries/Wire/Wire.cpp index d646132..b08023d 100644 --- a/libraries/Wire/Wire.cpp +++ b/libraries/Wire/Wire.cpp @@ -128,6 +128,7 @@ uint8 TwoWire::process() { // shift out the address we're transmitting to i2c_shift_out(sla_addr); if (!i2c_get_ack()) { + i2c_stop(); // Fix up the state of the bus return ENACKADDR; } // Recieving @@ -146,6 +147,7 @@ uint8 TwoWire::process() { for (uint8 i = 0; i < itc_msg.length; i++) { i2c_shift_out(itc_msg.data[i]); if (!i2c_get_ack()) { + i2c_stop(); // Fix up the state of the bus return ENACKTRNS; } itc_msg.xferred++; -- cgit v1.2.3