Skip to content

Commit 40bffe3

Browse files
author
Marti Bolivar
committed
Wire: release the bus on error
1 parent df44924 commit 40bffe3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libraries/Wire/Wire.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ uint8 TwoWire::process() {
128128
// shift out the address we're transmitting to
129129
i2c_shift_out(sla_addr);
130130
if (!i2c_get_ack()) {
131+
i2c_stop(); // Fix up the state of the bus
131132
return ENACKADDR;
132133
}
133134
// Recieving
@@ -146,6 +147,7 @@ uint8 TwoWire::process() {
146147
for (uint8 i = 0; i < itc_msg.length; i++) {
147148
i2c_shift_out(itc_msg.data[i]);
148149
if (!i2c_get_ack()) {
150+
i2c_stop(); // Fix up the state of the bus
149151
return ENACKTRNS;
150152
}
151153
itc_msg.xferred++;

0 commit comments

Comments
 (0)