123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef ZEPHYR_INCLUDE_FS_LITTLEFS_H_
- #define ZEPHYR_INCLUDE_FS_LITTLEFS_H_
- #include <zephyr/types.h>
- #include <kernel.h>
- #include <device.h>
- #include <lfs.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- struct lfs_dev {
- uint32_t offset;
- uint32_t size;
- struct device *dev;
- };
- struct fs_littlefs {
-
- struct lfs_config cfg;
-
- uint8_t *read_buffer;
-
- uint8_t *prog_buffer;
-
- uint32_t *lookahead_buffer[CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE / sizeof(uint32_t)];
-
- struct lfs lfs;
- struct lfs_dev lfs_dev;
- struct k_mutex mutex;
- };
- #define FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(name, read_sz, prog_sz, cache_sz, lookahead_sz) \
- static uint8_t __aligned(4) name ## _read_buffer[cache_sz]; \
- static uint8_t __aligned(4) name ## _prog_buffer[cache_sz]; \
- static uint32_t name ## _lookahead_buffer[(lookahead_sz) / sizeof(uint32_t)]; \
- static struct fs_littlefs name = { \
- .cfg = { \
- .read_size = (read_sz), \
- .prog_size = (prog_sz), \
- .cache_size = (cache_sz), \
- .lookahead_size = (lookahead_sz), \
- .read_buffer = name ## _read_buffer, \
- .prog_buffer = name ## _prog_buffer, \
- .lookahead_buffer = name ## _lookahead_buffer, \
- }, \
- }
- #define FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(name) \
- FS_LITTLEFS_DECLARE_CUSTOM_CONFIG(name, \
- CONFIG_FS_LITTLEFS_READ_SIZE, \
- CONFIG_FS_LITTLEFS_PROG_SIZE, \
- CONFIG_FS_LITTLEFS_CACHE_SIZE, \
- CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE)
- #ifdef __cplusplus
- }
- #endif
- #endif
|