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