none

Dependents:   4180_Project YNU_MPU YNU_MPUd2 YNU_MPUd2 ... more

Fork of FatFileSystem by mbed unsupported

Committer:
kpatel70
Date:
Fri Dec 07 17:50:06 2012 +0000
Revision:
4:b12f19dfe9fc
Parent:
0:97df4125f18d
None

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_unsupported 0:97df4125f18d 1 /*--------------------------------------------------------------------------/
mbed_unsupported 0:97df4125f18d 2 / FatFs - FAT file system module include file R0.06 (C)ChaN, 2008
mbed_unsupported 0:97df4125f18d 3 /---------------------------------------------------------------------------/
mbed_unsupported 0:97df4125f18d 4 / FatFs module is an experimenal project to implement FAT file system to
mbed_unsupported 0:97df4125f18d 5 / cheap microcontrollers. This is a free software and is opened for education,
mbed_unsupported 0:97df4125f18d 6 / research and development under license policy of following trems.
mbed_unsupported 0:97df4125f18d 7 /
mbed_unsupported 0:97df4125f18d 8 / Copyright (C) 2008, ChaN, all right reserved.
mbed_unsupported 0:97df4125f18d 9 /
mbed_unsupported 0:97df4125f18d 10 / * The FatFs module is a free software and there is no warranty.
mbed_unsupported 0:97df4125f18d 11 / * You can use, modify and/or redistribute it for personal, non-profit or
mbed_unsupported 0:97df4125f18d 12 / commercial use without any restriction under your responsibility.
mbed_unsupported 0:97df4125f18d 13 / * Redistributions of source code must retain the above copyright notice.
mbed_unsupported 0:97df4125f18d 14 /
mbed_unsupported 0:97df4125f18d 15 /---------------------------------------------------------------------------*/
mbed_unsupported 0:97df4125f18d 16
mbed_unsupported 0:97df4125f18d 17 #ifndef _FATFS
mbed_unsupported 0:97df4125f18d 18
kpatel70 4:b12f19dfe9fc 19 #define _MCU_ENDIAN 2
mbed_unsupported 0:97df4125f18d 20 /* The _MCU_ENDIAN defines which access method is used to the FAT structure.
mbed_unsupported 0:97df4125f18d 21 / 1: Enable word access.
mbed_unsupported 0:97df4125f18d 22 / 2: Disable word access and use byte-by-byte access instead.
mbed_unsupported 0:97df4125f18d 23 / When the architectural byte order of the MCU is big-endian and/or address
mbed_unsupported 0:97df4125f18d 24 / miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
mbed_unsupported 0:97df4125f18d 25 / If it is not the case, it can also be set to 1 for good code efficiency. */
mbed_unsupported 0:97df4125f18d 26
kpatel70 4:b12f19dfe9fc 27 #define _FS_READONLY 0
mbed_unsupported 0:97df4125f18d 28 /* Setting _FS_READONLY to 1 defines read only configuration. This removes
mbed_unsupported 0:97df4125f18d 29 / writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
mbed_unsupported 0:97df4125f18d 30 / f_truncate and useless f_getfree. */
mbed_unsupported 0:97df4125f18d 31
kpatel70 4:b12f19dfe9fc 32 #define _FS_MINIMIZE 0
mbed_unsupported 0:97df4125f18d 33 /* The _FS_MINIMIZE option defines minimization level to remove some functions.
mbed_unsupported 0:97df4125f18d 34 / 0: Full function.
mbed_unsupported 0:97df4125f18d 35 / 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
mbed_unsupported 0:97df4125f18d 36 / 2: f_opendir and f_readdir are removed in addition to level 1.
mbed_unsupported 0:97df4125f18d 37 / 3: f_lseek is removed in addition to level 2. */
mbed_unsupported 0:97df4125f18d 38
kpatel70 4:b12f19dfe9fc 39 #define _USE_STRFUNC 0
mbed_unsupported 0:97df4125f18d 40 /* To enable string functions, set _USE_STRFUNC to 1 or 2. */
mbed_unsupported 0:97df4125f18d 41
kpatel70 4:b12f19dfe9fc 42 #define _USE_MKFS 1
mbed_unsupported 0:97df4125f18d 43 /* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is
mbed_unsupported 0:97df4125f18d 44 / enabled. */
mbed_unsupported 0:97df4125f18d 45
kpatel70 4:b12f19dfe9fc 46 #define _DRIVES 4
mbed_unsupported 0:97df4125f18d 47 /* Number of logical drives to be used. This affects the size of internal table. */
mbed_unsupported 0:97df4125f18d 48
kpatel70 4:b12f19dfe9fc 49 #define _MULTI_PARTITION 0
mbed_unsupported 0:97df4125f18d 50 /* When _MULTI_PARTITION is set to 0, each logical drive is bound to same
mbed_unsupported 0:97df4125f18d 51 / physical drive number and can mount only 1st primaly partition. When it is
mbed_unsupported 0:97df4125f18d 52 / set to 1, each logical drive can mount a partition listed in Drives[]. */
mbed_unsupported 0:97df4125f18d 53
kpatel70 4:b12f19dfe9fc 54 #define _USE_FSINFO 0
mbed_unsupported 0:97df4125f18d 55 /* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */
mbed_unsupported 0:97df4125f18d 56
kpatel70 4:b12f19dfe9fc 57 #define _USE_SJIS 1
mbed_unsupported 0:97df4125f18d 58 /* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
mbed_unsupported 0:97df4125f18d 59 / only US-ASCII(7bit) code can be accepted as file/directory name. */
mbed_unsupported 0:97df4125f18d 60
kpatel70 4:b12f19dfe9fc 61 #define _USE_NTFLAG 1
mbed_unsupported 0:97df4125f18d 62 /* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
mbed_unsupported 0:97df4125f18d 63 / Note that the files are always accessed in case insensitive. */
mbed_unsupported 0:97df4125f18d 64
mbed_unsupported 0:97df4125f18d 65
mbed_unsupported 0:97df4125f18d 66 #include "integer.h"
mbed_unsupported 0:97df4125f18d 67
mbed_unsupported 0:97df4125f18d 68 #ifdef __cplusplus
mbed_unsupported 0:97df4125f18d 69 extern "C" {
mbed_unsupported 0:97df4125f18d 70 #endif
mbed_unsupported 0:97df4125f18d 71
mbed_unsupported 0:97df4125f18d 72 /* Definitions corresponds to multiple sector size (not tested) */
kpatel70 4:b12f19dfe9fc 73 #define S_MAX_SIZ 512U /* Do not change */
mbed_unsupported 0:97df4125f18d 74 #if S_MAX_SIZ > 512U
kpatel70 4:b12f19dfe9fc 75 #define SS(fs) ((fs)->s_size)
mbed_unsupported 0:97df4125f18d 76 #else
kpatel70 4:b12f19dfe9fc 77 #define SS(fs) 512U
mbed_unsupported 0:97df4125f18d 78 #endif
mbed_unsupported 0:97df4125f18d 79
mbed_unsupported 0:97df4125f18d 80
mbed_unsupported 0:97df4125f18d 81 /* File system object structure */
mbed_unsupported 0:97df4125f18d 82 typedef struct _FATFS {
kpatel70 4:b12f19dfe9fc 83 WORD id; /* File system mount ID */
kpatel70 4:b12f19dfe9fc 84 WORD n_rootdir; /* Number of root directory entries */
kpatel70 4:b12f19dfe9fc 85 DWORD winsect; /* Current sector appearing in the win[] */
kpatel70 4:b12f19dfe9fc 86 DWORD sects_fat; /* Sectors per fat */
kpatel70 4:b12f19dfe9fc 87 DWORD max_clust; /* Maximum cluster# + 1 */
kpatel70 4:b12f19dfe9fc 88 DWORD fatbase; /* FAT start sector */
kpatel70 4:b12f19dfe9fc 89 DWORD dirbase; /* Root directory start sector (cluster# for FAT32) */
kpatel70 4:b12f19dfe9fc 90 DWORD database; /* Data start sector */
mbed_unsupported 0:97df4125f18d 91 #if !_FS_READONLY
kpatel70 4:b12f19dfe9fc 92 DWORD last_clust; /* Last allocated cluster */
kpatel70 4:b12f19dfe9fc 93 DWORD free_clust; /* Number of free clusters */
mbed_unsupported 0:97df4125f18d 94 #if _USE_FSINFO
kpatel70 4:b12f19dfe9fc 95 DWORD fsi_sector; /* fsinfo sector */
kpatel70 4:b12f19dfe9fc 96 BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
kpatel70 4:b12f19dfe9fc 97 BYTE pad2;
mbed_unsupported 0:97df4125f18d 98 #endif
mbed_unsupported 0:97df4125f18d 99 #endif
kpatel70 4:b12f19dfe9fc 100 BYTE fs_type; /* FAT sub type */
kpatel70 4:b12f19dfe9fc 101 BYTE csize; /* Number of sectors per cluster */
mbed_unsupported 0:97df4125f18d 102 #if S_MAX_SIZ > 512U
kpatel70 4:b12f19dfe9fc 103 WORD s_size; /* Sector size */
mbed_unsupported 0:97df4125f18d 104 #endif
kpatel70 4:b12f19dfe9fc 105 BYTE n_fats; /* Number of FAT copies */
kpatel70 4:b12f19dfe9fc 106 BYTE drive; /* Physical drive number */
kpatel70 4:b12f19dfe9fc 107 BYTE winflag; /* win[] dirty flag (1:must be written back) */
kpatel70 4:b12f19dfe9fc 108 BYTE pad1;
kpatel70 4:b12f19dfe9fc 109 BYTE win[S_MAX_SIZ]; /* Disk access window for Directory/FAT */
mbed_unsupported 0:97df4125f18d 110 } FATFS;
mbed_unsupported 0:97df4125f18d 111
mbed_unsupported 0:97df4125f18d 112
mbed_unsupported 0:97df4125f18d 113 /* Directory object structure */
mbed_unsupported 0:97df4125f18d 114 typedef struct _DIR {
kpatel70 4:b12f19dfe9fc 115 WORD id; /* Owner file system mount ID */
kpatel70 4:b12f19dfe9fc 116 WORD index; /* Current index */
kpatel70 4:b12f19dfe9fc 117 FATFS* fs; /* Pointer to the owner file system object */
kpatel70 4:b12f19dfe9fc 118 DWORD sclust; /* Start cluster */
kpatel70 4:b12f19dfe9fc 119 DWORD clust; /* Current cluster */
kpatel70 4:b12f19dfe9fc 120 DWORD sect; /* Current sector */
mbed_unsupported 0:97df4125f18d 121 } FATFS_DIR;
mbed_unsupported 0:97df4125f18d 122
mbed_unsupported 0:97df4125f18d 123
mbed_unsupported 0:97df4125f18d 124 /* File object structure */
mbed_unsupported 0:97df4125f18d 125 typedef struct _FIL {
kpatel70 4:b12f19dfe9fc 126 WORD id; /* Owner file system mount ID */
kpatel70 4:b12f19dfe9fc 127 BYTE flag; /* File status flags */
kpatel70 4:b12f19dfe9fc 128 BYTE csect; /* Sector address in the cluster */
kpatel70 4:b12f19dfe9fc 129 FATFS* fs; /* Pointer to the owner file system object */
kpatel70 4:b12f19dfe9fc 130 DWORD fptr; /* File R/W pointer */
kpatel70 4:b12f19dfe9fc 131 DWORD fsize; /* File size */
kpatel70 4:b12f19dfe9fc 132 DWORD org_clust; /* File start cluster */
kpatel70 4:b12f19dfe9fc 133 DWORD curr_clust; /* Current cluster */
kpatel70 4:b12f19dfe9fc 134 DWORD curr_sect; /* Current sector */
mbed_unsupported 0:97df4125f18d 135 #if _FS_READONLY == 0
kpatel70 4:b12f19dfe9fc 136 DWORD dir_sect; /* Sector containing the directory entry */
kpatel70 4:b12f19dfe9fc 137 BYTE* dir_ptr; /* Ponter to the directory entry in the window */
mbed_unsupported 0:97df4125f18d 138 #endif
kpatel70 4:b12f19dfe9fc 139 BYTE buffer[S_MAX_SIZ]; /* File R/W buffer */
mbed_unsupported 0:97df4125f18d 140 } FIL;
mbed_unsupported 0:97df4125f18d 141
mbed_unsupported 0:97df4125f18d 142
mbed_unsupported 0:97df4125f18d 143 /* File status structure */
mbed_unsupported 0:97df4125f18d 144 typedef struct _FILINFO {
kpatel70 4:b12f19dfe9fc 145 DWORD fsize; /* Size */
kpatel70 4:b12f19dfe9fc 146 WORD fdate; /* Date */
kpatel70 4:b12f19dfe9fc 147 WORD ftime; /* Time */
kpatel70 4:b12f19dfe9fc 148 BYTE fattrib; /* Attribute */
kpatel70 4:b12f19dfe9fc 149 char fname[8+1+3+1]; /* Name (8.3 format) */
mbed_unsupported 0:97df4125f18d 150 } FILINFO;
mbed_unsupported 0:97df4125f18d 151
mbed_unsupported 0:97df4125f18d 152
mbed_unsupported 0:97df4125f18d 153
mbed_unsupported 0:97df4125f18d 154 /* Definitions corresponds to multi partition */
mbed_unsupported 0:97df4125f18d 155
kpatel70 4:b12f19dfe9fc 156 #if _MULTI_PARTITION != 0 /* Multiple partition cfg */
mbed_unsupported 0:97df4125f18d 157
mbed_unsupported 0:97df4125f18d 158 typedef struct _PARTITION {
kpatel70 4:b12f19dfe9fc 159 BYTE pd; /* Physical drive # (0-255) */
kpatel70 4:b12f19dfe9fc 160 BYTE pt; /* Partition # (0-3) */
mbed_unsupported 0:97df4125f18d 161 } PARTITION;
mbed_unsupported 0:97df4125f18d 162 extern
kpatel70 4:b12f19dfe9fc 163 const PARTITION Drives[]; /* Logical drive# to physical location conversion table */
kpatel70 4:b12f19dfe9fc 164 #define LD2PD(drv) (Drives[drv].pd) /* Get physical drive# */
kpatel70 4:b12f19dfe9fc 165 #define LD2PT(drv) (Drives[drv].pt) /* Get partition# */
mbed_unsupported 0:97df4125f18d 166
kpatel70 4:b12f19dfe9fc 167 #else /* Single partition cfg */
mbed_unsupported 0:97df4125f18d 168
kpatel70 4:b12f19dfe9fc 169 #define LD2PD(drv) (drv) /* Physical drive# is equal to logical drive# */
kpatel70 4:b12f19dfe9fc 170 #define LD2PT(drv) 0 /* Always mounts the 1st partition */
mbed_unsupported 0:97df4125f18d 171
mbed_unsupported 0:97df4125f18d 172 #endif
mbed_unsupported 0:97df4125f18d 173
mbed_unsupported 0:97df4125f18d 174
mbed_unsupported 0:97df4125f18d 175 /* File function return code (FRESULT) */
mbed_unsupported 0:97df4125f18d 176
mbed_unsupported 0:97df4125f18d 177 typedef enum {
kpatel70 4:b12f19dfe9fc 178 FR_OK = 0, /* 0 */
kpatel70 4:b12f19dfe9fc 179 FR_NOT_READY, /* 1 */
kpatel70 4:b12f19dfe9fc 180 FR_NO_FILE, /* 2 */
kpatel70 4:b12f19dfe9fc 181 FR_NO_PATH, /* 3 */
kpatel70 4:b12f19dfe9fc 182 FR_INVALID_NAME, /* 4 */
kpatel70 4:b12f19dfe9fc 183 FR_INVALID_DRIVE, /* 5 */
kpatel70 4:b12f19dfe9fc 184 FR_DENIED, /* 6 */
kpatel70 4:b12f19dfe9fc 185 FR_EXIST, /* 7 */
kpatel70 4:b12f19dfe9fc 186 FR_RW_ERROR, /* 8 */
kpatel70 4:b12f19dfe9fc 187 FR_WRITE_PROTECTED, /* 9 */
kpatel70 4:b12f19dfe9fc 188 FR_NOT_ENABLED, /* 10 */
kpatel70 4:b12f19dfe9fc 189 FR_NO_FILESYSTEM, /* 11 */
kpatel70 4:b12f19dfe9fc 190 FR_INVALID_OBJECT, /* 12 */
kpatel70 4:b12f19dfe9fc 191 FR_MKFS_ABORTED /* 13 */
mbed_unsupported 0:97df4125f18d 192 } FRESULT;
mbed_unsupported 0:97df4125f18d 193
mbed_unsupported 0:97df4125f18d 194
mbed_unsupported 0:97df4125f18d 195
mbed_unsupported 0:97df4125f18d 196 /*-----------------------------------------------------*/
mbed_unsupported 0:97df4125f18d 197 /* FatFs module application interface */
mbed_unsupported 0:97df4125f18d 198
kpatel70 4:b12f19dfe9fc 199 FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
kpatel70 4:b12f19dfe9fc 200 FRESULT f_open (FIL*, const char*, BYTE); /* Open or create a file */
kpatel70 4:b12f19dfe9fc 201 FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
kpatel70 4:b12f19dfe9fc 202 FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
kpatel70 4:b12f19dfe9fc 203 FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
kpatel70 4:b12f19dfe9fc 204 FRESULT f_close (FIL*); /* Close an open file object */
kpatel70 4:b12f19dfe9fc 205 FRESULT f_opendir (FATFS_DIR*, const char*); /* Open an existing directory */
kpatel70 4:b12f19dfe9fc 206 FRESULT f_readdir (FATFS_DIR*, FILINFO*); /* Read a directory item */
kpatel70 4:b12f19dfe9fc 207 FRESULT f_stat (const char*, FILINFO*); /* Get file status */
kpatel70 4:b12f19dfe9fc 208 FRESULT f_getfree (const char*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
kpatel70 4:b12f19dfe9fc 209 FRESULT f_truncate (FIL*); /* Truncate file */
kpatel70 4:b12f19dfe9fc 210 FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
kpatel70 4:b12f19dfe9fc 211 FRESULT f_unlink (const char*); /* Delete an existing file or directory */
kpatel70 4:b12f19dfe9fc 212 FRESULT f_mkdir (const char*); /* Create a new directory */
kpatel70 4:b12f19dfe9fc 213 FRESULT f_chmod (const char*, BYTE, BYTE); /* Change file/dir attriburte */
kpatel70 4:b12f19dfe9fc 214 FRESULT f_utime (const char*, const FILINFO*); /* Change file/dir timestamp */
kpatel70 4:b12f19dfe9fc 215 FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
kpatel70 4:b12f19dfe9fc 216 FRESULT f_mkfs (BYTE, BYTE, WORD); /* Create a file system on the drive */
mbed_unsupported 0:97df4125f18d 217 #if _USE_STRFUNC
mbed_unsupported 0:97df4125f18d 218 #define feof(fp) ((fp)->fptr == (fp)->fsize)
mbed_unsupported 0:97df4125f18d 219 #define EOF -1
kpatel70 4:b12f19dfe9fc 220 int fputc (int, FIL*); /* Put a character to the file */
kpatel70 4:b12f19dfe9fc 221 int fputs (const char*, FIL*); /* Put a string to the file */
kpatel70 4:b12f19dfe9fc 222 int fprintf (FIL*, const char*, ...); /* Put a formatted string to the file */
kpatel70 4:b12f19dfe9fc 223 char* fgets (char*, int, FIL*); /* Get a string from the file */
mbed_unsupported 0:97df4125f18d 224 #endif
mbed_unsupported 0:97df4125f18d 225
mbed_unsupported 0:97df4125f18d 226 /* User defined function to give a current time to fatfs module */
mbed_unsupported 0:97df4125f18d 227
kpatel70 4:b12f19dfe9fc 228 DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
kpatel70 4:b12f19dfe9fc 229 /* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
mbed_unsupported 0:97df4125f18d 230
mbed_unsupported 0:97df4125f18d 231
mbed_unsupported 0:97df4125f18d 232
mbed_unsupported 0:97df4125f18d 233 /* File access control and file status flags (FIL.flag) */
mbed_unsupported 0:97df4125f18d 234
kpatel70 4:b12f19dfe9fc 235 #define FA_READ 0x01
kpatel70 4:b12f19dfe9fc 236 #define FA_OPEN_EXISTING 0x00
mbed_unsupported 0:97df4125f18d 237 #if _FS_READONLY == 0
kpatel70 4:b12f19dfe9fc 238 #define FA_WRITE 0x02
kpatel70 4:b12f19dfe9fc 239 #define FA_CREATE_NEW 0x04
kpatel70 4:b12f19dfe9fc 240 #define FA_CREATE_ALWAYS 0x08
kpatel70 4:b12f19dfe9fc 241 #define FA_OPEN_ALWAYS 0x10
kpatel70 4:b12f19dfe9fc 242 #define FA__WRITTEN 0x20
kpatel70 4:b12f19dfe9fc 243 #define FA__DIRTY 0x40
mbed_unsupported 0:97df4125f18d 244 #endif
kpatel70 4:b12f19dfe9fc 245 #define FA__ERROR 0x80
mbed_unsupported 0:97df4125f18d 246
mbed_unsupported 0:97df4125f18d 247
mbed_unsupported 0:97df4125f18d 248 /* FAT sub type (FATFS.fs_type) */
mbed_unsupported 0:97df4125f18d 249
kpatel70 4:b12f19dfe9fc 250 #define FS_FAT12 1
kpatel70 4:b12f19dfe9fc 251 #define FS_FAT16 2
kpatel70 4:b12f19dfe9fc 252 #define FS_FAT32 3
mbed_unsupported 0:97df4125f18d 253
mbed_unsupported 0:97df4125f18d 254
mbed_unsupported 0:97df4125f18d 255 /* File attribute bits for directory entry */
mbed_unsupported 0:97df4125f18d 256
kpatel70 4:b12f19dfe9fc 257 #define AM_RDO 0x01 /* Read only */
kpatel70 4:b12f19dfe9fc 258 #define AM_HID 0x02 /* Hidden */
kpatel70 4:b12f19dfe9fc 259 #define AM_SYS 0x04 /* System */
kpatel70 4:b12f19dfe9fc 260 #define AM_VOL 0x08 /* Volume label */
kpatel70 4:b12f19dfe9fc 261 #define AM_LFN 0x0F /* LFN entry */
kpatel70 4:b12f19dfe9fc 262 #define AM_DIR 0x10 /* Directory */
kpatel70 4:b12f19dfe9fc 263 #define AM_ARC 0x20 /* Archive */
mbed_unsupported 0:97df4125f18d 264
mbed_unsupported 0:97df4125f18d 265
mbed_unsupported 0:97df4125f18d 266
mbed_unsupported 0:97df4125f18d 267 /* Offset of FAT structure members */
mbed_unsupported 0:97df4125f18d 268
kpatel70 4:b12f19dfe9fc 269 #define BS_jmpBoot 0
kpatel70 4:b12f19dfe9fc 270 #define BS_OEMName 3
kpatel70 4:b12f19dfe9fc 271 #define BPB_BytsPerSec 11
kpatel70 4:b12f19dfe9fc 272 #define BPB_SecPerClus 13
kpatel70 4:b12f19dfe9fc 273 #define BPB_RsvdSecCnt 14
kpatel70 4:b12f19dfe9fc 274 #define BPB_NumFATs 16
kpatel70 4:b12f19dfe9fc 275 #define BPB_RootEntCnt 17
kpatel70 4:b12f19dfe9fc 276 #define BPB_TotSec16 19
kpatel70 4:b12f19dfe9fc 277 #define BPB_Media 21
kpatel70 4:b12f19dfe9fc 278 #define BPB_FATSz16 22
kpatel70 4:b12f19dfe9fc 279 #define BPB_SecPerTrk 24
kpatel70 4:b12f19dfe9fc 280 #define BPB_NumHeads 26
kpatel70 4:b12f19dfe9fc 281 #define BPB_HiddSec 28
kpatel70 4:b12f19dfe9fc 282 #define BPB_TotSec32 32
kpatel70 4:b12f19dfe9fc 283 #define BS_55AA 510
mbed_unsupported 0:97df4125f18d 284
kpatel70 4:b12f19dfe9fc 285 #define BS_DrvNum 36
kpatel70 4:b12f19dfe9fc 286 #define BS_BootSig 38
kpatel70 4:b12f19dfe9fc 287 #define BS_VolID 39
kpatel70 4:b12f19dfe9fc 288 #define BS_VolLab 43
kpatel70 4:b12f19dfe9fc 289 #define BS_FilSysType 54
mbed_unsupported 0:97df4125f18d 290
kpatel70 4:b12f19dfe9fc 291 #define BPB_FATSz32 36
kpatel70 4:b12f19dfe9fc 292 #define BPB_ExtFlags 40
kpatel70 4:b12f19dfe9fc 293 #define BPB_FSVer 42
kpatel70 4:b12f19dfe9fc 294 #define BPB_RootClus 44
kpatel70 4:b12f19dfe9fc 295 #define BPB_FSInfo 48
kpatel70 4:b12f19dfe9fc 296 #define BPB_BkBootSec 50
kpatel70 4:b12f19dfe9fc 297 #define BS_DrvNum32 64
kpatel70 4:b12f19dfe9fc 298 #define BS_BootSig32 66
kpatel70 4:b12f19dfe9fc 299 #define BS_VolID32 67
kpatel70 4:b12f19dfe9fc 300 #define BS_VolLab32 71
kpatel70 4:b12f19dfe9fc 301 #define BS_FilSysType32 82
mbed_unsupported 0:97df4125f18d 302
kpatel70 4:b12f19dfe9fc 303 #define FSI_LeadSig 0
kpatel70 4:b12f19dfe9fc 304 #define FSI_StrucSig 484
kpatel70 4:b12f19dfe9fc 305 #define FSI_Free_Count 488
kpatel70 4:b12f19dfe9fc 306 #define FSI_Nxt_Free 492
mbed_unsupported 0:97df4125f18d 307
kpatel70 4:b12f19dfe9fc 308 #define MBR_Table 446
mbed_unsupported 0:97df4125f18d 309
kpatel70 4:b12f19dfe9fc 310 #define DIR_Name 0
kpatel70 4:b12f19dfe9fc 311 #define DIR_Attr 11
kpatel70 4:b12f19dfe9fc 312 #define DIR_NTres 12
kpatel70 4:b12f19dfe9fc 313 #define DIR_CrtTime 14
kpatel70 4:b12f19dfe9fc 314 #define DIR_CrtDate 16
kpatel70 4:b12f19dfe9fc 315 #define DIR_FstClusHI 20
kpatel70 4:b12f19dfe9fc 316 #define DIR_WrtTime 22
kpatel70 4:b12f19dfe9fc 317 #define DIR_WrtDate 24
kpatel70 4:b12f19dfe9fc 318 #define DIR_FstClusLO 26
kpatel70 4:b12f19dfe9fc 319 #define DIR_FileSize 28
mbed_unsupported 0:97df4125f18d 320
mbed_unsupported 0:97df4125f18d 321
mbed_unsupported 0:97df4125f18d 322
mbed_unsupported 0:97df4125f18d 323 /* Multi-byte word access macros */
mbed_unsupported 0:97df4125f18d 324
kpatel70 4:b12f19dfe9fc 325 #if _MCU_ENDIAN == 1 /* Use word access */
kpatel70 4:b12f19dfe9fc 326 #define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
kpatel70 4:b12f19dfe9fc 327 #define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
kpatel70 4:b12f19dfe9fc 328 #define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
kpatel70 4:b12f19dfe9fc 329 #define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
kpatel70 4:b12f19dfe9fc 330 #elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */
kpatel70 4:b12f19dfe9fc 331 #define LD_WORD(ptr) (WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
kpatel70 4:b12f19dfe9fc 332 #define LD_DWORD(ptr) (DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
kpatel70 4:b12f19dfe9fc 333 #define ST_WORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
kpatel70 4:b12f19dfe9fc 334 #define ST_DWORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(volatile BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(volatile BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
mbed_unsupported 0:97df4125f18d 335 #else
mbed_unsupported 0:97df4125f18d 336 #error Do not forget to set _MCU_ENDIAN properly!
mbed_unsupported 0:97df4125f18d 337 #endif
mbed_unsupported 0:97df4125f18d 338
mbed_unsupported 0:97df4125f18d 339 #ifdef __cplusplus
mbed_unsupported 0:97df4125f18d 340 };
mbed_unsupported 0:97df4125f18d 341 #endif
mbed_unsupported 0:97df4125f18d 342
mbed_unsupported 0:97df4125f18d 343 #define _FATFS
mbed_unsupported 0:97df4125f18d 344 #endif /* _FATFS */