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) {
106
106
sei ();
107
107
}
108
108
#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
+
109
121
// ------------------------------------------------------------------------------
110
122
// send command and return error code. Return zero for OK
111
123
uint8_t Sd2Card::cardCommand (uint8_t cmd, uint32_t arg) {
@@ -430,9 +442,7 @@ uint8_t Sd2Card::readData(uint32_t block,
430
442
spiRec ();
431
443
}
432
444
// transfer data
433
- for (uint16_t i = 0 ; i < count; i++) {
434
- dst[i] = spiRec ();
435
- }
445
+ spiRec (dst, count);
436
446
#endif // OPTIMIZE_HARDWARE_SPI
437
447
438
448
offset_ += count;
@@ -479,7 +489,7 @@ uint8_t Sd2Card::readRegister(uint8_t cmd, void* buf) {
479
489
}
480
490
if (!waitStartBlock ()) goto fail;
481
491
// transfer data
482
- for ( uint16_t i = 0 ; i < 16 ; i++) dst[i] = spiRec ( );
492
+ spiRec ( dst, 16 );
483
493
spiRec (); // get first crc byte
484
494
spiRec (); // get second crc byte
485
495
chipSelectHigh ();
You can’t perform that action at this time.
0 commit comments