mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-22 04:54:47 +00:00
Add SD card initialization
This commit is contained in:
parent
cd95d0865f
commit
61ebdb3367
@ -1,6 +1,18 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "FSCommon.h"
|
#include "FSCommon.h"
|
||||||
|
|
||||||
|
#ifdef HAS_SDCARD
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <SD.h>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SDCARD_USE_SPI1
|
||||||
|
SPIClass SPI1(HSPI);
|
||||||
|
#define SDHandler SPI1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif //HAS_SDCARD
|
||||||
|
|
||||||
bool copyFile(const char* from, const char* to)
|
bool copyFile(const char* from, const char* to)
|
||||||
{
|
{
|
||||||
@ -169,3 +181,39 @@ void fsInit()
|
|||||||
listDir("/", 10);
|
listDir("/", 10);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setupSDCard()
|
||||||
|
{
|
||||||
|
#ifdef HAS_SDCARD
|
||||||
|
SDHandler.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
|
||||||
|
|
||||||
|
if (!SD.begin(SDCARD_CS, SDHandler)) {
|
||||||
|
DEBUG_MSG("No SD_MMC card detected\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
uint8_t cardType = SD.cardType();
|
||||||
|
if (cardType == CARD_NONE) {
|
||||||
|
DEBUG_MSG("No SD_MMC card attached\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
DEBUG_MSG("SD_MMC Card Type: ");
|
||||||
|
if (cardType == CARD_MMC) {
|
||||||
|
DEBUG_MSG("MMC\n");
|
||||||
|
} else if (cardType == CARD_SD) {
|
||||||
|
DEBUG_MSG("SDSC\n");
|
||||||
|
} else if (cardType == CARD_SDHC) {
|
||||||
|
DEBUG_MSG("SDHC\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("UNKNOWN\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||||
|
DEBUG_MSG("SD Card Size: %lluMB\n", cardSize);
|
||||||
|
DEBUG_MSG("Total space: %llu MB\n", SD.totalBytes() / (1024 * 1024));
|
||||||
|
DEBUG_MSG("Used space: %llu MB\n", SD.usedBytes() / (1024 * 1024));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,3 +44,4 @@ bool copyFile(const char* from, const char* to);
|
|||||||
bool renameFile(const char* pathFrom, const char* pathTo);
|
bool renameFile(const char* pathFrom, const char* pathTo);
|
||||||
void listDir(const char * dirname, uint8_t levels, boolean del);
|
void listDir(const char * dirname, uint8_t levels, boolean del);
|
||||||
void rmDir(const char * dirname);
|
void rmDir(const char * dirname);
|
||||||
|
void setupSDCard();
|
@ -254,6 +254,10 @@ void setup()
|
|||||||
DEBUG_MSG("PCF8563 RTC found\n");
|
DEBUG_MSG("PCF8563 RTC found\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_SDCARD
|
||||||
|
setupSDCard();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef RAK4630
|
#ifdef RAK4630
|
||||||
// scanEInkDevice();
|
// scanEInkDevice();
|
||||||
|
Loading…
Reference in New Issue
Block a user