Updated get_fattime to use rtc and provide a date/time. This has been an annoying missing feature.

Dependents:   IoTGateway_Basic y_XBeeTest_5_read CameraC1098_picture LifeCam ... more

Committer:
SomeRandomBloke
Date:
Fri Mar 30 18:41:26 2012 +0000
Revision:
0:93acdd9f65f4
Updated get_fattime to use rtc and provide a date/time.

Who changed what in which revision?

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