| User | Revision | Line number | New contents of line |
| emh203 |
0:76427232f435
|
1
|
/*---------------------------------------------------------------------------/
|
| emh203 |
0:76427232f435
|
2
|
/ FatFs - FAT file system module include file R0.09 (C)ChaN, 2011
|
| emh203 |
0:76427232f435
|
3
|
/----------------------------------------------------------------------------/
|
| emh203 |
0:76427232f435
|
4
|
/ FatFs module is a generic FAT file system module for small embedded systems.
|
| emh203 |
0:76427232f435
|
5
|
/ This is a free software that opened for education, research and commercial
|
| emh203 |
0:76427232f435
|
6
|
/ developments under license policy of following trems.
|
| emh203 |
0:76427232f435
|
7
|
/
|
| emh203 |
0:76427232f435
|
8
|
/ Copyright (C) 2011, ChaN, all right reserved.
|
| emh203 |
0:76427232f435
|
9
|
/
|
| emh203 |
0:76427232f435
|
10
|
/ * The FatFs module is a free software and there is NO WARRANTY.
|
| emh203 |
0:76427232f435
|
11
|
/ * No restriction on use. You can use, modify and redistribute it for
|
| emh203 |
0:76427232f435
|
12
|
/ personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
|
| emh203 |
0:76427232f435
|
13
|
/ * Redistributions of source code must retain the above copyright notice.
|
| emh203 |
0:76427232f435
|
14
|
/
|
| emh203 |
0:76427232f435
|
15
|
/----------------------------------------------------------------------------*/
|
| emh203 |
0:76427232f435
|
16
|
|
| emh203 |
0:76427232f435
|
17
|
#ifndef _FATFS
|
| emh203 |
0:76427232f435
|
18
|
#define _FATFS 6502 /* Revision ID */
|
| emh203 |
0:76427232f435
|
19
|
|
| emh203 |
0:76427232f435
|
20
|
#ifdef __cplusplus
|
| emh203 |
0:76427232f435
|
21
|
extern "C" {
|
| emh203 |
0:76427232f435
|
22
|
#endif
|
| emh203 |
0:76427232f435
|
23
|
|
| emh203 |
0:76427232f435
|
24
|
#include "integer.h" /* Basic integer types */
|
| emh203 |
0:76427232f435
|
25
|
#include "ffconf.h" /* FatFs configuration options */
|
| emh203 |
0:76427232f435
|
26
|
|
| emh203 |
0:76427232f435
|
27
|
|
| emh203 |
0:76427232f435
|
28
|
#if _FATFS != _FFCONF
|
| emh203 |
0:76427232f435
|
29
|
#error Wrong configuration file (ffconf.h).
|
| emh203 |
0:76427232f435
|
30
|
#endif
|
| emh203 |
0:76427232f435
|
31
|
|
| emh203 |
0:76427232f435
|
32
|
|
| emh203 |
0:76427232f435
|
33
|
|
| emh203 |
0:76427232f435
|
34
|
/* Definitions of volume management */
|
| emh203 |
0:76427232f435
|
35
|
|
| emh203 |
0:76427232f435
|
36
|
#if _MULTI_PARTITION /* Multiple partition configuration */
|
| emh203 |
0:76427232f435
|
37
|
typedef struct {
|
| emh203 |
0:76427232f435
|
38
|
BYTE pd; /* Physical drive number */
|
| emh203 |
0:76427232f435
|
39
|
BYTE pt; /* Partition: 0:Auto detect, 1-4:Forced partition) */
|
| emh203 |
0:76427232f435
|
40
|
} PARTITION;
|
| emh203 |
0:76427232f435
|
41
|
extern PARTITION VolToPart[]; /* Volume - Partition resolution table */
|
| emh203 |
0:76427232f435
|
42
|
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive number */
|
| emh203 |
0:76427232f435
|
43
|
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition index */
|
| emh203 |
0:76427232f435
|
44
|
|
| emh203 |
0:76427232f435
|
45
|
#else /* Single partition configuration */
|
| emh203 |
0:76427232f435
|
46
|
#define LD2PD(vol) (vol) /* Each logical drive is bound to the same physical drive number */
|
| emh203 |
0:76427232f435
|
47
|
#define LD2PT(vol) 0 /* Always mounts the 1st partition or in SFD */
|
| emh203 |
0:76427232f435
|
48
|
|
| emh203 |
0:76427232f435
|
49
|
#endif
|
| emh203 |
0:76427232f435
|
50
|
|
| emh203 |
0:76427232f435
|
51
|
|
| emh203 |
0:76427232f435
|
52
|
|
| emh203 |
0:76427232f435
|
53
|
/* Type of path name strings on FatFs API */
|
| emh203 |
0:76427232f435
|
54
|
|
| emh203 |
0:76427232f435
|
55
|
#if _LFN_UNICODE /* Unicode string */
|
| emh203 |
0:76427232f435
|
56
|
#if !_USE_LFN
|
| emh203 |
0:76427232f435
|
57
|
#error _LFN_UNICODE must be 0 in non-LFN cfg.
|
| emh203 |
0:76427232f435
|
58
|
#endif
|
| emh203 |
0:76427232f435
|
59
|
#ifndef _INC_TCHAR
|
| emh203 |
0:76427232f435
|
60
|
typedef WCHAR TCHAR;
|
| emh203 |
0:76427232f435
|
61
|
#define _T(x) L ## x
|
| emh203 |
0:76427232f435
|
62
|
#define _TEXT(x) L ## x
|
| emh203 |
0:76427232f435
|
63
|
#endif
|
| emh203 |
0:76427232f435
|
64
|
|
| emh203 |
0:76427232f435
|
65
|
#else /* ANSI/OEM string */
|
| emh203 |
0:76427232f435
|
66
|
#ifndef _INC_TCHAR
|
| emh203 |
0:76427232f435
|
67
|
typedef char TCHAR;
|
| emh203 |
0:76427232f435
|
68
|
#define _T(x) x
|
| emh203 |
0:76427232f435
|
69
|
#define _TEXT(x) x
|
| emh203 |
0:76427232f435
|
70
|
#endif
|
| emh203 |
0:76427232f435
|
71
|
|
| emh203 |
0:76427232f435
|
72
|
#endif
|
| emh203 |
0:76427232f435
|
73
|
|
| emh203 |
0:76427232f435
|
74
|
|
| emh203 |
0:76427232f435
|
75
|
|
| emh203 |
0:76427232f435
|
76
|
/* File system object structure (FATFS) */
|
| emh203 |
0:76427232f435
|
77
|
|
| emh203 |
0:76427232f435
|
78
|
typedef struct {
|
| emh203 |
0:76427232f435
|
79
|
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
|
| emh203 |
0:76427232f435
|
80
|
BYTE drv; /* Physical drive number */
|
| emh203 |
0:76427232f435
|
81
|
BYTE csize; /* Sectors per cluster (1,2,4...128) */
|
| emh203 |
0:76427232f435
|
82
|
BYTE n_fats; /* Number of FAT copies (1,2) */
|
| emh203 |
0:76427232f435
|
83
|
BYTE wflag; /* win[] dirty flag (1:must be written back) */
|
| emh203 |
0:76427232f435
|
84
|
BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
|
| emh203 |
0:76427232f435
|
85
|
WORD id; /* File system mount ID */
|
| emh203 |
0:76427232f435
|
86
|
WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
|
| emh203 |
0:76427232f435
|
87
|
#if _MAX_SS != 512
|
| emh203 |
0:76427232f435
|
88
|
WORD ssize; /* Bytes per sector (512, 1024, 2048 or 4096) */
|
| emh203 |
0:76427232f435
|
89
|
#endif
|
| emh203 |
0:76427232f435
|
90
|
#if _FS_REENTRANT
|
| emh203 |
0:76427232f435
|
91
|
_SYNC_t sobj; /* Identifier of sync object */
|
| emh203 |
0:76427232f435
|
92
|
#endif
|
| emh203 |
0:76427232f435
|
93
|
#if !_FS_READONLY
|
| emh203 |
0:76427232f435
|
94
|
DWORD last_clust; /* Last allocated cluster */
|
| emh203 |
0:76427232f435
|
95
|
DWORD free_clust; /* Number of free clusters */
|
| emh203 |
0:76427232f435
|
96
|
DWORD fsi_sector; /* fsinfo sector (FAT32) */
|
| emh203 |
0:76427232f435
|
97
|
#endif
|
| emh203 |
0:76427232f435
|
98
|
#if _FS_RPATH
|
| emh203 |
0:76427232f435
|
99
|
DWORD cdir; /* Current directory start cluster (0:root) */
|
| emh203 |
0:76427232f435
|
100
|
#endif
|
| emh203 |
0:76427232f435
|
101
|
DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
|
| emh203 |
0:76427232f435
|
102
|
DWORD fsize; /* Sectors per FAT */
|
| emh203 |
0:76427232f435
|
103
|
DWORD fatbase; /* FAT start sector */
|
| emh203 |
0:76427232f435
|
104
|
DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
|
| emh203 |
0:76427232f435
|
105
|
DWORD database; /* Data start sector */
|
| emh203 |
0:76427232f435
|
106
|
DWORD winsect; /* Current sector appearing in the win[] */
|
| emh203 |
0:76427232f435
|
107
|
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
|
| emh203 |
0:76427232f435
|
108
|
} FATFS;
|
| emh203 |
0:76427232f435
|
109
|
|
| emh203 |
0:76427232f435
|
110
|
|
| emh203 |
0:76427232f435
|
111
|
|
| emh203 |
0:76427232f435
|
112
|
/* File object structure (FIL) */
|
| emh203 |
0:76427232f435
|
113
|
|
| emh203 |
0:76427232f435
|
114
|
typedef struct {
|
| emh203 |
0:76427232f435
|
115
|
FATFS* fs; /* Pointer to the owner file system object */
|
| emh203 |
0:76427232f435
|
116
|
WORD id; /* Owner file system mount ID */
|
| emh203 |
0:76427232f435
|
117
|
BYTE flag; /* File status flags */
|
| emh203 |
0:76427232f435
|
118
|
BYTE pad1;
|
| emh203 |
0:76427232f435
|
119
|
DWORD fptr; /* File read/write pointer (0 on file open) */
|
| emh203 |
0:76427232f435
|
120
|
DWORD fsize; /* File size */
|
| emh203 |
0:76427232f435
|
121
|
DWORD sclust; /* File start cluster (0 when fsize==0) */
|
| emh203 |
0:76427232f435
|
122
|
DWORD clust; /* Current cluster */
|
| emh203 |
0:76427232f435
|
123
|
DWORD dsect; /* Current data sector */
|
| emh203 |
0:76427232f435
|
124
|
#if !_FS_READONLY
|
| emh203 |
0:76427232f435
|
125
|
DWORD dir_sect; /* Sector containing the directory entry */
|
| emh203 |
0:76427232f435
|
126
|
BYTE* dir_ptr; /* Ponter to the directory entry in the window */
|
| emh203 |
0:76427232f435
|
127
|
#endif
|
| emh203 |
0:76427232f435
|
128
|
#if _USE_FASTSEEK
|
| emh203 |
0:76427232f435
|
129
|
DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
|
| emh203 |
0:76427232f435
|
130
|
#endif
|
| emh203 |
0:76427232f435
|
131
|
#if _FS_SHARE
|
| emh203 |
0:76427232f435
|
132
|
UINT lockid; /* File lock ID (index of file semaphore table) */
|
| emh203 |
0:76427232f435
|
133
|
#endif
|
| emh203 |
0:76427232f435
|
134
|
#if !_FS_TINY
|
| emh203 |
0:76427232f435
|
135
|
BYTE buf[_MAX_SS]; /* File data read/write buffer */
|
| emh203 |
0:76427232f435
|
136
|
#endif
|
| emh203 |
0:76427232f435
|
137
|
} FIL;
|
| emh203 |
0:76427232f435
|
138
|
|
| emh203 |
0:76427232f435
|
139
|
|
| emh203 |
0:76427232f435
|
140
|
|
| emh203 |
0:76427232f435
|
141
|
/* Directory object structure (DIR) */
|
| emh203 |
0:76427232f435
|
142
|
|
| emh203 |
0:76427232f435
|
143
|
typedef struct {
|
| emh203 |
0:76427232f435
|
144
|
FATFS* fs; /* Pointer to the owner file system object */
|
| emh203 |
0:76427232f435
|
145
|
WORD id; /* Owner file system mount ID */
|
| emh203 |
0:76427232f435
|
146
|
WORD index; /* Current read/write index number */
|
| emh203 |
0:76427232f435
|
147
|
DWORD sclust; /* Table start cluster (0:Root dir) */
|
| emh203 |
0:76427232f435
|
148
|
DWORD clust; /* Current cluster */
|
| emh203 |
0:76427232f435
|
149
|
DWORD sect; /* Current sector */
|
| emh203 |
0:76427232f435
|
150
|
BYTE* dir; /* Pointer to the current SFN entry in the win[] */
|
| emh203 |
0:76427232f435
|
151
|
BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
|
| emh203 |
0:76427232f435
|
152
|
#if _USE_LFN
|
| emh203 |
0:76427232f435
|
153
|
WCHAR* lfn; /* Pointer to the LFN working buffer */
|
| emh203 |
0:76427232f435
|
154
|
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
|
| emh203 |
0:76427232f435
|
155
|
#endif
|
| emh203 |
0:76427232f435
|
156
|
} eDIR;
|
| emh203 |
0:76427232f435
|
157
|
|
| emh203 |
0:76427232f435
|
158
|
|
| emh203 |
0:76427232f435
|
159
|
|
| emh203 |
0:76427232f435
|
160
|
/* File status structure (FILINFO) */
|
| emh203 |
0:76427232f435
|
161
|
|
| emh203 |
0:76427232f435
|
162
|
typedef struct {
|
| emh203 |
0:76427232f435
|
163
|
DWORD fsize; /* File size */
|
| emh203 |
0:76427232f435
|
164
|
WORD fdate; /* Last modified date */
|
| emh203 |
0:76427232f435
|
165
|
WORD ftime; /* Last modified time */
|
| emh203 |
0:76427232f435
|
166
|
BYTE fattrib; /* Attribute */
|
| emh203 |
0:76427232f435
|
167
|
TCHAR fname[13]; /* Short file name (8.3 format) */
|
| emh203 |
0:76427232f435
|
168
|
#if _USE_LFN
|
| emh203 |
0:76427232f435
|
169
|
TCHAR* lfname; /* Pointer to the LFN buffer */
|
| emh203 |
0:76427232f435
|
170
|
UINT lfsize; /* Size of LFN buffer in TCHAR */
|
| emh203 |
0:76427232f435
|
171
|
#endif
|
| emh203 |
0:76427232f435
|
172
|
} FILINFO;
|
| emh203 |
0:76427232f435
|
173
|
|
| emh203 |
0:76427232f435
|
174
|
|
| emh203 |
0:76427232f435
|
175
|
|
| emh203 |
0:76427232f435
|
176
|
/* File function return code (FRESULT) */
|
| emh203 |
0:76427232f435
|
177
|
|
| emh203 |
0:76427232f435
|
178
|
typedef enum {
|
| emh203 |
0:76427232f435
|
179
|
FR_OK = 0, /* (0) Succeeded */
|
| emh203 |
0:76427232f435
|
180
|
FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */
|
| emh203 |
0:76427232f435
|
181
|
FR_INT_ERR, /* (2) Assertion failed */
|
| emh203 |
0:76427232f435
|
182
|
FR_NOT_READY, /* (3) The physical drive cannot work */
|
| emh203 |
0:76427232f435
|
183
|
FR_NO_FILE, /* (4) Could not find the file */
|
| emh203 |
0:76427232f435
|
184
|
FR_NO_PATH, /* (5) Could not find the path */
|
| emh203 |
0:76427232f435
|
185
|
FR_INVALID_NAME, /* (6) The path name format is invalid */
|
| emh203 |
0:76427232f435
|
186
|
FR_DENIED, /* (7) Acces denied due to prohibited access or directory full */
|
| emh203 |
0:76427232f435
|
187
|
FR_EXIST, /* (8) Acces denied due to prohibited access */
|
| emh203 |
0:76427232f435
|
188
|
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
|
| emh203 |
0:76427232f435
|
189
|
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
|
| emh203 |
0:76427232f435
|
190
|
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
|
| emh203 |
0:76427232f435
|
191
|
FR_NOT_ENABLED, /* (12) The volume has no work area */
|
| emh203 |
0:76427232f435
|
192
|
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
|
| emh203 |
0:76427232f435
|
193
|
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
|
| emh203 |
0:76427232f435
|
194
|
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
|
| emh203 |
0:76427232f435
|
195
|
FR_LOCKED, /* (16) The operation is rejected according to the file shareing policy */
|
| emh203 |
0:76427232f435
|
196
|
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
|
| emh203 |
0:76427232f435
|
197
|
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
|
| emh203 |
0:76427232f435
|
198
|
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */
|
| emh203 |
0:76427232f435
|
199
|
} FRESULT;
|
| emh203 |
0:76427232f435
|
200
|
|
| emh203 |
0:76427232f435
|
201
|
|
| emh203 |
0:76427232f435
|
202
|
|
| emh203 |
0:76427232f435
|
203
|
/*--------------------------------------------------------------*/
|
| emh203 |
0:76427232f435
|
204
|
/* FatFs module application interface */
|
| emh203 |
0:76427232f435
|
205
|
|
| emh203 |
0:76427232f435
|
206
|
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
|
| emh203 |
0:76427232f435
|
207
|
FRESULT f_open (FIL*, const TCHAR*, BYTE); /* Open or create a file */
|
| emh203 |
0:76427232f435
|
208
|
FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
|
| emh203 |
0:76427232f435
|
209
|
FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
|
| emh203 |
0:76427232f435
|
210
|
FRESULT f_close (FIL*); /* Close an open file object */
|
| emh203 |
0:76427232f435
|
211
|
FRESULT f_opendir (eDIR*, const TCHAR*); /* Open an existing directory */
|
| emh203 |
0:76427232f435
|
212
|
FRESULT f_readdir (eDIR*, FILINFO*); /* Read a directory item */
|
| emh203 |
0:76427232f435
|
213
|
FRESULT f_stat (const TCHAR*, FILINFO*); /* Get file status */
|
| emh203 |
0:76427232f435
|
214
|
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
|
| emh203 |
0:76427232f435
|
215
|
FRESULT f_getfree (const TCHAR*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
|
| emh203 |
0:76427232f435
|
216
|
FRESULT f_truncate (FIL*); /* Truncate file */
|
| emh203 |
0:76427232f435
|
217
|
FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
|
| emh203 |
0:76427232f435
|
218
|
FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */
|
| emh203 |
0:76427232f435
|
219
|
FRESULT f_mkdir (const TCHAR*); /* Create a new directory */
|
| emh203 |
0:76427232f435
|
220
|
FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attriburte of the file/dir */
|
| emh203 |
0:76427232f435
|
221
|
FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change timestamp of the file/dir */
|
| emh203 |
0:76427232f435
|
222
|
FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */
|
| emh203 |
0:76427232f435
|
223
|
FRESULT f_chdrive (BYTE); /* Change current drive */
|
| emh203 |
0:76427232f435
|
224
|
FRESULT f_chdir (const TCHAR*); /* Change current directory */
|
| emh203 |
0:76427232f435
|
225
|
FRESULT f_getcwd (TCHAR*, UINT); /* Get current directory */
|
| emh203 |
0:76427232f435
|
226
|
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
|
| emh203 |
0:76427232f435
|
227
|
FRESULT f_mkfs (BYTE, BYTE, UINT); /* Create a file system on the drive */
|
| emh203 |
0:76427232f435
|
228
|
FRESULT f_fdisk (BYTE, const DWORD[], void*); /* Divide a physical drive into some partitions */
|
| emh203 |
0:76427232f435
|
229
|
int f_putc (TCHAR, FIL*); /* Put a character to the file */
|
| emh203 |
0:76427232f435
|
230
|
int f_puts (const TCHAR*, FIL*); /* Put a string to the file */
|
| emh203 |
0:76427232f435
|
231
|
int f_printf (FIL*, const TCHAR*, ...); /* Put a formatted string to the file */
|
| emh203 |
0:76427232f435
|
232
|
TCHAR* f_gets (TCHAR*, int, FIL*); /* Get a string from the file */
|
| emh203 |
0:76427232f435
|
233
|
|
| emh203 |
0:76427232f435
|
234
|
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
|
| emh203 |
0:76427232f435
|
235
|
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
|
| emh203 |
0:76427232f435
|
236
|
#define f_tell(fp) ((fp)->fptr)
|
| emh203 |
0:76427232f435
|
237
|
#define f_size(fp) ((fp)->fsize)
|
| emh203 |
0:76427232f435
|
238
|
|
| emh203 |
0:76427232f435
|
239
|
#ifndef EOF
|
| emh203 |
0:76427232f435
|
240
|
#define EOF (-1)
|
| emh203 |
0:76427232f435
|
241
|
#endif
|
| emh203 |
0:76427232f435
|
242
|
|
| emh203 |
0:76427232f435
|
243
|
|
| emh203 |
0:76427232f435
|
244
|
|
| emh203 |
0:76427232f435
|
245
|
|
| emh203 |
0:76427232f435
|
246
|
/*--------------------------------------------------------------*/
|
| emh203 |
0:76427232f435
|
247
|
/* Additional user defined functions */
|
| emh203 |
0:76427232f435
|
248
|
|
| emh203 |
0:76427232f435
|
249
|
/* RTC function */
|
| emh203 |
0:76427232f435
|
250
|
#if !_FS_READONLY
|
| emh203 |
0:76427232f435
|
251
|
//DWORD get_fattime (void);
|
| emh203 |
0:76427232f435
|
252
|
#endif
|
| emh203 |
0:76427232f435
|
253
|
|
| emh203 |
0:76427232f435
|
254
|
/* Unicode support functions */
|
| emh203 |
0:76427232f435
|
255
|
#if _USE_LFN /* Unicode - OEM code conversion */
|
| emh203 |
0:76427232f435
|
256
|
WCHAR ff_convert (WCHAR, UINT); /* OEM-Unicode bidirectional conversion */
|
| emh203 |
0:76427232f435
|
257
|
WCHAR ff_wtoupper (WCHAR); /* Unicode upper-case conversion */
|
| emh203 |
0:76427232f435
|
258
|
#if _USE_LFN == 3 /* Memory functions */
|
| emh203 |
0:76427232f435
|
259
|
void* ff_memalloc (UINT); /* Allocate memory block */
|
| emh203 |
0:76427232f435
|
260
|
void ff_memfree (void*); /* Free memory block */
|
| emh203 |
0:76427232f435
|
261
|
#endif
|
| emh203 |
0:76427232f435
|
262
|
#endif
|
| emh203 |
0:76427232f435
|
263
|
|
| emh203 |
0:76427232f435
|
264
|
/* Sync functions */
|
| emh203 |
0:76427232f435
|
265
|
#if _FS_REENTRANT
|
| emh203 |
0:76427232f435
|
266
|
int ff_cre_syncobj (BYTE, _SYNC_t*);/* Create a sync object */
|
| emh203 |
0:76427232f435
|
267
|
int ff_req_grant (_SYNC_t); /* Lock sync object */
|
| emh203 |
0:76427232f435
|
268
|
void ff_rel_grant (_SYNC_t); /* Unlock sync object */
|
| emh203 |
0:76427232f435
|
269
|
int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
|
| emh203 |
0:76427232f435
|
270
|
#endif
|
| emh203 |
0:76427232f435
|
271
|
|
| emh203 |
0:76427232f435
|
272
|
|
| emh203 |
0:76427232f435
|
273
|
|
| emh203 |
0:76427232f435
|
274
|
|
| emh203 |
0:76427232f435
|
275
|
/*--------------------------------------------------------------*/
|
| emh203 |
0:76427232f435
|
276
|
/* Flags and offset address */
|
| emh203 |
0:76427232f435
|
277
|
|
| emh203 |
0:76427232f435
|
278
|
|
| emh203 |
0:76427232f435
|
279
|
/* File access control and file status flags (FIL.flag) */
|
| emh203 |
0:76427232f435
|
280
|
|
| emh203 |
0:76427232f435
|
281
|
#define FA_READ 0x01
|
| emh203 |
0:76427232f435
|
282
|
#define FA_OPEN_EXISTING 0x00
|
| emh203 |
0:76427232f435
|
283
|
#define FA__ERROR 0x80
|
| emh203 |
0:76427232f435
|
284
|
|
| emh203 |
0:76427232f435
|
285
|
#if !_FS_READONLY
|
| emh203 |
0:76427232f435
|
286
|
#define FA_WRITE 0x02
|
| emh203 |
0:76427232f435
|
287
|
#define FA_CREATE_NEW 0x04
|
| emh203 |
0:76427232f435
|
288
|
#define FA_CREATE_ALWAYS 0x08
|
| emh203 |
0:76427232f435
|
289
|
#define FA_OPEN_ALWAYS 0x10
|
| emh203 |
0:76427232f435
|
290
|
#define FA__WRITTEN 0x20
|
| emh203 |
0:76427232f435
|
291
|
#define FA__DIRTY 0x40
|
| emh203 |
0:76427232f435
|
292
|
#endif
|
| emh203 |
0:76427232f435
|
293
|
|
| emh203 |
0:76427232f435
|
294
|
|
| emh203 |
0:76427232f435
|
295
|
/* FAT sub type (FATFS.fs_type) */
|
| emh203 |
0:76427232f435
|
296
|
|
| emh203 |
0:76427232f435
|
297
|
#define FS_FAT12 1
|
| emh203 |
0:76427232f435
|
298
|
#define FS_FAT16 2
|
| emh203 |
0:76427232f435
|
299
|
#define FS_FAT32 3
|
| emh203 |
0:76427232f435
|
300
|
|
| emh203 |
0:76427232f435
|
301
|
|
| emh203 |
0:76427232f435
|
302
|
/* File attribute bits for directory entry */
|
| emh203 |
0:76427232f435
|
303
|
|
| emh203 |
0:76427232f435
|
304
|
#define AM_RDO 0x01 /* Read only */
|
| emh203 |
0:76427232f435
|
305
|
#define AM_HID 0x02 /* Hidden */
|
| emh203 |
0:76427232f435
|
306
|
#define AM_SYS 0x04 /* System */
|
| emh203 |
0:76427232f435
|
307
|
#define AM_VOL 0x08 /* Volume label */
|
| emh203 |
0:76427232f435
|
308
|
#define AM_LFN 0x0F /* LFN entry */
|
| emh203 |
0:76427232f435
|
309
|
#define AM_DIR 0x10 /* Directory */
|
| emh203 |
0:76427232f435
|
310
|
#define AM_ARC 0x20 /* Archive */
|
| emh203 |
0:76427232f435
|
311
|
#define AM_MASK 0x3F /* Mask of defined bits */
|
| emh203 |
0:76427232f435
|
312
|
|
| emh203 |
0:76427232f435
|
313
|
|
| emh203 |
0:76427232f435
|
314
|
/* Fast seek feature */
|
| emh203 |
0:76427232f435
|
315
|
#define CREATE_LINKMAP 0xFFFFFFFF
|
| emh203 |
0:76427232f435
|
316
|
|
| emh203 |
0:76427232f435
|
317
|
|
| emh203 |
0:76427232f435
|
318
|
|
| emh203 |
0:76427232f435
|
319
|
/*--------------------------------*/
|
| emh203 |
0:76427232f435
|
320
|
/* Multi-byte word access macros */
|
| emh203 |
0:76427232f435
|
321
|
|
| emh203 |
0:76427232f435
|
322
|
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
|
| emh203 |
0:76427232f435
|
323
|
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
|
| emh203 |
0:76427232f435
|
324
|
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
|
| emh203 |
0:76427232f435
|
325
|
#define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
|
| emh203 |
0:76427232f435
|
326
|
#define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
|
| emh203 |
0:76427232f435
|
327
|
#else /* Use byte-by-byte access to the FAT structure */
|
| emh203 |
0:76427232f435
|
328
|
#define LD_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
|
| emh203 |
0:76427232f435
|
329
|
#define LD_DWORD(ptr) (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
|
| emh203 |
0:76427232f435
|
330
|
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
|
| emh203 |
0:76427232f435
|
331
|
#define ST_DWORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
|
| emh203 |
0:76427232f435
|
332
|
#endif
|
| emh203 |
0:76427232f435
|
333
|
|
| emh203 |
0:76427232f435
|
334
|
#ifdef __cplusplus
|
| emh203 |
0:76427232f435
|
335
|
}
|
| emh203 |
0:76427232f435
|
336
|
#endif
|
| emh203 |
0:76427232f435
|
337
|
|
| emh203 |
0:76427232f435
|
338
|
#endif /* _FATFS */
|