temp

Dependencies:   mbed SDFileSystem MS5607 ADXL345_I2C FATFileSystem

Committer:
IKobayashi
Date:
Mon Mar 16 23:37:42 2020 +0900
Revision:
0:c88c3b616c00
copy

Who changed what in which revision?

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