File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,18 @@ void spiSend(uint8_t data) {
106106 sei ();
107107}
108108#endif // SOFTWARE_SPI
109+
110+ void spiRec (uint8_t * data, int size) {
111+ #ifdef USE_SPI_LIB
112+ SDCARD_SPI.transfer (data, size);
113+ #else
114+ while (size) {
115+ *data++ = spiRec ();
116+ size--;
117+ }
118+ #endif
119+ }
120+
109121// ------------------------------------------------------------------------------
110122// send command and return error code. Return zero for OK
111123uint8_t Sd2Card::cardCommand (uint8_t cmd, uint32_t arg) {
@@ -430,9 +442,7 @@ uint8_t Sd2Card::readData(uint32_t block,
430442 spiRec ();
431443 }
432444 // transfer data
433- for (uint16_t i = 0 ; i < count; i++) {
434- dst[i] = spiRec ();
435- }
445+ spiRec (dst, count);
436446#endif // OPTIMIZE_HARDWARE_SPI
437447
438448 offset_ += count;
@@ -479,7 +489,7 @@ uint8_t Sd2Card::readRegister(uint8_t cmd, void* buf) {
479489 }
480490 if (!waitStartBlock ()) goto fail;
481491 // transfer data
482- for ( uint16_t i = 0 ; i < 16 ; i++) dst[i] = spiRec ( );
492+ spiRec ( dst, 16 );
483493 spiRec (); // get first crc byte
484494 spiRec (); // get second crc byte
485495 chipSelectHigh ();
You can’t perform that action at this time.
0 commit comments