-
Notifications
You must be signed in to change notification settings - Fork 0
/
sd_config.h
38 lines (33 loc) · 887 Bytes
/
sd_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// sd_config.h
#ifndef SD_CONFIG_H
#define SD_CONFIG_H
#include "FS.h"
#include "SD.h"
#include "SPI.h"
// 初始化 SD 卡
bool initSDCard() {
Serial.println("Initializing SD card...");
if(!SD.begin(21)){ // 确保21为CS引脚
Serial.println("Card Mount Failed");
return false;
}
uint8_t cardType = SD.cardType();
// Determine if the type of SD card is available
if(cardType == CARD_NONE){
Serial.println("No SD card attached");
return false;
}
Serial.print("SD Card Type: ");
if(cardType == CARD_MMC){
Serial.println("MMC");
} else if(cardType == CARD_SD){
Serial.println("SDSC");
} else if(cardType == CARD_SDHC){
Serial.println("SDHC");
} else {
Serial.println("UNKNOWN");
}
Serial.println("SD卡初始化成功");
return true;
}
#endif // SD_CONFIG_H