Some library needed for things? Licence unknown

Dependents:   LEDSign_SimpleSD

Committer:
TBSliver
Date:
Sun Jul 29 10:07:38 2012 +0000
Revision:
0:e4324838bc6f
[mbed] converted /LEDSign_SimpleSD/FatFileSystem

Who changed what in which revision?

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