LCD1289Serial_Ethenet

Dependencies:   EthernetInterface FatFileSystemCpp SDFileSystem mbed-rtos mbed

Committer:
shindo
Date:
Wed Nov 07 06:42:34 2012 +0000
Revision:
0:a5367e4d8591
LCD1289Serial_Ethenet

Who changed what in which revision?

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