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) {
347347 root.openRoot (volume);
348348}
349349
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+ }
351356
352357// this little helper is used to traverse paths
353358SdFile SDClass::getParentDir (const char *filepath, int *index) {
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ class SDClass {
6868 // This needs to be called to set up the connection to the SD card
6969 // before other methods are used.
7070 boolean begin (uint8_t csPin = SD_CHIP_SELECT_PIN);
71+ boolean begin (uint32_t clock, uint8_t csPin);
7172
7273 // Open the specified file/directory with the supplied mode (e.g. read or
7374 // 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) {
540540#endif // USE_SPI_LIB
541541 return true ;
542542}
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
543552// ------------------------------------------------------------------------------
544553// wait for card to go not busy
545554uint8_t Sd2Card::waitNotBusy (uint16_t timeoutMillis) {
Original file line number Diff line number Diff line change @@ -223,6 +223,9 @@ class Sd2Card {
223223 }
224224 void readEnd (void );
225225 uint8_t setSckRate (uint8_t sckRateID);
226+ #ifdef USE_SPI_LIB
227+ uint8_t setSpiClock (uint32_t clock);
228+ #endif
226229 /* * Return the card type: SD V1, SD V2 or SDHC */
227230 uint8_t type (void ) const {return type_;}
228231 uint8_t writeBlock (uint32_t blockNumber, const uint8_t * src);
You can’t perform that action at this time.
0 commit comments