Skip to content

Commit 21646c4

Browse files
committed
Wire: fix read in slave receiving thread
1 parent b86aaa7 commit 21646c4

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

libraries/Wire/Wire.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,10 @@ void arduino::MbedI2C::receiveThd() {
136136
case mbed::I2CSlave::WriteGeneral:
137137
case mbed::I2CSlave::WriteAddressed:
138138
rxBuffer.clear();
139-
char buf[16];
140-
while (1) {
141-
int c = slave->read(buf, sizeof(buf));
142-
for (int i = 0; i < c; i++) {
143-
rxBuffer.store_char(uint8_t(buf[i]));
144-
}
145-
if (c <= sizeof(buf)) {
146-
break;
147-
}
139+
char buf[256];
140+
int c = slave->read(buf, sizeof(buf));
141+
for (int i = 0; i < c; i++) {
142+
rxBuffer.store_char(uint8_t(buf[i]));
148143
}
149144
if (rxBuffer.available() > 0 && onReceiveCb != NULL) {
150145
onReceiveCb(rxBuffer.available());

0 commit comments

Comments
 (0)