Skip to content

Commit 8ab666b

Browse files
authored
Update SD.cpp
line 357, remove card.setSpiClock(clock) in function SDClass::begin(uint32_t clock, uint8_t csPin) when SOFTWARE_SPI is defined
1 parent 6c43462 commit 8ab666b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/SD.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ namespace SDLib {
354354
volume.init(card) &&
355355
root.openRoot(volume);
356356
}
357-
357+
#ifndef SOFTWARE_SPI //Added compiler directive so that MEGA works with this code
358358
bool SDClass::begin(uint32_t clock, uint8_t csPin) {
359359
if (root.isOpen()) {
360360
root.close();
@@ -365,7 +365,19 @@ namespace SDLib {
365365
volume.init(card) &&
366366
root.openRoot(volume);
367367
}
368+
#else
369+
bool SDClass::begin(uint32_t clock, uint8_t csPin) {
370+
if (root.isOpen()) {
371+
root.close();
372+
}
368373

374+
return card.init(SPI_HALF_SPEED, csPin) &&
375+
card.setSpiClock(clock) &&
376+
volume.init(card) &&
377+
root.openRoot(volume);
378+
}
379+
#endif  //SOFTWARE_SPI
380+
369381
//call this when a card is removed. It will allow you to insert and initialise a new card.
370382
void SDClass::end() {
371383
root.close();

0 commit comments

Comments
 (0)