Skip to content

Commit 2d0bedc

Browse files
committed
- sped up transfer(buf, rxbuf, count) a little by making it use direct byte transfers and not calling transfer(data)
1 parent 8c6c694 commit 2d0bedc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libraries/SPI/SPI.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ void ArduinoSPI::transfer(void *buf, void *rxbuf, size_t count)
386386
uint8_t *rx = (uint8_t *) rxbuf;
387387
const uint8_t* tx = (const uint8_t *) buf;
388388
for (size_t i = 4U * n32; i < count; i++) {
389-
uint8_t tmp = transfer((buf) ? tx[i] : 0xFF);
389+
_spi_ctrl.p_regs->SPDR_BY = (buf) ? tx[i] : 0xFF;
390+
while (0U == _spi_ctrl.p_regs->SPSR_b.SPRF) {}
391+
uint8_t tmp = _spi_ctrl.p_regs->SPDR_BY;
390392
if (rxbuf) {
391393
rx[i] = tmp;
392394
}
@@ -395,7 +397,6 @@ void ArduinoSPI::transfer(void *buf, void *rxbuf, size_t count)
395397
}
396398
}
397399

398-
399400
void ArduinoSPI::beginTransaction(arduino::SPISettings settings)
400401
{
401402
if (!_is_initialized)

0 commit comments

Comments
 (0)