-

Dependents:   RSALB_hbridge_helloworld RSALB_lobster WavPlayer_test AudioCODEC_HelloWorld ... more

Fork of FatFileSystemCpp by Igor Skochinsky

Committer:
p07gbar
Date:
Wed Sep 19 11:03:35 2012 +0000
Revision:
2:e869ee8f3c3d
Parent:
0:6ceefe1c53e4
-

Who changed what in which revision?

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