From 3e5830bc60a14e5c7a60aa1af25cd428fbd9fb1a Mon Sep 17 00:00:00 2001 From: Jackson Ming Hu Date: Wed, 10 Jan 2024 14:43:02 +1100 Subject: [PATCH] sdmmc: implement mount check API for SDMMC --- include/esp_littlefs.h | 13 +++++++++++++ src/esp_littlefs.c | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/esp_littlefs.h b/include/esp_littlefs.h index 9d63d8d..7c2bb40 100644 --- a/include/esp_littlefs.h +++ b/include/esp_littlefs.h @@ -112,6 +112,19 @@ bool esp_littlefs_mounted(const char* partition_label); */ bool esp_littlefs_partition_mounted(const esp_partition_t* partition); +#ifdef CONFIG_LITTLEFS_SDMMC_SUPPORT +/** + * Check if littlefs is mounted + * + * @param sdcard SD card to check. + * + * @return + * - true if mounted + * - false if not mounted + */ +bool esp_littlefs_sdmmc_mounted(sdmmc_card_t *sdcard); +#endif + /** * Format the littlefs partition * diff --git a/src/esp_littlefs.c b/src/esp_littlefs.c index 188a3c4..f5fd7ba 100644 --- a/src/esp_littlefs.c +++ b/src/esp_littlefs.c @@ -320,6 +320,17 @@ bool esp_littlefs_partition_mounted(const esp_partition_t* partition) { return _efs[index]->cache_size > 0; } +#ifdef CONFIG_LITTLEFS_SDMMC_SUPPORT +bool esp_littlefs_sdmmc_mounted(sdmmc_card_t *sdcard) +{ + int index; + esp_err_t err = esp_littlefs_by_sdmmc_handle(sdcard, &index); + + if(err != ESP_OK) return false; + return _efs[index]->cache_size > 0; +} +#endif + esp_err_t esp_littlefs_info(const char* partition_label, size_t *total_bytes, size_t *used_bytes){ int index; esp_err_t err; @@ -342,6 +353,7 @@ esp_err_t esp_littlefs_partition_info(const esp_partition_t* partition, size_t * return ESP_OK; } +#ifdef CONFIG_LITTLEFS_SDMMC_SUPPORT esp_err_t esp_littlefs_sdmmc_info(sdmmc_card_t *sdcard, size_t *total_bytes, size_t *used_bytes) { int index; @@ -353,6 +365,7 @@ esp_err_t esp_littlefs_sdmmc_info(sdmmc_card_t *sdcard, size_t *total_bytes, siz return ESP_OK; } +#endif esp_err_t esp_vfs_littlefs_register(const esp_vfs_littlefs_conf_t * conf) {