annotate ff.h @ 407:36a33c56c383

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