spiffs_fs.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016 OTA keys S.A.
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #include "spiffs.h"
48 #include "spiffs_config.h"
49 #include "vfs.h"
50 #include "mtd.h"
51 #include "mutex.h"
52 
54 #define SPIFFS_DIR_SIZE (12)
55 
56 #if (VFS_DIR_BUFFER_SIZE < SPIFFS_DIR_SIZE)
57 #error "VFS_DIR_BUFFER_SIZE too small"
58 #endif
59 
64 #ifndef SPIFFS_FS_CACHE_SIZE
65 #if SPIFFS_CACHE || defined(DOXYGEN)
73 #define SPIFFS_FS_CACHE_SIZE (512)
74 #else
75 #define SPIFFS_FS_CACHE_SIZE (0)
76 #endif /* SPIFFS_CACHE */
77 #endif /* SPIFFS_FS_CACHE_SIZE */
78 #ifndef SPIFFS_FS_WORK_SIZE
86 #define SPIFFS_FS_WORK_SIZE (512)
87 #endif
88 #ifndef SPIFFS_FS_FD_SPACE_SIZE
95 #define SPIFFS_FS_FD_SPACE_SIZE (4 * 32)
96 #endif
102 typedef struct spiffs_desc {
103  spiffs fs;
106 #if (SPIFFS_CACHE == 1) || defined(DOXYGEN)
108 #endif
109  spiffs_config config;
112 #if (SPIFFS_HAL_CALLBACK_EXTRA == 1) || defined(DOXYGEN)
114 #endif
115 #if (SPIFFS_SINGLETON == 0) || defined(DOXYGEN)
116  uint32_t base_addr;
117  uint32_t block_count;
119 #endif
121 
124 
133 void spiffs_lock(struct spiffs_t *fs);
134 
143 void spiffs_unlock(struct spiffs_t *fs);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
#define SPIFFS_FS_WORK_SIZE
The size of the work buffer.
Definition: spiffs_fs.h:86
void spiffs_lock(struct spiffs_t *fs)
SPIFFS lock function.
struct spiffs_desc spiffs_desc_t
This contains everything needed to run an instance of SPIFFS.
void spiffs_unlock(struct spiffs_t *fs)
SPIFFS unlock function.
#define SPIFFS_FS_FD_SPACE_SIZE
the size of the file descriptor buffer
Definition: spiffs_fs.h:95
const vfs_file_system_t spiffs_file_system
The SPIFFS vfs driver, a pointer to a spiffs_desc_t must be provided as vfs_mountp::private_data.
#define SPIFFS_FS_CACHE_SIZE
the size of the cache buffer
Definition: spiffs_fs.h:73
Mutex for thread synchronization.
MTD device descriptor.
Definition: mtd.h:111
Mutex structure.
Definition: mutex.h:36
This contains everything needed to run an instance of SPIFFS.
Definition: spiffs_fs.h:102
mutex_t lock
A lock for SPIFFS internal use.
Definition: spiffs_fs.h:111
spiffs_config config
SPIFFS config, filled at mount time depending on the underlying mtdi_dev_t dev.
Definition: spiffs_fs.h:109
uint8_t work[SPIFFS_FS_WORK_SIZE]
SPIFFS work buffer.
Definition: spiffs_fs.h:104
uint32_t block_count
Number of blocks in current partition, if 0, the mtd number of sector is used.
Definition: spiffs_fs.h:117
uint8_t cache[SPIFFS_FS_CACHE_SIZE]
SPIFFS cache.
Definition: spiffs_fs.h:107
mtd_dev_t * dev
The underlying mtd device, must be set by user.
Definition: spiffs_fs.h:113
spiffs fs
The SPIFFS struct.
Definition: spiffs_fs.h:103
uint32_t base_addr
Base address of partition.
Definition: spiffs_fs.h:116
uint8_t fd_space[SPIFFS_FS_FD_SPACE_SIZE]
SPIFFS file descriptor cache.
Definition: spiffs_fs.h:105
A file system driver.
Definition: vfs.h:386