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