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