James Heavey / Mbed 2 deprecated 2665-Breakout-Game

Dependencies:   mbed

Committer:
jamesheavey
Date:
Tue Jan 05 01:14:11 2021 +0000
Revision:
0:92b180c8d407
test

Who changed what in which revision?

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