Xbee CountUp

Dependencies:   mbed

Fork of HeptaXbee_CountUp by 智也 大野

Committer:
tomoya123
Date:
Fri Dec 09 04:58:00 2016 +0000
Revision:
0:0a7fa0911e6c
Xbee CountUP

Who changed what in which revision?

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