littlefs_fs.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 OTA keys S.A.
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
21 #include <stdalign.h>
22 
23 #include "vfs.h"
24 #include "lfs.h"
25 #include "mtd.h"
26 #include "mutex.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 #ifndef LITTLEFS_LOOKAHEAD_SIZE
38 #define LITTLEFS_LOOKAHEAD_SIZE (128)
39 #endif
40 
41 #ifndef LITTLEFS_FILE_BUFFER_SIZE
45 #define LITTLEFS_FILE_BUFFER_SIZE (0)
46 #endif
47 
48 #ifndef LITTLEFS_READ_BUFFER_SIZE
51 #define LITTLEFS_READ_BUFFER_SIZE (0)
52 #endif
53 
54 #ifndef LITTLEFS_PROG_BUFFER_SIZE
57 #define LITTLEFS_PROG_BUFFER_SIZE (0)
58 #endif
59 
60 #ifndef LITTLEFS_MIN_BLOCK_SIZE_EXP
64 #define LITTLEFS_MIN_BLOCK_SIZE_EXP (-1)
65 #endif
71 typedef struct {
72  lfs_t fs;
73  struct lfs_config config;
79  uint32_t base_addr;
80 #if LITTLEFS_FILE_BUFFER_SIZE || DOXYGEN
82  alignas(uint32_t) uint8_t file_buf[LITTLEFS_FILE_BUFFER_SIZE];
83 #endif
84 #if LITTLEFS_READ_BUFFER_SIZE || DOXYGEN
86  alignas(uint32_t) uint8_t read_buf[LITTLEFS_READ_BUFFER_SIZE];
87 #endif
88 #if LITTLEFS_PROG_BUFFER_SIZE || DOXYGEN
90  alignas(uint32_t) uint8_t prog_buf[LITTLEFS_PROG_BUFFER_SIZE];
91 #endif
93  alignas(uint32_t) uint8_t lookahead_buf[LITTLEFS_LOOKAHEAD_SIZE / 8];
94  uint16_t sectors_per_block;
96 
99 
100 #ifdef __cplusplus
101 }
102 #endif
103 
#define LITTLEFS_LOOKAHEAD_SIZE
Default lookahead size.
Definition: littlefs_fs.h:38
#define LITTLEFS_FILE_BUFFER_SIZE
File buffer size, if 0, dynamic allocation is used.
Definition: littlefs_fs.h:45
const vfs_file_system_t littlefs_file_system
The littlefs vfs driver.
#define LITTLEFS_READ_BUFFER_SIZE
Read buffer size, if 0, dynamic allocation is used.
Definition: littlefs_fs.h:51
#define LITTLEFS_PROG_BUFFER_SIZE
Prog buffer size, if 0, dynamic allocation is used.
Definition: littlefs_fs.h:57
Mutex for thread synchronization.
littlefs descriptor for vfs integration
Definition: littlefs_fs.h:71
uint16_t sectors_per_block
number of sectors per block
Definition: littlefs_fs.h:94
mtd_dev_t * dev
mtd device to use
Definition: littlefs_fs.h:74
mutex_t lock
mutex
Definition: littlefs_fs.h:75
uint32_t base_addr
first block number to use, total number of block is defined in config.
Definition: littlefs_fs.h:79
MTD device descriptor.
Definition: mtd.h:111
Mutex structure.
Definition: mutex.h:36
A file system driver.
Definition: vfs.h:386