Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5adc40a

Browse filesBrowse files
authored
Merge pull request #1055 from pennam/i2c-slave
I2CSlave: fix slave write regression
2 parents 9db78f9 + 6231980 commit 5adc40a
Copy full SHA for 5adc40a

File tree

1 file changed

+5
-3
lines changed
Filter options

1 file changed

+5
-3
lines changed

‎libraries/Wire/Wire.cpp

Copy file name to clipboardExpand all lines: libraries/Wire/Wire.cpp
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ size_t arduino::MbedI2C::write(const uint8_t* data, int len) {
124124
int arduino::MbedI2C::read() {
125125
int rv = -1;
126126
core_util_critical_section_enter();
127-
128127
if (rxBuffer.available()) {
129128

130129
rv = rxBuffer.read_char();
@@ -160,9 +159,12 @@ void arduino::MbedI2C::receiveThd() {
160159
}
161160
if (usedTxBuffer != 0) {
162161
core_util_critical_section_enter();
163-
slave->write((const char *) txBuffer, usedTxBuffer);
164-
core_util_critical_section_exit();
162+
uint8_t tempTxBuffer[256];
163+
uint8_t usedTempTxBuffer = usedTxBuffer;
164+
memcpy(tempTxBuffer, txBuffer, usedTempTxBuffer);
165165
usedTxBuffer = 0;
166+
core_util_critical_section_exit();
167+
slave->write((const char *) tempTxBuffer, usedTempTxBuffer);
166168
}
167169
//slave->stop();
168170
break;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.