littlefs_fs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 OTA keys S.A.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef FS_LITTLEFS_FS_H
23 #define FS_LITTLEFS_FS_H
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #include "vfs.h"
30 #include "lfs.h"
31 #include "mtd.h"
32 #include "mutex.h"
33 
38 #ifndef LITTLEFS_LOOKAHEAD_SIZE
39 
40 #define LITTLEFS_LOOKAHEAD_SIZE (128)
41 #endif
42 
43 #ifndef LITTLEFS_FILE_BUFFER_SIZE
44 
47 #define LITTLEFS_FILE_BUFFER_SIZE (0)
48 #endif
49 
50 #ifndef LITTLEFS_READ_BUFFER_SIZE
51 
53 #define LITTLEFS_READ_BUFFER_SIZE (0)
54 #endif
55 
56 #ifndef LITTLEFS_PROG_BUFFER_SIZE
57 
59 #define LITTLEFS_PROG_BUFFER_SIZE (0)
60 #endif
61 
66 typedef struct {
67  lfs_t fs;
68  struct lfs_config config;
74  uint32_t base_addr;
75 #if LITTLEFS_FILE_BUFFER_SIZE || DOXYGEN
76 
77  uint8_t file_buf[LITTLEFS_FILE_BUFFER_SIZE];
78 #endif
79 #if LITTLEFS_READ_BUFFER_SIZE || DOXYGEN
80 
81  uint8_t read_buf[LITTLEFS_READ_BUFFER_SIZE];
82 #endif
83 #if LITTLEFS_PROG_BUFFER_SIZE || DOXYGEN
84 
85  uint8_t prog_buf[LITTLEFS_PROG_BUFFER_SIZE];
86 #endif
87 
88  uint8_t lookahead_buf[LITTLEFS_LOOKAHEAD_SIZE / 8];
90 
93 
94 #ifdef __cplusplus
95 }
96 #endif
97 
98 #endif /* FS_LITTLEFS_FS_H */
99 
mtd_dev_t
MTD device descriptor.
Definition: mtd.h:58
littlefs_desc_t::lock
mutex_t lock
mutex
Definition: littlefs_fs.h:70
littlefs_desc_t
littlefs descriptor for vfs integration
Definition: littlefs_fs.h:66
LITTLEFS_READ_BUFFER_SIZE
#define LITTLEFS_READ_BUFFER_SIZE
Read buffer size, if 0, dynamic allocation is used.
Definition: littlefs_fs.h:53
LITTLEFS_LOOKAHEAD_SIZE
#define LITTLEFS_LOOKAHEAD_SIZE
Default lookahead size.
Definition: littlefs_fs.h:40
littlefs_file_system
const vfs_file_system_t littlefs_file_system
The littlefs vfs driver.
littlefs_desc_t::fs
lfs_t fs
littlefs descriptor
Definition: littlefs_fs.h:67
LITTLEFS_FILE_BUFFER_SIZE
#define LITTLEFS_FILE_BUFFER_SIZE
File buffer size, if 0, dynamic allocation is used.
Definition: littlefs_fs.h:47
mutex.h
Mutex for thread synchronization.
vfs_file_system_t
A file system driver.
Definition: vfs.h:256
littlefs_desc_t::base_addr
uint32_t base_addr
first block number to use, total number of block is defined in config.
Definition: littlefs_fs.h:74
littlefs_desc_t::dev
mtd_dev_t * dev
mtd device to use
Definition: littlefs_fs.h:69
vfs.h
VFS layer API declarations.
LITTLEFS_PROG_BUFFER_SIZE
#define LITTLEFS_PROG_BUFFER_SIZE
Prog buffer size, if 0, dynamic allocation is used.
Definition: littlefs_fs.h:59
mutex_t
Mutex structure.
Definition: mutex.h:120