Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:54:50 2016 +0000
Revision:
1:d96dbedaebdb
Parent:
0:6c56fb4bc5f0
Removed extra directories for other platforms

Who changed what in which revision?

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