在这个例程里,可以执行基本的SD、MMC、SDIO栈
可以自动分辨卡是什么卡并且通过MCI或SPI接口读写,并不需要文件系统。
执行以下顺序:
等待卡插入
初使化卡
如果是SD或MMC卡,测试读/写操作。
写数据到卡上。
读数据从卡上。
效验卡。
如果插入的是SDIO卡:
出始化SDIO卡。
读写测试通过CIA
以下是主函数循环:
- while (1) {
- if (slot == sd_mmc_nb_slot()) {
- slot = 0;
- }
- printf("Please plug an SD, MMC or SDIO card in slot %d.\n\r", slot+1);
- // Wait for a card and ready
- do {
- err = sd_mmc_check(slot);
- if ((SD_MMC_ERR_NO_CARD != err)
- && (SD_MMC_INIT_ONGOING != err)
- && (SD_MMC_OK != err)) {
- printf("Card install FAILED\n\r");
- printf("Please unplug and re-plug the card.\n\r");
- while (SD_MMC_ERR_NO_CARD != sd_mmc_check(slot)) {
- }
- }
- } while (SD_MMC_OK != err);
-
- // Display basic card information
- main_display_info_card(slot);
-
- /* Test the card */
- if (sd_mmc_get_type(slot) & CARD_TYPE_SDIO) {
- // Test CIA of SDIO card
- main_test_sdio(slot);
- }
- if (sd_mmc_get_type(slot) & (CARD_TYPE_SD | CARD_TYPE_MMC)) {
- // SD/MMC Card R/W
- main_test_memory(slot);
- }
- printf("Test finished, please unplugged the card.\n\r");
- while (SD_MMC_OK == sd_mmc_check(slot)) {
- }
- slot++;
- }
以下是运行结果:
|