Dependents:   USBMSD_CDC_11U35test

Fork of USBFileSystem by Erik -

Committer:
k4zuki
Date:
Tue Apr 21 09:14:07 2015 +0000
Revision:
9:98a97b7d56a8
Parent:
2:9af05743d551
update USBDevice

Who changed what in which revision?

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