手動機アーム、mbed基盤のspiをおくるだけのプログラムです(9/4)

Dependencies:   SPI_master_arm_shudouki mbed

Fork of SPI_master_arm_shudouki2 by F^3 RC 2班

Committer:
yoka06
Date:
Mon Sep 04 13:02:43 2017 +0000
Revision:
2:faa028d2f2f8
Parent:
0:76d1c7f13415
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yoka06 0:76d1c7f13415 1 /*--------------------------------------------------------------------------/
yoka06 0:76d1c7f13415 2 / FatFs - FAT file system module include file R0.06 (C)ChaN, 2008
yoka06 0:76d1c7f13415 3 /---------------------------------------------------------------------------/
yoka06 0:76d1c7f13415 4 / FatFs module is an experimenal project to implement FAT file system to
yoka06 0:76d1c7f13415 5 / cheap microcontrollers. This is a free software and is opened for education,
yoka06 0:76d1c7f13415 6 / research and development under license policy of following trems.
yoka06 0:76d1c7f13415 7 /
yoka06 0:76d1c7f13415 8 / Copyright (C) 2008, ChaN, all right reserved.
yoka06 0:76d1c7f13415 9 /
yoka06 0:76d1c7f13415 10 / * The FatFs module is a free software and there is no warranty.
yoka06 0:76d1c7f13415 11 / * You can use, modify and/or redistribute it for personal, non-profit or
yoka06 0:76d1c7f13415 12 / commercial use without any restriction under your responsibility.
yoka06 0:76d1c7f13415 13 / * Redistributions of source code must retain the above copyright notice.
yoka06 0:76d1c7f13415 14 /
yoka06 0:76d1c7f13415 15 /---------------------------------------------------------------------------*/
yoka06 0:76d1c7f13415 16
yoka06 0:76d1c7f13415 17 #ifndef _FATFS
yoka06 0:76d1c7f13415 18
yoka06 0:76d1c7f13415 19 #define _MCU_ENDIAN 2
yoka06 0:76d1c7f13415 20 /* The _MCU_ENDIAN defines which access method is used to the FAT structure.
yoka06 0:76d1c7f13415 21 / 1: Enable word access.
yoka06 0:76d1c7f13415 22 / 2: Disable word access and use byte-by-byte access instead.
yoka06 0:76d1c7f13415 23 / When the architectural byte order of the MCU is big-endian and/or address
yoka06 0:76d1c7f13415 24 / miss-aligned access results incorrect behavior, the _MCU_ENDIAN must be set to 2.
yoka06 0:76d1c7f13415 25 / If it is not the case, it can also be set to 1 for good code efficiency. */
yoka06 0:76d1c7f13415 26
yoka06 0:76d1c7f13415 27 #define _FS_READONLY 0
yoka06 0:76d1c7f13415 28 /* Setting _FS_READONLY to 1 defines read only configuration. This removes
yoka06 0:76d1c7f13415 29 / writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
yoka06 0:76d1c7f13415 30 / f_truncate and useless f_getfree. */
yoka06 0:76d1c7f13415 31
yoka06 0:76d1c7f13415 32 #define _FS_MINIMIZE 0
yoka06 0:76d1c7f13415 33 /* The _FS_MINIMIZE option defines minimization level to remove some functions.
yoka06 0:76d1c7f13415 34 / 0: Full function.
yoka06 0:76d1c7f13415 35 / 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate and f_rename are removed.
yoka06 0:76d1c7f13415 36 / 2: f_opendir and f_readdir are removed in addition to level 1.
yoka06 0:76d1c7f13415 37 / 3: f_lseek is removed in addition to level 2. */
yoka06 0:76d1c7f13415 38
yoka06 0:76d1c7f13415 39 #define _USE_STRFUNC 0
yoka06 0:76d1c7f13415 40 /* To enable string functions, set _USE_STRFUNC to 1 or 2. */
yoka06 0:76d1c7f13415 41
yoka06 0:76d1c7f13415 42 #define _USE_MKFS 1
yoka06 0:76d1c7f13415 43 /* When _USE_MKFS is set to 1 and _FS_READONLY is set to 0, f_mkfs function is
yoka06 0:76d1c7f13415 44 / enabled. */
yoka06 0:76d1c7f13415 45
yoka06 0:76d1c7f13415 46 #define _DRIVES 4
yoka06 0:76d1c7f13415 47 /* Number of logical drives to be used. This affects the size of internal table. */
yoka06 0:76d1c7f13415 48
yoka06 0:76d1c7f13415 49 #define _MULTI_PARTITION 0
yoka06 0:76d1c7f13415 50 /* When _MULTI_PARTITION is set to 0, each logical drive is bound to same
yoka06 0:76d1c7f13415 51 / physical drive number and can mount only 1st primaly partition. When it is
yoka06 0:76d1c7f13415 52 / set to 1, each logical drive can mount a partition listed in Drives[]. */
yoka06 0:76d1c7f13415 53
yoka06 0:76d1c7f13415 54 #define _USE_FSINFO 0
yoka06 0:76d1c7f13415 55 /* To enable FSInfo support on FAT32 volume, set _USE_FSINFO to 1. */
yoka06 0:76d1c7f13415 56
yoka06 0:76d1c7f13415 57 #define _USE_SJIS 1
yoka06 0:76d1c7f13415 58 /* When _USE_SJIS is set to 1, Shift-JIS code transparency is enabled, otherwise
yoka06 0:76d1c7f13415 59 / only US-ASCII(7bit) code can be accepted as file/directory name. */
yoka06 0:76d1c7f13415 60
yoka06 0:76d1c7f13415 61 #define _USE_NTFLAG 1
yoka06 0:76d1c7f13415 62 /* When _USE_NTFLAG is set to 1, upper/lower case of the file name is preserved.
yoka06 0:76d1c7f13415 63 / Note that the files are always accessed in case insensitive. */
yoka06 0:76d1c7f13415 64
yoka06 0:76d1c7f13415 65
yoka06 0:76d1c7f13415 66 #include "integer.h"
yoka06 0:76d1c7f13415 67
yoka06 0:76d1c7f13415 68 #ifdef __cplusplus
yoka06 0:76d1c7f13415 69 extern "C" {
yoka06 0:76d1c7f13415 70 #endif
yoka06 0:76d1c7f13415 71
yoka06 0:76d1c7f13415 72 /* Definitions corresponds to multiple sector size (not tested) */
yoka06 0:76d1c7f13415 73 #define S_MAX_SIZ 512U /* Do not change */
yoka06 0:76d1c7f13415 74 #if S_MAX_SIZ > 512U
yoka06 0:76d1c7f13415 75 #define SS(fs) ((fs)->s_size)
yoka06 0:76d1c7f13415 76 #else
yoka06 0:76d1c7f13415 77 #define SS(fs) 512U
yoka06 0:76d1c7f13415 78 #endif
yoka06 0:76d1c7f13415 79
yoka06 0:76d1c7f13415 80
yoka06 0:76d1c7f13415 81 /* File system object structure */
yoka06 0:76d1c7f13415 82 typedef struct _FATFS {
yoka06 0:76d1c7f13415 83 WORD id; /* File system mount ID */
yoka06 0:76d1c7f13415 84 WORD n_rootdir; /* Number of root directory entries */
yoka06 0:76d1c7f13415 85 DWORD winsect; /* Current sector appearing in the win[] */
yoka06 0:76d1c7f13415 86 DWORD sects_fat; /* Sectors per fat */
yoka06 0:76d1c7f13415 87 DWORD max_clust; /* Maximum cluster# + 1 */
yoka06 0:76d1c7f13415 88 DWORD fatbase; /* FAT start sector */
yoka06 0:76d1c7f13415 89 DWORD dirbase; /* Root directory start sector (cluster# for FAT32) */
yoka06 0:76d1c7f13415 90 DWORD database; /* Data start sector */
yoka06 0:76d1c7f13415 91 #if !_FS_READONLY
yoka06 0:76d1c7f13415 92 DWORD last_clust; /* Last allocated cluster */
yoka06 0:76d1c7f13415 93 DWORD free_clust; /* Number of free clusters */
yoka06 0:76d1c7f13415 94 #if _USE_FSINFO
yoka06 0:76d1c7f13415 95 DWORD fsi_sector; /* fsinfo sector */
yoka06 0:76d1c7f13415 96 BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
yoka06 0:76d1c7f13415 97 BYTE pad2;
yoka06 0:76d1c7f13415 98 #endif
yoka06 0:76d1c7f13415 99 #endif
yoka06 0:76d1c7f13415 100 BYTE fs_type; /* FAT sub type */
yoka06 0:76d1c7f13415 101 BYTE csize; /* Number of sectors per cluster */
yoka06 0:76d1c7f13415 102 #if S_MAX_SIZ > 512U
yoka06 0:76d1c7f13415 103 WORD s_size; /* Sector size */
yoka06 0:76d1c7f13415 104 #endif
yoka06 0:76d1c7f13415 105 BYTE n_fats; /* Number of FAT copies */
yoka06 0:76d1c7f13415 106 BYTE drive; /* Physical drive number */
yoka06 0:76d1c7f13415 107 BYTE winflag; /* win[] dirty flag (1:must be written back) */
yoka06 0:76d1c7f13415 108 BYTE pad1;
yoka06 0:76d1c7f13415 109 BYTE win[S_MAX_SIZ]; /* Disk access window for Directory/FAT */
yoka06 0:76d1c7f13415 110 } FATFS;
yoka06 0:76d1c7f13415 111
yoka06 0:76d1c7f13415 112
yoka06 0:76d1c7f13415 113 /* Directory object structure */
yoka06 0:76d1c7f13415 114 typedef struct _DIR {
yoka06 0:76d1c7f13415 115 WORD id; /* Owner file system mount ID */
yoka06 0:76d1c7f13415 116 WORD index; /* Current index */
yoka06 0:76d1c7f13415 117 FATFS* fs; /* Pointer to the owner file system object */
yoka06 0:76d1c7f13415 118 DWORD sclust; /* Start cluster */
yoka06 0:76d1c7f13415 119 DWORD clust; /* Current cluster */
yoka06 0:76d1c7f13415 120 DWORD sect; /* Current sector */
yoka06 0:76d1c7f13415 121 } FATFS_DIR;
yoka06 0:76d1c7f13415 122
yoka06 0:76d1c7f13415 123
yoka06 0:76d1c7f13415 124 /* File object structure */
yoka06 0:76d1c7f13415 125 typedef struct _FIL {
yoka06 0:76d1c7f13415 126 WORD id; /* Owner file system mount ID */
yoka06 0:76d1c7f13415 127 BYTE flag; /* File status flags */
yoka06 0:76d1c7f13415 128 BYTE csect; /* Sector address in the cluster */
yoka06 0:76d1c7f13415 129 FATFS* fs; /* Pointer to the owner file system object */
yoka06 0:76d1c7f13415 130 DWORD fptr; /* File R/W pointer */
yoka06 0:76d1c7f13415 131 DWORD fsize; /* File size */
yoka06 0:76d1c7f13415 132 DWORD org_clust; /* File start cluster */
yoka06 0:76d1c7f13415 133 DWORD curr_clust; /* Current cluster */
yoka06 0:76d1c7f13415 134 DWORD curr_sect; /* Current sector */
yoka06 0:76d1c7f13415 135 #if _FS_READONLY == 0
yoka06 0:76d1c7f13415 136 DWORD dir_sect; /* Sector containing the directory entry */
yoka06 0:76d1c7f13415 137 BYTE* dir_ptr; /* Ponter to the directory entry in the window */
yoka06 0:76d1c7f13415 138 #endif
yoka06 0:76d1c7f13415 139 BYTE buffer[S_MAX_SIZ]; /* File R/W buffer */
yoka06 0:76d1c7f13415 140 } FIL;
yoka06 0:76d1c7f13415 141
yoka06 0:76d1c7f13415 142
yoka06 0:76d1c7f13415 143 /* File status structure */
yoka06 0:76d1c7f13415 144 typedef struct _FILINFO {
yoka06 0:76d1c7f13415 145 DWORD fsize; /* Size */
yoka06 0:76d1c7f13415 146 WORD fdate; /* Date */
yoka06 0:76d1c7f13415 147 WORD ftime; /* Time */
yoka06 0:76d1c7f13415 148 BYTE fattrib; /* Attribute */
yoka06 0:76d1c7f13415 149 char fname[8+1+3+1]; /* Name (8.3 format) */
yoka06 0:76d1c7f13415 150 } FILINFO;
yoka06 0:76d1c7f13415 151
yoka06 0:76d1c7f13415 152
yoka06 0:76d1c7f13415 153
yoka06 0:76d1c7f13415 154 /* Definitions corresponds to multi partition */
yoka06 0:76d1c7f13415 155
yoka06 0:76d1c7f13415 156 #if _MULTI_PARTITION != 0 /* Multiple partition cfg */
yoka06 0:76d1c7f13415 157
yoka06 0:76d1c7f13415 158 typedef struct _PARTITION {
yoka06 0:76d1c7f13415 159 BYTE pd; /* Physical drive # (0-255) */
yoka06 0:76d1c7f13415 160 BYTE pt; /* Partition # (0-3) */
yoka06 0:76d1c7f13415 161 } PARTITION;
yoka06 0:76d1c7f13415 162 extern
yoka06 0:76d1c7f13415 163 const PARTITION Drives[]; /* Logical drive# to physical location conversion table */
yoka06 0:76d1c7f13415 164 #define LD2PD(drv) (Drives[drv].pd) /* Get physical drive# */
yoka06 0:76d1c7f13415 165 #define LD2PT(drv) (Drives[drv].pt) /* Get partition# */
yoka06 0:76d1c7f13415 166
yoka06 0:76d1c7f13415 167 #else /* Single partition cfg */
yoka06 0:76d1c7f13415 168
yoka06 0:76d1c7f13415 169 #define LD2PD(drv) (drv) /* Physical drive# is equal to logical drive# */
yoka06 0:76d1c7f13415 170 #define LD2PT(drv) 0 /* Always mounts the 1st partition */
yoka06 0:76d1c7f13415 171
yoka06 0:76d1c7f13415 172 #endif
yoka06 0:76d1c7f13415 173
yoka06 0:76d1c7f13415 174
yoka06 0:76d1c7f13415 175 /* File function return code (FRESULT) */
yoka06 0:76d1c7f13415 176
yoka06 0:76d1c7f13415 177 typedef enum {
yoka06 0:76d1c7f13415 178 FR_OK = 0, /* 0 */
yoka06 0:76d1c7f13415 179 FR_NOT_READY, /* 1 */
yoka06 0:76d1c7f13415 180 FR_NO_FILE, /* 2 */
yoka06 0:76d1c7f13415 181 FR_NO_PATH, /* 3 */
yoka06 0:76d1c7f13415 182 FR_INVALID_NAME, /* 4 */
yoka06 0:76d1c7f13415 183 FR_INVALID_DRIVE, /* 5 */
yoka06 0:76d1c7f13415 184 FR_DENIED, /* 6 */
yoka06 0:76d1c7f13415 185 FR_EXIST, /* 7 */
yoka06 0:76d1c7f13415 186 FR_RW_ERROR, /* 8 */
yoka06 0:76d1c7f13415 187 FR_WRITE_PROTECTED, /* 9 */
yoka06 0:76d1c7f13415 188 FR_NOT_ENABLED, /* 10 */
yoka06 0:76d1c7f13415 189 FR_NO_FILESYSTEM, /* 11 */
yoka06 0:76d1c7f13415 190 FR_INVALID_OBJECT, /* 12 */
yoka06 0:76d1c7f13415 191 FR_MKFS_ABORTED /* 13 */
yoka06 0:76d1c7f13415 192 } FRESULT;
yoka06 0:76d1c7f13415 193
yoka06 0:76d1c7f13415 194
yoka06 0:76d1c7f13415 195
yoka06 0:76d1c7f13415 196 /*-----------------------------------------------------*/
yoka06 0:76d1c7f13415 197 /* FatFs module application interface */
yoka06 0:76d1c7f13415 198
yoka06 0:76d1c7f13415 199 FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
yoka06 0:76d1c7f13415 200 FRESULT f_open (FIL*, const char*, BYTE); /* Open or create a file */
yoka06 0:76d1c7f13415 201 FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
yoka06 0:76d1c7f13415 202 FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
yoka06 0:76d1c7f13415 203 FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
yoka06 0:76d1c7f13415 204 FRESULT f_close (FIL*); /* Close an open file object */
yoka06 0:76d1c7f13415 205 FRESULT f_opendir (FATFS_DIR*, const char*); /* Open an existing directory */
yoka06 0:76d1c7f13415 206 FRESULT f_readdir (FATFS_DIR*, FILINFO*); /* Read a directory item */
yoka06 0:76d1c7f13415 207 FRESULT f_stat (const char*, FILINFO*); /* Get file status */
yoka06 0:76d1c7f13415 208 FRESULT f_getfree (const char*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
yoka06 0:76d1c7f13415 209 FRESULT f_truncate (FIL*); /* Truncate file */
yoka06 0:76d1c7f13415 210 FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
yoka06 0:76d1c7f13415 211 FRESULT f_unlink (const char*); /* Delete an existing file or directory */
yoka06 0:76d1c7f13415 212 FRESULT f_mkdir (const char*); /* Create a new directory */
yoka06 0:76d1c7f13415 213 FRESULT f_chmod (const char*, BYTE, BYTE); /* Change file/dir attriburte */
yoka06 0:76d1c7f13415 214 FRESULT f_utime (const char*, const FILINFO*); /* Change file/dir timestamp */
yoka06 0:76d1c7f13415 215 FRESULT f_rename (const char*, const char*); /* Rename/Move a file or directory */
yoka06 0:76d1c7f13415 216 FRESULT f_mkfs (BYTE, BYTE, WORD); /* Create a file system on the drive */
yoka06 0:76d1c7f13415 217 #if _USE_STRFUNC
yoka06 0:76d1c7f13415 218 #define feof(fp) ((fp)->fptr == (fp)->fsize)
yoka06 0:76d1c7f13415 219 #define EOF -1
yoka06 0:76d1c7f13415 220 int fputc (int, FIL*); /* Put a character to the file */
yoka06 0:76d1c7f13415 221 int fputs (const char*, FIL*); /* Put a string to the file */
yoka06 0:76d1c7f13415 222 int fprintf (FIL*, const char*, ...); /* Put a formatted string to the file */
yoka06 0:76d1c7f13415 223 char* fgets (char*, int, FIL*); /* Get a string from the file */
yoka06 0:76d1c7f13415 224 #endif
yoka06 0:76d1c7f13415 225
yoka06 0:76d1c7f13415 226 /* User defined function to give a current time to fatfs module */
yoka06 0:76d1c7f13415 227
yoka06 0:76d1c7f13415 228 DWORD get_fattime (void); /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */
yoka06 0:76d1c7f13415 229 /* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */
yoka06 0:76d1c7f13415 230
yoka06 0:76d1c7f13415 231
yoka06 0:76d1c7f13415 232
yoka06 0:76d1c7f13415 233 /* File access control and file status flags (FIL.flag) */
yoka06 0:76d1c7f13415 234
yoka06 0:76d1c7f13415 235 #define FA_READ 0x01
yoka06 0:76d1c7f13415 236 #define FA_OPEN_EXISTING 0x00
yoka06 0:76d1c7f13415 237 #if _FS_READONLY == 0
yoka06 0:76d1c7f13415 238 #define FA_WRITE 0x02
yoka06 0:76d1c7f13415 239 #define FA_CREATE_NEW 0x04
yoka06 0:76d1c7f13415 240 #define FA_CREATE_ALWAYS 0x08
yoka06 0:76d1c7f13415 241 #define FA_OPEN_ALWAYS 0x10
yoka06 0:76d1c7f13415 242 #define FA__WRITTEN 0x20
yoka06 0:76d1c7f13415 243 #define FA__DIRTY 0x40
yoka06 0:76d1c7f13415 244 #endif
yoka06 0:76d1c7f13415 245 #define FA__ERROR 0x80
yoka06 0:76d1c7f13415 246
yoka06 0:76d1c7f13415 247
yoka06 0:76d1c7f13415 248 /* FAT sub type (FATFS.fs_type) */
yoka06 0:76d1c7f13415 249
yoka06 0:76d1c7f13415 250 #define FS_FAT12 1
yoka06 0:76d1c7f13415 251 #define FS_FAT16 2
yoka06 0:76d1c7f13415 252 #define FS_FAT32 3
yoka06 0:76d1c7f13415 253
yoka06 0:76d1c7f13415 254
yoka06 0:76d1c7f13415 255 /* File attribute bits for directory entry */
yoka06 0:76d1c7f13415 256
yoka06 0:76d1c7f13415 257 #define AM_RDO 0x01 /* Read only */
yoka06 0:76d1c7f13415 258 #define AM_HID 0x02 /* Hidden */
yoka06 0:76d1c7f13415 259 #define AM_SYS 0x04 /* System */
yoka06 0:76d1c7f13415 260 #define AM_VOL 0x08 /* Volume label */
yoka06 0:76d1c7f13415 261 #define AM_LFN 0x0F /* LFN entry */
yoka06 0:76d1c7f13415 262 #define AM_DIR 0x10 /* Directory */
yoka06 0:76d1c7f13415 263 #define AM_ARC 0x20 /* Archive */
yoka06 0:76d1c7f13415 264
yoka06 0:76d1c7f13415 265
yoka06 0:76d1c7f13415 266
yoka06 0:76d1c7f13415 267 /* Offset of FAT structure members */
yoka06 0:76d1c7f13415 268
yoka06 0:76d1c7f13415 269 #define BS_jmpBoot 0
yoka06 0:76d1c7f13415 270 #define BS_OEMName 3
yoka06 0:76d1c7f13415 271 #define BPB_BytsPerSec 11
yoka06 0:76d1c7f13415 272 #define BPB_SecPerClus 13
yoka06 0:76d1c7f13415 273 #define BPB_RsvdSecCnt 14
yoka06 0:76d1c7f13415 274 #define BPB_NumFATs 16
yoka06 0:76d1c7f13415 275 #define BPB_RootEntCnt 17
yoka06 0:76d1c7f13415 276 #define BPB_TotSec16 19
yoka06 0:76d1c7f13415 277 #define BPB_Media 21
yoka06 0:76d1c7f13415 278 #define BPB_FATSz16 22
yoka06 0:76d1c7f13415 279 #define BPB_SecPerTrk 24
yoka06 0:76d1c7f13415 280 #define BPB_NumHeads 26
yoka06 0:76d1c7f13415 281 #define BPB_HiddSec 28
yoka06 0:76d1c7f13415 282 #define BPB_TotSec32 32
yoka06 0:76d1c7f13415 283 #define BS_55AA 510
yoka06 0:76d1c7f13415 284
yoka06 0:76d1c7f13415 285 #define BS_DrvNum 36
yoka06 0:76d1c7f13415 286 #define BS_BootSig 38
yoka06 0:76d1c7f13415 287 #define BS_VolID 39
yoka06 0:76d1c7f13415 288 #define BS_VolLab 43
yoka06 0:76d1c7f13415 289 #define BS_FilSysType 54
yoka06 0:76d1c7f13415 290
yoka06 0:76d1c7f13415 291 #define BPB_FATSz32 36
yoka06 0:76d1c7f13415 292 #define BPB_ExtFlags 40
yoka06 0:76d1c7f13415 293 #define BPB_FSVer 42
yoka06 0:76d1c7f13415 294 #define BPB_RootClus 44
yoka06 0:76d1c7f13415 295 #define BPB_FSInfo 48
yoka06 0:76d1c7f13415 296 #define BPB_BkBootSec 50
yoka06 0:76d1c7f13415 297 #define BS_DrvNum32 64
yoka06 0:76d1c7f13415 298 #define BS_BootSig32 66
yoka06 0:76d1c7f13415 299 #define BS_VolID32 67
yoka06 0:76d1c7f13415 300 #define BS_VolLab32 71
yoka06 0:76d1c7f13415 301 #define BS_FilSysType32 82
yoka06 0:76d1c7f13415 302
yoka06 0:76d1c7f13415 303 #define FSI_LeadSig 0
yoka06 0:76d1c7f13415 304 #define FSI_StrucSig 484
yoka06 0:76d1c7f13415 305 #define FSI_Free_Count 488
yoka06 0:76d1c7f13415 306 #define FSI_Nxt_Free 492
yoka06 0:76d1c7f13415 307
yoka06 0:76d1c7f13415 308 #define MBR_Table 446
yoka06 0:76d1c7f13415 309
yoka06 0:76d1c7f13415 310 #define DIR_Name 0
yoka06 0:76d1c7f13415 311 #define DIR_Attr 11
yoka06 0:76d1c7f13415 312 #define DIR_NTres 12
yoka06 0:76d1c7f13415 313 #define DIR_CrtTime 14
yoka06 0:76d1c7f13415 314 #define DIR_CrtDate 16
yoka06 0:76d1c7f13415 315 #define DIR_FstClusHI 20
yoka06 0:76d1c7f13415 316 #define DIR_WrtTime 22
yoka06 0:76d1c7f13415 317 #define DIR_WrtDate 24
yoka06 0:76d1c7f13415 318 #define DIR_FstClusLO 26
yoka06 0:76d1c7f13415 319 #define DIR_FileSize 28
yoka06 0:76d1c7f13415 320
yoka06 0:76d1c7f13415 321
yoka06 0:76d1c7f13415 322
yoka06 0:76d1c7f13415 323 /* Multi-byte word access macros */
yoka06 0:76d1c7f13415 324
yoka06 0:76d1c7f13415 325 #if _MCU_ENDIAN == 1 /* Use word access */
yoka06 0:76d1c7f13415 326 #define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
yoka06 0:76d1c7f13415 327 #define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
yoka06 0:76d1c7f13415 328 #define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
yoka06 0:76d1c7f13415 329 #define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
yoka06 0:76d1c7f13415 330 #elif _MCU_ENDIAN == 2 /* Use byte-by-byte access */
yoka06 0:76d1c7f13415 331 #define LD_WORD(ptr) (WORD)(((WORD)*(volatile BYTE*)((ptr)+1)<<8)|(WORD)*(volatile BYTE*)(ptr))
yoka06 0:76d1c7f13415 332 #define LD_DWORD(ptr) (DWORD)(((DWORD)*(volatile BYTE*)((ptr)+3)<<24)|((DWORD)*(volatile BYTE*)((ptr)+2)<<16)|((WORD)*(volatile BYTE*)((ptr)+1)<<8)|*(volatile BYTE*)(ptr))
yoka06 0:76d1c7f13415 333 #define ST_WORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
yoka06 0:76d1c7f13415 334 #define ST_DWORD(ptr,val) *(volatile BYTE*)(ptr)=(BYTE)(val); *(volatile BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8); *(volatile BYTE*)((ptr)+2)=(BYTE)((DWORD)(val)>>16); *(volatile BYTE*)((ptr)+3)=(BYTE)((DWORD)(val)>>24)
yoka06 0:76d1c7f13415 335 #else
yoka06 0:76d1c7f13415 336 #error Do not forget to set _MCU_ENDIAN properly!
yoka06 0:76d1c7f13415 337 #endif
yoka06 0:76d1c7f13415 338
yoka06 0:76d1c7f13415 339 #ifdef __cplusplus
yoka06 0:76d1c7f13415 340 };
yoka06 0:76d1c7f13415 341 #endif
yoka06 0:76d1c7f13415 342
yoka06 0:76d1c7f13415 343 #define _FATFS
yoka06 0:76d1c7f13415 344 #endif /* _FATFS */