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