File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,6 @@ size_t arduino::MbedI2C::write(const uint8_t* data, int len) {
124
124
int arduino::MbedI2C::read () {
125
125
int rv = -1 ;
126
126
core_util_critical_section_enter ();
127
-
128
127
if (rxBuffer.available ()) {
129
128
130
129
rv = rxBuffer.read_char ();
@@ -160,9 +159,12 @@ void arduino::MbedI2C::receiveThd() {
160
159
}
161
160
if (usedTxBuffer != 0 ) {
162
161
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);
165
165
usedTxBuffer = 0 ;
166
+ core_util_critical_section_exit ();
167
+ slave->write ((const char *) tempTxBuffer, usedTempTxBuffer);
166
168
}
167
169
// slave->stop();
168
170
break ;
You can’t perform that action at this time.
0 commit comments