.

Dependents:   CANcan

Committer:
TickTock
Date:
Sun Dec 23 22:57:35 2012 +0000
Revision:
2:243ee5f47c25
.;

Who changed what in which revision?

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