aboutsummaryrefslogtreecommitdiffstats
path: root/libraries
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2014-11-19 22:38:37 -0500
committerbnewbold <bnewbold@robocracy.org>2015-05-27 20:50:14 -0700
commitc21a588f565680d9bc1b22dff1177ca65c1b08e9 (patch)
tree87b53e9e9ced10284707fb6625b89d59b662fa01 /libraries
parent97aa002c9d268c30a13b308e7138ad2c41fde7c6 (diff)
downloadlibrambutan-c21a588f565680d9bc1b22dff1177ca65c1b08e9.tar.gz
librambutan-c21a588f565680d9bc1b22dff1177ca65c1b08e9.zip
Wire: release the bus on error
Diffstat (limited to 'libraries')
-rw-r--r--libraries/Wire/Wire.cpp2
1 files changed, 2 insertions, 0 deletions
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++;