help :(

Dependencies:   FFT

Committer:
annieluo2
Date:
Wed Dec 02 18:02:03 2020 +0000
Revision:
0:d6c9b09b4042
boo

Who changed what in which revision?

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