spiffs_fs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 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 
9 #pragma once
10 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 #include "spiffs.h"
51 #include "spiffs_config.h"
52 #include "vfs.h"
53 #include "mtd.h"
54 #include "mutex.h"
55 
57 #define SPIFFS_DIR_SIZE (12)
58 
59 #if (VFS_DIR_BUFFER_SIZE < SPIFFS_DIR_SIZE)
60 #error "VFS_DIR_BUFFER_SIZE too small"
61 #endif
62 
67 #ifndef SPIFFS_FS_CACHE_SIZE
68 #if SPIFFS_CACHE || defined(DOXYGEN)
76 #define SPIFFS_FS_CACHE_SIZE (512)
77 #else
78 #define SPIFFS_FS_CACHE_SIZE (0)
79 #endif /* SPIFFS_CACHE */
80 #endif /* SPIFFS_FS_CACHE_SIZE */
81 #ifndef SPIFFS_FS_WORK_SIZE
89 #define SPIFFS_FS_WORK_SIZE (512)
90 #endif
91 #ifndef SPIFFS_FS_FD_SPACE_SIZE
98 #define SPIFFS_FS_FD_SPACE_SIZE (4 * 32)
99 #endif
105 typedef struct spiffs_desc {
106  spiffs fs;
109 #if (SPIFFS_CACHE == 1) || defined(DOXYGEN)
111 #endif
112  spiffs_config config;
115 #if (SPIFFS_HAL_CALLBACK_EXTRA == 1) || defined(DOXYGEN)
117 #endif
118 #if (SPIFFS_SINGLETON == 0) || defined(DOXYGEN)
119  uint32_t base_addr;
120  uint32_t block_count;
122 #endif
124 
127 
136 void spiffs_lock(struct spiffs_t *fs);
137 
146 void spiffs_unlock(struct spiffs_t *fs);
147 
148 #ifdef __cplusplus
149 }
150 #endif
151 
#define SPIFFS_FS_WORK_SIZE
The size of the work buffer.
Definition: spiffs_fs.h:89
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:98
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:76
Mutex for thread synchronization.
MTD device descriptor.
Definition: mtd.h:111
Mutex structure.
Definition: mutex.h:39
This contains everything needed to run an instance of SPIFFS.
Definition: spiffs_fs.h:105
mutex_t lock
A lock for SPIFFS internal use.
Definition: spiffs_fs.h:114
spiffs_config config
SPIFFS config, filled at mount time depending on the underlying mtdi_dev_t dev.
Definition: spiffs_fs.h:112
uint8_t work[SPIFFS_FS_WORK_SIZE]
SPIFFS work buffer.
Definition: spiffs_fs.h:107
uint32_t block_count
Number of blocks in current partition, if 0, the mtd number of sector is used.
Definition: spiffs_fs.h:120
uint8_t cache[SPIFFS_FS_CACHE_SIZE]
SPIFFS cache.
Definition: spiffs_fs.h:110
mtd_dev_t * dev
The underlying mtd device, must be set by user.
Definition: spiffs_fs.h:116
spiffs fs
The SPIFFS struct.
Definition: spiffs_fs.h:106
uint32_t base_addr
Base address of partition.
Definition: spiffs_fs.h:119
uint8_t fd_space[SPIFFS_FS_FD_SPACE_SIZE]
SPIFFS file descriptor cache.
Definition: spiffs_fs.h:108
A file system driver.
Definition: vfs.h:374