Local copy of the FatFileSystem.

Dependents:   SimpleWaveRecorderPlayer y_CameraC1098_ES_01 _test_SDHCFileSystem Application-SimpleWaveRecorderPlayerGenerator ... more

Committer:
shintamainjp
Date:
Sat Apr 14 02:24:08 2012 +0000
Revision:
0:8c55801ce311
Initial version.

Who changed what in which revision?

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