Skip to content

Commit 1afdaa3

Browse files
committed
speedup SPI transaction
From 2.5Mbps to 7Mbps on UNO R4 WiFi
1 parent 5df269e commit 1afdaa3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/microchip/TC6_Io.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace TC6
2525
* CONSTANTS
2626
**************************************************************************************/
2727

28-
static SPISettings const LAN865x_SPI_SETTING{8 * 1000 * 1000UL, MSBFIRST, SPI_MODE0};
28+
static SPISettings const LAN865x_SPI_SETTING{24 * 1000 * 1000UL, MSBFIRST, SPI_MODE0};
2929

3030
/**************************************************************************************
3131
* STATIC MEMBER DEFINITION
@@ -90,8 +90,8 @@ bool TC6_Io::spi_transaction(uint8_t const *pTx, uint8_t *pRx, uint16_t const le
9090
digitalWrite(_cs_pin, LOW);
9191
_spi.beginTransaction(LAN865x_SPI_SETTING);
9292

93-
for (size_t b = 0; b < len; b++)
94-
pRx[b] = _spi.transfer(pTx[b]);
93+
memcpy(pRx, pTx, len);
94+
_spi.transfer(pRx, len);
9595

9696
_spi.endTransaction();
9797
digitalWrite(_cs_pin, HIGH);

0 commit comments

Comments
 (0)