VSF Documented
vsf_littlefs.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_LITTLEFS_H__
19#define __VSF_LITTLEFS_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "../../vsf_fs_cfg.h"
24
25#if VSF_USE_FS == ENABLED && VSF_FS_USE_LITTLEFS == ENABLED
26
27#include "kernel/vsf_kernel.h"
28#include "lfs.h"
29
30#if defined(__VSF_LITTLEFS_CLASS_IMPLEMENT)
31# undef __VSF_LITTLEFS_CLASS_IMPLEMENT
32# define __VSF_CLASS_IMPLEMENT__
33#endif
34
35#include "utilities/ooc_class.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*============================ MACROS ========================================*/
42
43#if VSF_KERNEL_CFG_SUPPORT_THREAD != ENABLED
44# error littlefs runs in thread mode, please enable VSF_KERNEL_CFG_SUPPORT_THREAD
45#endif
46
47#ifndef VSF_LITTLEFS_CFG_STACK_SIZE
48// any comment value for the default stack size? 4K should be enough
49# define VSF_LITTLEFS_CFG_STACK_SIZE 4096
50#endif
51
52/*============================ MACROFIED FUNCTIONS ===========================*/
53/*============================ TYPES =========================================*/
54
56
58 public_member(
59 implement(vk_file_t)
60 )
61 private_member(
62 union {
63 lfs_file_t lfs_file;
64 lfs_dir_t lfs_dir;
65 };
66 vk_lfs_info_t *info;
67 )
68};
69
71 private_member(
72 vk_lfs_file_t root;
73 )
74
75 public_member(
76 struct lfs_config config;
77 )
78
79 private_member(
80 lfs_t lfs;
81
82 vsf_crit_t crit;
83 vsf_sem_t sem;
84 vsf_thread_t thread;
85 vsf_thread_cb_t thread_cb;
88
89 int op;
90 union {
91 struct {
92 vk_lfs_file_t *dir;
93 const char *name;
94 } open;
95 struct {
96 vk_lfs_file_t *dir;
97 const char *name;
98 vk_file_attr_t attr;
99 } create;
100 struct {
101 vk_lfs_file_t *dir;
102 const char *name;
103 } unlink;
104 struct {
105 lfs_file_t *file;
106 } close_file;
107 struct {
108 lfs_dir_t *dir;
109 } close_dir;
110 struct {
111 lfs_file_t *file;
112 void *buffer;
113 lfs_size_t size;
114 } read_file;
115 struct {
116 lfs_file_t *file;
117 void *buffer;
118 lfs_size_t size;
119 } write_file;
120 struct {
121 lfs_file_t *file;
123 } setpos;
124 struct {
125 lfs_file_t *file;
127 } setsize;
128 } param;
129 struct {
130 int ret;
131 union {
132 struct {
133 vk_lfs_file_t *file;
134 } open;
135 struct {
136 lfs_ssize_t size;
137 } read_file;
138 struct {
139 lfs_ssize_t size;
140 } write_file;
141 };
142 } result;
143 vsf_eda_t *caller;
145};
146
147/*============================ GLOBAL VARIABLES ==============================*/
148
149extern const vk_fs_op_t vk_lfs_op;
150
151/*============================ PROTOTYPES ====================================*/
152
153#ifdef __cplusplus
154}
155#endif
156
157#endif // VSF_USE_FS && VSF_FS_USE_LITTLEFS
158#endif // __VSF_LITTLEFS_H__
#define VSF_CAL_ALIGN(__N)
Definition __compiler.h:179
Definition vsf_fs.h:114
Definition vsf_fs.h:92
Definition vsf_littlefs.h:57
Definition vsf_littlefs.h:70
Definition vsf_eda.h:766
Definition vsf_eda.h:892
Definition vsf_eda.h:864
#define open
Definition fcntl.h:20
#define vsf_dcl_class
Definition ooc_class.h:46
#define vsf_class(__name)
Definition ooc_class.h:48
unsigned long long uint64_t
Definition stdint.h:11
#define unlink
Definition unistd.h:114
vk_file_attr_t
Definition vsf_fs_cfg.h:99
const vk_fs_op_t vk_lfs_op
#define VSF_LITTLEFS_CFG_STACK_SIZE
Definition vsf_littlefs.h:49
uint64_t offset
Definition vsf_memfs.h:49
uint32_t size
Definition vsf_memfs.h:50
#define __VSF_THREAD_STACK_SAFE_SIZE(__stack)
Definition vsf_thread.h:63
#define VSF_KERNEL_CFG_THREAD_STACK_ALIGN_BIT
Definition vsf_thread.h:59