Unverified Commit 4d2f64a1 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

Add bidirectional bulk SPI transfer, update SdFAT (#819)

Should speed up SD transfers significantly (2.5x+).

See #801
parent 9997461e
......@@ -110,6 +110,19 @@ class HardwareSPI
virtual uint16_t transfer16(uint16_t data) = 0;
virtual void transfer(void *buf, size_t count) = 0;
// New transfer API. If either send or recv == nullptr then ignore it
virtual void transfer(const void *send, void *recv, size_t count) {
const uint8_t *out = (const uint8_t *)send;
uint8_t *in = (uint8_t *)recv;
for (size_t i = 0; i < count; i++) {
uint8_t t = out ? *(out++) : 0xff;
t = transfer(t);
if (in) {
*(in++) = t;
}
}
}
// Transaction Functions
virtual void usingInterrupt(int interruptNumber) = 0;
virtual void notUsingInterrupt(int interruptNumber) = 0;
......
Subproject commit 43a65b42d5a827092188cfe11fb27237da252692
Subproject commit 255180be140d252605f28667078201fba588b968
......@@ -141,13 +141,13 @@ void SPIClassRP2040::transfer(void *buf, size_t count) {
DEBUGSPI("SPI::transfer completed\n");
}
void SPIClassRP2040::transfer(void *txbuf, void *rxbuf, size_t count) {
void SPIClassRP2040::transfer(const void *txbuf, void *rxbuf, size_t count) {
if (!_initted) {
return;
}
DEBUGSPI("SPI::transfer(%p, %p, %d)\n", txbuf, rxbuf, count);
uint8_t *txbuff = reinterpret_cast<uint8_t *>(txbuf);
const uint8_t *txbuff = reinterpret_cast<const uint8_t *>(txbuf);
uint8_t *rxbuff = reinterpret_cast<uint8_t *>(rxbuf);
// MSB version is easy!
......
......@@ -36,7 +36,7 @@ public:
void transfer(void *buf, size_t count) override;
// Sends one buffer and receives into another, much faster! can set rx or txbuf to NULL
void transfer(void *txbuf, void *rxbuf, size_t count);
void transfer(const void *txbuf, void *rxbuf, size_t count) override;
// Call before/after every complete transaction
void beginTransaction(SPISettings settings) override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment