Skip to content

Commit

Permalink
Wire: release the bus on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Marti Bolivar committed Nov 20, 2014
1 parent df44924 commit 40bffe3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/Wire/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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++;
Expand Down

0 comments on commit 40bffe3

Please sign in to comment.