Skip to content

Commit

Permalink
fixed: Wire::writeReadAsync not setting _dmaSendBufferLen, therefore …
Browse files Browse the repository at this point in the history
…allocating the DMA buffer anew on every call
  • Loading branch information
stefan-veecle committed Feb 8, 2025
1 parent 5e2fbf3 commit be82407
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ bool TwoWire::writeReadAsync(uint8_t address, const void *wbuffer, size_t wbytes
abortAsync();

// Create or enlarge dma command buffer, we need one entry for every i2c byte we want to write/read
const size_t bufLen = (wbytes + rbytes) * 2;
const size_t bufLen = (wbytes + rbytes) * sizeof(uint16_t);
if (_dmaSendBufferLen < bufLen) {
if (_dmaSendBuffer) {
free(_dmaSendBuffer);
Expand All @@ -518,6 +518,7 @@ bool TwoWire::writeReadAsync(uint8_t address, const void *wbuffer, size_t wbytes
if (!_dmaSendBuffer) {
return false;
}
_dmaSendBufferLen = bufLen;
}

// Fill the dma command buffer
Expand Down

0 comments on commit be82407

Please sign in to comment.