EA BaseBoard, playing wav, PC see\'s SD-card through USB port.

Dependencies:   mbed

Committer:
Lerche
Date:
Tue Nov 22 05:45:58 2011 +0000
Revision:
0:fef366d2ed20
Thanks to those who provided EA_WavPlayer and USB_MSC

Who changed what in which revision?

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