A code for the spindling of bots.

Dependencies:   MX12 ServoRingBuffer mbed-src

Fork of SpindleBot by MRD Lab

Committer:
labmrd
Date:
Thu Aug 13 17:55:40 2015 +0000
Revision:
14:7c5beaa9fb01
Parent:
4:e44ac08027bd
This revision marks Mark's mark of resignation from the labmrd mbed account.

Who changed what in which revision?

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