23
23
// ------------------------------------------------------------------------------
24
24
#ifndef SOFTWARE_SPI
25
25
#ifdef USE_SPI_LIB
26
+
27
+ #ifndef SDCARD_SPI
28
+ #define SDCARD_SPI SPI
29
+ #endif
30
+
26
31
#include < SPI.h>
27
32
static SPISettings settings;
28
33
#endif
@@ -34,7 +39,7 @@ static void spiSend(uint8_t b) {
34
39
while (!(SPSR & (1 << SPIF)))
35
40
;
36
41
#else
37
- SPI .transfer (b);
42
+ SDCARD_SPI .transfer (b);
38
43
#endif
39
44
}
40
45
/* * Receive a byte from the card */
@@ -43,7 +48,7 @@ static uint8_t spiRec(void) {
43
48
spiSend (0XFF );
44
49
return SPDR;
45
50
#else
46
- return SPI .transfer (0xFF );
51
+ return SDCARD_SPI .transfer (0xFF );
47
52
#endif
48
53
}
49
54
#else // SOFTWARE_SPI
@@ -164,7 +169,7 @@ void Sd2Card::chipSelectHigh(void) {
164
169
#ifdef USE_SPI_LIB
165
170
if (chip_select_asserted) {
166
171
chip_select_asserted = 0 ;
167
- SPI .endTransaction ();
172
+ SDCARD_SPI .endTransaction ();
168
173
}
169
174
#endif
170
175
}
@@ -173,7 +178,7 @@ void Sd2Card::chipSelectLow(void) {
173
178
#ifdef USE_SPI_LIB
174
179
if (!chip_select_asserted) {
175
180
chip_select_asserted = 1 ;
176
- SPI .beginTransaction (settings);
181
+ SDCARD_SPI .beginTransaction (settings);
177
182
}
178
183
#endif
179
184
digitalWrite (chipSelectPin_, LOW);
@@ -265,18 +270,18 @@ uint8_t Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
265
270
// clear double speed
266
271
SPSR &= ~(1 << SPI2X);
267
272
#else // USE_SPI_LIB
268
- SPI .begin ();
273
+ SDCARD_SPI .begin ();
269
274
settings = SPISettings (250000 , MSBFIRST, SPI_MODE0);
270
275
#endif // USE_SPI_LIB
271
276
#endif // SOFTWARE_SPI
272
277
273
278
// must supply min of 74 clock cycles with CS high.
274
279
#ifdef USE_SPI_LIB
275
- SPI .beginTransaction (settings);
280
+ SDCARD_SPI .beginTransaction (settings);
276
281
#endif
277
282
for (uint8_t i = 0 ; i < 10 ; i++) spiSend (0XFF );
278
283
#ifdef USE_SPI_LIB
279
- SPI .endTransaction ();
284
+ SDCARD_SPI .endTransaction ();
280
285
#endif
281
286
282
287
chipSelectLow ();
0 commit comments