1
0
Fork 0
2020-embedded-game-programming/game/src/odroid/sdcard.c

34 lines
900 B
C
Raw Permalink Normal View History

2020-05-20 01:16:30 +00:00
#include "sdcard.h"
#include <esp_vfs_fat.h>
#include <driver/sdmmc_host.h>
#include <driver/sdspi_host.h>
#include <sdmmc_cmd.h>
static const gpio_num_t SD_PIN_MISO = GPIO_NUM_19;
static const gpio_num_t SD_PIN_MOSI = GPIO_NUM_23;
static const gpio_num_t SD_PIN_SCLK = GPIO_NUM_18;
static const gpio_num_t SD_PIN_CS = GPIO_NUM_22;
void Odroid_InitializeSdcard()
{
sdmmc_host_t host = SDSPI_HOST_DEFAULT();
host.slot = VSPI_HOST;
sdspi_slot_config_t slot_config = SDSPI_SLOT_CONFIG_DEFAULT();
slot_config.gpio_miso = SD_PIN_MISO;
slot_config.gpio_mosi = SD_PIN_MOSI;
slot_config.gpio_sck = SD_PIN_SCLK;
slot_config.gpio_cs = SD_PIN_CS;
esp_vfs_fat_sdmmc_mount_config_t mount_config = {};
mount_config.format_if_mount_failed = false;
mount_config.max_files = 5;
sdmmc_card_t* card;
ESP_ERROR_CHECK(esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card));
}