publication inutile mais obligée

Committer:
adrevong
Date:
Tue Jan 28 11:14:21 2020 +0000
Revision:
0:8b2a15992487

        

Who changed what in which revision?

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