File tree Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Expand file tree Collapse file tree 4 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -347,7 +347,12 @@ boolean SDClass::begin(uint8_t csPin) {
347
347
root.openRoot (volume);
348
348
}
349
349
350
-
350
+ boolean SDClass::begin (uint32_t clock, uint8_t csPin) {
351
+ return card.init (SPI_HALF_SPEED, csPin) &&
352
+ card.setSpiClock (clock) &&
353
+ volume.init (card) &&
354
+ root.openRoot (volume);
355
+ }
351
356
352
357
// this little helper is used to traverse paths
353
358
SdFile SDClass::getParentDir (const char *filepath, int *index) {
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ class SDClass {
68
68
// This needs to be called to set up the connection to the SD card
69
69
// before other methods are used.
70
70
boolean begin (uint8_t csPin = SD_CHIP_SELECT_PIN);
71
+ boolean begin (uint32_t clock, uint8_t csPin);
71
72
72
73
// Open the specified file/directory with the supplied mode (e.g. read or
73
74
// write, etc). Returns a File object for interacting with the file.
Original file line number Diff line number Diff line change @@ -540,6 +540,15 @@ uint8_t Sd2Card::setSckRate(uint8_t sckRateID) {
540
540
#endif // USE_SPI_LIB
541
541
return true ;
542
542
}
543
+ #ifdef USE_SPI_LIB
544
+ // ------------------------------------------------------------------------------
545
+ // set the SPI clock frequency
546
+ uint8_t Sd2Card::setSpiClock (uint32_t clock)
547
+ {
548
+ settings = SPISettings (clock, MSBFIRST, SPI_MODE0);
549
+ return true ;
550
+ }
551
+ #endif
543
552
// ------------------------------------------------------------------------------
544
553
// wait for card to go not busy
545
554
uint8_t Sd2Card::waitNotBusy (uint16_t timeoutMillis) {
Original file line number Diff line number Diff line change @@ -223,6 +223,9 @@ class Sd2Card {
223
223
}
224
224
void readEnd (void );
225
225
uint8_t setSckRate (uint8_t sckRateID);
226
+ #ifdef USE_SPI_LIB
227
+ uint8_t setSpiClock (uint32_t clock);
228
+ #endif
226
229
/* * Return the card type: SD V1, SD V2 or SDHC */
227
230
uint8_t type (void ) const {return type_;}
228
231
uint8_t writeBlock (uint32_t blockNumber, const uint8_t * src);
You can’t perform that action at this time.
0 commit comments