dd

Dependencies:   C12832 mbed

Committer:
pfe
Date:
Wed Apr 08 08:27:55 2015 +0000
Revision:
0:caecb0d1e7d3
ddd

Who changed what in which revision?

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