hattori&ide

Dependencies:   mbed

Committer:
hattori_atsushi
Date:
Sun Dec 18 08:16:01 2022 +0000
Revision:
0:f77369cabd75
hattori

Who changed what in which revision?

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