ロケット用プログラム

Dependencies:   mbed

Committer:
ishiyamayuto
Date:
Wed Sep 11 06:37:20 2019 +0000
Revision:
0:d58274531d38
BMP180,MPU6050

Who changed what in which revision?

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