SDInterface.cpp 1023 B

1234567891011121314151617181920212223242526272829303132
  1. #include "SDInterface.h"
  2. bool SDInterface::initSD() {
  3. if (!SD.begin(SD_CS)) {
  4. Serial.println("Failed to mount SD Card");
  5. this->supported = false;
  6. return false;
  7. }
  8. else {
  9. this->supported = true;
  10. this->cardType = SD.cardType();
  11. if (cardType == CARD_MMC)
  12. Serial.println("SD: MMC Mounted");
  13. else if(cardType == CARD_SD)
  14. Serial.println("SD: SDSC Mounted");
  15. else if(cardType == CARD_SDHC)
  16. Serial.println("SD: SDHC Mounted");
  17. else
  18. Serial.println("SD: UNKNOWN Card Mounted");
  19. this->cardSizeBT = SD.cardSize();
  20. this->cardSizeKB = SD.cardSize() / 1024;
  21. this->cardSizeMB = SD.cardSize() / (1024 * 1024);
  22. this->cardSizeGB = SD.cardSize() / (1024 * 1024 * 1024);
  23. Serial.printf("SD Card Size: %llu Bytes\n", this->cardSizeBT);
  24. Serial.printf("SD Card Size: %lluKB\n", this->cardSizeKB);
  25. Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB);
  26. Serial.printf("SD Card Size: %lluGB\n", this->cardSizeGB);
  27. return true;
  28. }
  29. }