Skip to content

Commit

Permalink
sdmmc: implement mount check API for SDMMC
Browse files Browse the repository at this point in the history
  • Loading branch information
huming2207 committed Jan 10, 2024
1 parent dc62c84 commit 3e5830b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions include/esp_littlefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
13 changes: 13 additions & 0 deletions src/esp_littlefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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)
{
Expand Down

0 comments on commit 3e5830b

Please sign in to comment.