Skip to content

Commit 30a0885

Browse files
committed
rework
1 parent 6c7c974 commit 30a0885

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

libraries/Wire/Wire.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ void arduino::MbedI2C::receiveThd() {
153153
int i = slave->receive();
154154
int c = 0;
155155
int buf_idx = 0;
156+
int available = 0;
156157
switch (i) {
157158
case mbed::I2CSlave::ReadAddressed:
158159
if (onRequestCb != NULL) {
@@ -179,11 +180,10 @@ void arduino::MbedI2C::receiveThd() {
179180
break;
180181
}
181182
}
182-
if (rxBuffer.available() > 0 && onReceiveCb != NULL) {
183-
core_util_critical_section_exit();
184-
onReceiveCb(rxBuffer.available());
185-
} else {
186-
core_util_critical_section_exit();
183+
available = rxBuffer.available();
184+
core_util_critical_section_exit();
185+
if (available > 0 && onReceiveCb != NULL) {
186+
onReceiveCb(available);
187187
}
188188
//slave->stop();
189189
break;

0 commit comments

Comments
 (0)