aboutsummaryrefslogtreecommitdiffstats
path: root/libraries
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2014-11-19 22:38:37 -0500
committerbryan newbold <bnewbold@twinleaf.com>2014-11-24 15:18:30 -0800
commit53972f12b69a4979fb2f09d05c6661702eddf952 (patch)
tree071f131e1b099bc0e180da704e8eab8564962cba /libraries
parent4ad3b4e440f72264ceec77d3db6ed9ac6cb331da (diff)
downloadlibrambutan-53972f12b69a4979fb2f09d05c6661702eddf952.tar.gz
librambutan-53972f12b69a4979fb2f09d05c6661702eddf952.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++;