Lab Checkoff

Dependencies:   SDFileSystem TextLCD mbed-rtos mbed wave_player FATFileSystem

Committer:
doubster
Date:
Wed Nov 13 20:00:28 2013 +0000
Revision:
0:67dbd54e60d4
Lab Checkoff

Who changed what in which revision?

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