update sd card code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef CHAR_LCD_H
|
||||
#define CHAR_LCD_H
|
||||
|
||||
#include "i2c_lcd_pcf8574.h"
|
||||
#include "./i2c_lcd_pcf8574.h"
|
||||
#include <esp_log.h>
|
||||
|
||||
#define CHAR_LCD_I2C_NUM I2C_NUM_0
|
||||
|
||||
+26
-34
@@ -6,48 +6,40 @@ static const char* mount_point = MOUNT_POINT;
|
||||
static const char* TAG = "sd";
|
||||
|
||||
void init_sd() {
|
||||
esp_err_t ret;
|
||||
|
||||
// Options for mounting the filesystem.
|
||||
// If format_if_mount_failed is set to true, SD card will be partitioned and
|
||||
// formatted in case when mounting fails.
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = true,
|
||||
.max_files = 5,
|
||||
.allocation_unit_size = 16 * 1024,
|
||||
.disk_status_check_enable = false,
|
||||
};
|
||||
|
||||
ESP_LOGI(TAG, "Initializing SD card");
|
||||
|
||||
// Use settings defined above to initialize SD card and mount FAT filesystem.
|
||||
// Note: esp_vfs_fat_sdmmc/sdspi_mount is all-in-one convenience functions.
|
||||
// Please check its source code and implement error recovery when developing
|
||||
// production applications.
|
||||
esp_err_t ret;
|
||||
|
||||
esp_vfs_fat_sdmmc_mount_config_t mount_config = {
|
||||
.format_if_mount_failed = false,
|
||||
.max_files = 8,
|
||||
.allocation_unit_size = 16 * 1024,
|
||||
.disk_status_check_enable = true,
|
||||
.use_one_fat = false,
|
||||
};
|
||||
|
||||
ESP_LOGI(TAG, "Using SDMMC peripheral");
|
||||
sdmmc_host_t host = SDMMC_HOST_DEFAULT();
|
||||
|
||||
// This initializes the slot without card detect (CD) and write protect (WP) signals.
|
||||
// Modify slot_config.gpio_cd and slot_config.gpio_wp if your board has these signals.
|
||||
sdmmc_slot_config_t slot_config = SDMMC_SLOT_CONFIG_DEFAULT();
|
||||
|
||||
// Set bus width to use:
|
||||
slot_config.width = 4;
|
||||
|
||||
// On chips where the GPIOs used for SD card can be configured, set them in
|
||||
// the slot_config structure:
|
||||
slot_config.clk = SD_PIN_CLK;
|
||||
slot_config.cmd = SD_PIN_CMD;
|
||||
slot_config.d0 = SD_PIN_D0;
|
||||
slot_config.d1 = SD_PIN_D1;
|
||||
slot_config.d2 = SD_PIN_D2;
|
||||
slot_config.d3 = SD_PIN_D3;
|
||||
|
||||
// Enable internal pullups on enabled pins. The internal pullups
|
||||
// are insufficient however, please make sure 10k external pullups are
|
||||
// connected on the bus. This is for debug / example purpose only.
|
||||
slot_config.flags |= SDMMC_SLOT_FLAG_INTERNAL_PULLUP;
|
||||
sdmmc_slot_config_t slot_config = {
|
||||
.clk = SD_PIN_CLK,
|
||||
.cmd = SD_PIN_CMD,
|
||||
.d0 = SD_PIN_D0,
|
||||
.d1 = SD_PIN_D1,
|
||||
.d2 = SD_PIN_D2,
|
||||
.d3 = SD_PIN_D3,
|
||||
.d4 = GPIO_NUM_NC,
|
||||
.d5 = GPIO_NUM_NC,
|
||||
.d6 = GPIO_NUM_NC,
|
||||
.d7 = GPIO_NUM_NC,
|
||||
.cd = GPIO_NUM_NC,
|
||||
.wp = GPIO_NUM_NC,
|
||||
.width = 4,
|
||||
.flags = 0
|
||||
// .flags = SDMMC_SLOT_FLAG_INTERNAL_PULLUP
|
||||
};
|
||||
|
||||
ESP_LOGI(TAG, "Mounting filesystem");
|
||||
ret = esp_vfs_fat_sdmmc_mount(mount_point, &host, &slot_config, &mount_config, &card);
|
||||
|
||||
Reference in New Issue
Block a user