Select one of the symbols to view example projects that use it.
 
Outline
#include <sdmmc_cmd.h>
#include <sys/param.h>
#include "littlefs_api.h"
littlefs_sdmmc_read(const struct lfs_config *, lfs_block_t, lfs_off_t, void *, lfs_size_t)
littlefs_sdmmc_write(const struct lfs_config *, lfs_block_t, lfs_off_t, const void *, lfs_size_t)
littlefs_sdmmc_erase(const struct lfs_config *, lfs_block_t)
littlefs_sdmmc_sync(const struct lfs_config *)
Files
loading...
SourceVuESP-IDF Framework and Examplesperf_benchmark samplemanaged_components/joltwallet__littlefs/src/littlefs_sdmmc.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/** * @file littlefs_sdmmc.c * @brief Maps the HAL of sdmmc driver <-> littlefs * @author Jackson Ming Hu <jackson@smartguide.com.au> *//* ... */ #include <sdmmc_cmd.h> #include <sys/param.h> #include "littlefs_api.h" #if CONFIG_LITTLEFS_SDMMC_SUPPORT #if ESP_IDF_VERSION_MAJOR < 5 #error "SDMMC feature is only supported in ESP-IDF v5+, see: https://github.com/joltwallet/esp_littlefs/pull/170#issuecomment-1882484668" #else int littlefs_sdmmc_read(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, void *buffer, lfs_size_t size) { esp_littlefs_t * efs = c->context; uint32_t part_off = (block * c->block_size) + off; esp_err_t ret = sdmmc_read_sectors(efs->sdcard, buffer, block, MIN(size / efs->cfg.read_size, 1)); if (ret != ESP_OK) { ESP_LOGE(ESP_LITTLEFS_TAG, "Failed to read addr 0x%08lx: off 0x%08lx, block 0x%08lx, size %lu, err=0x%x", part_off, off, block, size, ret); return LFS_ERR_IO; }{...} return LFS_ERR_OK; }{ ... } int littlefs_sdmmc_write(const struct lfs_config *c, lfs_block_t block, lfs_off_t off, const void *buffer, lfs_size_t size) { esp_littlefs_t * efs = c->context; uint32_t part_off = (block * c->block_size) + off; esp_err_t ret = sdmmc_write_sectors(efs->sdcard, buffer, block, MIN(size / efs->cfg.prog_size, 1)); if (ret != ESP_OK) { ESP_LOGE(ESP_LITTLEFS_TAG, "Failed to write addr 0x%08lx: off 0x%08lx, block 0x%08lx, size %lu, err=0x%x", part_off, off, block, size, ret); return LFS_ERR_IO; }{...} return LFS_ERR_OK; }{ ... } int littlefs_sdmmc_erase(const struct lfs_config *c, lfs_block_t block) { esp_littlefs_t * efs = c->context; esp_err_t ret = sdmmc_erase_sectors(efs->sdcard, block, 1, SDMMC_ERASE_ARG); if (ret != ESP_OK) { ESP_LOGE(ESP_LITTLEFS_TAG, "Failed to erase block %lu: ret=0x%x %s", block, ret, esp_err_to_name(ret)); return LFS_ERR_IO; }{...} return LFS_ERR_OK; }{ ... } int littlefs_sdmmc_sync(const struct lfs_config *c) { return LFS_ERR_OK; // Doesn't require & doesn't support sync }{ ... } #endif/* ... */ /* ... */ #endif
Details