goutham dugyala / FATFilesystem_Axelta

Dependents:   SDFileSystem_Axelta

Committer:
gauthibit
Date:
Fri Nov 11 06:39:00 2016 +0000
Revision:
0:6547fbc0f7c0
FAT

Who changed what in which revision?

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