mikroSDK Reference Manual
lv_fs.h
Go to the documentation of this file.
1
6#ifndef LV_FS_H
7#define LV_FS_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#include <stdint.h>
19#include <stdbool.h>
20
21/*********************
22 * DEFINES
23 *********************/
24#define LV_FS_MAX_FN_LENGTH 64
25#define LV_FS_MAX_PATH_LENGTH 256
26
27/**********************
28 * TYPEDEFS
29 **********************/
30
34enum {
35 LV_FS_RES_OK = 0,
36 LV_FS_RES_HW_ERR, /*Low level hardware error*/
37 LV_FS_RES_FS_ERR, /*Error in the file system structure*/
38 LV_FS_RES_NOT_EX, /*Driver, file or directory is not exists*/
39 LV_FS_RES_FULL, /*Disk full*/
40 LV_FS_RES_LOCKED, /*The file is already opened*/
41 LV_FS_RES_DENIED, /*Access denied. Check 'fs_open' modes and write protect*/
42 LV_FS_RES_BUSY, /*The file system now can't handle it, try later*/
43 LV_FS_RES_TOUT, /*Process time outed*/
44 LV_FS_RES_NOT_IMP, /*Requested function is not implemented*/
45 LV_FS_RES_OUT_OF_MEM, /*Not enough memory for an internal operation*/
46 LV_FS_RES_INV_PARAM, /*Invalid parameter among arguments*/
47 LV_FS_RES_UNKNOWN, /*Other unknown error*/
48};
49typedef uint8_t lv_fs_res_t;
50
54enum {
55 LV_FS_MODE_WR = 0x01,
56 LV_FS_MODE_RD = 0x02,
57};
58typedef uint8_t lv_fs_mode_t;
59
60
64typedef enum {
69
70typedef struct _lv_fs_drv_t {
71 char letter;
72 uint16_t cache_size;
73 bool (*ready_cb)(struct _lv_fs_drv_t * drv);
74
75 void * (*open_cb)(struct _lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
76 lv_fs_res_t (*close_cb)(struct _lv_fs_drv_t * drv, void * file_p);
77 lv_fs_res_t (*read_cb)(struct _lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
78 lv_fs_res_t (*write_cb)(struct _lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
79 lv_fs_res_t (*seek_cb)(struct _lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
80 lv_fs_res_t (*tell_cb)(struct _lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
81
82 void * (*dir_open_cb)(struct _lv_fs_drv_t * drv, const char * path);
83 lv_fs_res_t (*dir_read_cb)(struct _lv_fs_drv_t * drv, void * rddir_p, char * fn);
84 lv_fs_res_t (*dir_close_cb)(struct _lv_fs_drv_t * drv, void * rddir_p);
85
86#if LV_USE_USER_DATA
87 void * user_data;
88#endif
90
91typedef struct {
92 uint32_t start;
93 uint32_t end;
94 uint32_t file_position;
95 void * buffer;
97
98typedef struct {
99 void * file_d;
100 lv_fs_drv_t * drv;
101 lv_fs_file_cache_t * cache;
103
104typedef struct {
105 void * dir_d;
106 lv_fs_drv_t * drv;
108
109/**********************
110 * GLOBAL PROTOTYPES
111 **********************/
112
116void _lv_fs_init(void);
117
125
133
140
147bool lv_fs_is_ready(char letter);
148
156lv_fs_res_t lv_fs_open(lv_fs_file_t * file_p, const char * path, lv_fs_mode_t mode);
157
163lv_fs_res_t lv_fs_close(lv_fs_file_t * file_p);
164
173lv_fs_res_t lv_fs_read(lv_fs_file_t * file_p, void * buf, uint32_t btr, uint32_t * br);
174
183lv_fs_res_t lv_fs_write(lv_fs_file_t * file_p, const void * buf, uint32_t btw, uint32_t * bw);
184
192lv_fs_res_t lv_fs_seek(lv_fs_file_t * file_p, uint32_t pos, lv_fs_whence_t whence);
193
200lv_fs_res_t lv_fs_tell(lv_fs_file_t * file_p, uint32_t * pos);
201
208lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t * rddir_p, const char * path);
209
217lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t * rddir_p, char * fn);
218
224lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t * rddir_p);
225
231char * lv_fs_get_letters(char * buf);
232
238const char * lv_fs_get_ext(const char * fn);
239
245char * lv_fs_up(char * path);
246
252const char * lv_fs_get_last(const char * path);
253
254/**********************
255 * MACROS
256 **********************/
257
258#ifdef __cplusplus
259} /*extern "C"*/
260#endif
261
262#endif /*LV_FS_H*/
lv_fs_res_t lv_fs_seek(lv_fs_file_t *file_p, uint32_t pos, lv_fs_whence_t whence)
void lv_fs_drv_init(lv_fs_drv_t *drv)
lv_fs_res_t lv_fs_tell(lv_fs_file_t *file_p, uint32_t *pos)
lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t *rddir_p)
const char * lv_fs_get_last(const char *path)
void lv_fs_drv_register(lv_fs_drv_t *drv)
lv_fs_res_t lv_fs_open(lv_fs_file_t *file_p, const char *path, lv_fs_mode_t mode)
bool lv_fs_is_ready(char letter)
lv_fs_drv_t * lv_fs_get_drv(char letter)
lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t *rddir_p, const char *path)
lv_fs_res_t lv_fs_close(lv_fs_file_t *file_p)
char * lv_fs_up(char *path)
lv_fs_res_t lv_fs_write(lv_fs_file_t *file_p, const void *buf, uint32_t btw, uint32_t *bw)
lv_fs_res_t lv_fs_read(lv_fs_file_t *file_p, void *buf, uint32_t btr, uint32_t *br)
lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t *rddir_p, char *fn)
const char * lv_fs_get_ext(const char *fn)
void _lv_fs_init(void)
lv_fs_whence_t
Definition lv_fs.h:64
@ LV_FS_SEEK_END
Definition lv_fs.h:67
@ LV_FS_SEEK_CUR
Definition lv_fs.h:66
@ LV_FS_SEEK_SET
Definition lv_fs.h:65
char * lv_fs_get_letters(char *buf)
Definition lv_fs.h:70
Definition lv_fs.h:104
Definition lv_fs.h:91
Definition lv_fs.h:98