void setup()
{
// 打开串行通信并等待端口打开
Serial.begin(115200);
while (!Serial) {
; // 等待串口连接
}
Serial.print("\nInitializing SD card...");//初始化SD卡
//我们将使用实用程序库中的初始化代码。
//因为我们只是在测试卡是否有效!
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println("initialization failed. Things to check:");//初始化失败。需要检查的东西:
Serial.println("* is a card inserted?");//插卡了吗?
Serial.println("* is your wiring correct?");//你的线路正确吗?
Serial.println("* did you change the chipSelect pin to match your shield or module?");
//你改变ChipSelect引脚来匹配你的盾或模块?
return;
} else {
Serial.println("Wiring is correct and a card is present.");
//接线正确,并有一张卡片。
}
// 打印的类型的卡
Serial.print("\nCard type: ");
switch (card.type()) {
case SD_CARD_TYPE_SD1:
Serial.println("SD1");
break;
case SD_CARD_TYPE_SD2:
Serial.println("SD2");
break;
case SD_CARD_TYPE_SDHC:
Serial.println("SDHC");
break;
default:
Serial.println("Unknown");
}
// Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
//现在我们将尝试打开“音量”/ 'partition”应该是fat16和fat32
if (!volume.init(card)) {
Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
//无法找到FAT16/FAT32分区,NMAKE肯定你已经格式化卡
return;
}
// print the type and size of the first FAT-type volume
//打印第一个脂肪类型的类型和大小。
uint32_t volumesize;
Serial.print("\nVolume type is FAT");//测定
Serial.println(volume.fatType(), DEC);
Serial.println();