IJFW - IchigoJamのBASICプログラムをメモリカード(MMCまたは互換カード)に保存したり読み出したりできるプログラム。メモリカードにファームウェアのファイルを置くだけで、電源ON時に自動的に書き換える機能も搭載(一応こちらがメイン)。LPC1114FN28専用。

Dependencies:   mbed

参考URL http://www.cyberchabudai.org/index.php/entry?tag=IJFW

Committer:
oks486
Date:
Sun Aug 21 07:51:01 2016 +0000
Revision:
2:daf6c4719496
Parent:
0:43cce7b453d0
Modified I2c2mem for "FILES" command

Who changed what in which revision?

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