Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Committer:
gert_lauritsen
Date:
Fri Jul 05 12:55:53 2019 +0000
Branch:
MbedBMAGThrRev
Revision:
61:52a6d0ffd8e5
dato rettel og ID i file lagt ind i version 5

Who changed what in which revision?

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