Here is the init code:
Code: Select all
static void init_sdmmc(void) {
int64_t t_start = esp_timer_get_time();
esp_err_t err;
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
host.max_freq_khz = 80000; // 80 MHz
host.flags = SDMMC_HOST_FLAG_1BIT; // 1-bit mode
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
slot_config.clk = 39;
slot_config.cmd = 38;
slot_config.d0 = 40;
slot_config.width = 1;
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.allocation_unit_size = 16 * 1024
};
sdmmc_card_t *card;
err = esp_vfs_fat_sdmmc_mount("/sdcard", &host, &slot_config, &mount_config, &card);
int64_t t_end = esp_timer_get_time();
if (err != ESP_OK) {
printf("[%lld ms] SDMMC mount a dat chix, bă! Eroare: 0x%x\n", t_end / 1000, err);
return;
}
printf("[%lld ms] SDMMC montat, frate! Durată: %lld ms, Frecvență cerută: %d kHz, Frecvență reală: %d kHz\n",
t_end / 1000, (t_end - t_start) / 1000, host.max_freq_khz, card->host.max_freq_khz);
}