SD card data log

Dependents:   riset_Datalogger

Committer:
kotachi
Date:
Sun Nov 03 07:28:09 2019 +0000
Revision:
0:18d80d7403d3
SD card logging system

Who changed what in which revision?

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