Skip to content

Commit 6ca4422

Browse files
committed
I2CSlave: restore critical section with temp buffer
1 parent a9991f4 commit 6ca4422

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

libraries/Wire/Wire.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,12 @@ void arduino::MbedI2C::receiveThd() {
158158
onRequestCb();
159159
}
160160
if (usedTxBuffer != 0) {
161-
slave->write((const char *) txBuffer, usedTxBuffer);
161+
core_util_critical_section_enter();
162+
uint8_t tempTxBuffer[usedTxBuffer];
163+
memcpy(tempTxBuffer, txBuffer, sizeof(tempTxBuffer));
162164
usedTxBuffer = 0;
165+
core_util_critical_section_exit();
166+
slave->write((const char *) tempTxBuffer, sizeof(tempTxBuffer));
163167
}
164168
//slave->stop();
165169
break;

0 commit comments

Comments
 (0)