Skip to content

Commit 3c556e6

Browse files
fixed: Wire::writeReadAsync not setting _dmaSendBufferLen, therefore allocating the DMA buffer anew on every call (earlephilhower#2796)
Co-authored-by: Stefan Nuernberger <[email protected]>
1 parent 5e2fbf3 commit 3c556e6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libraries/Wire/src/Wire.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ bool TwoWire::writeReadAsync(uint8_t address, const void *wbuffer, size_t wbytes
507507
abortAsync();
508508

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

523524
// Fill the dma command buffer

0 commit comments

Comments
 (0)