]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Source/FreeRTOS-Plus-FAT-SL/api/fat_sl.h
Add missing +TCP code.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-FAT-SL / api / fat_sl.h
1 /*\r
2  * FreeRTOS+FAT SL V1.0.1 (C) 2014 HCC Embedded\r
3  *\r
4  * The FreeRTOS+FAT SL license terms are different to the FreeRTOS license \r
5  * terms.\r
6  * \r
7  * FreeRTOS+FAT SL uses a dual license model that allows the software to be used \r
8  * under a standard GPL open source license, or a commercial license.  The \r
9  * standard GPL license (unlike the modified GPL license under which FreeRTOS \r
10  * itself is distributed) requires that all software statically linked with \r
11  * FreeRTOS+FAT SL is also distributed under the same GPL V2 license terms.  \r
12  * Details of both license options follow:\r
13  * \r
14  * - Open source licensing -\r
15  * FreeRTOS+FAT SL is a free download and may be used, modified, evaluated and\r
16  * distributed without charge provided the user adheres to version two of the \r
17  * GNU General Public License (GPL) and does not remove the copyright notice or \r
18  * this text.  The GPL V2 text is available on the gnu.org web site, and on the\r
19  * following URL: http://www.FreeRTOS.org/gpl-2.0.txt.\r
20  * \r
21  * - Commercial licensing -\r
22  * Businesses and individuals who for commercial or other reasons cannot comply\r
23  * with the terms of the GPL V2 license must obtain a commercial license before \r
24  * incorporating FreeRTOS+FAT SL into proprietary software for distribution in \r
25  * any form.  Commercial licenses can be purchased from \r
26  * http://shop.freertos.org/fat_sl and do not require any source files to be \r
27  * changed.\r
28  *\r
29  * FreeRTOS+FAT SL is distributed in the hope that it will be useful.  You\r
30  * cannot use FreeRTOS+FAT SL unless you agree that you use the software 'as\r
31  * is'.  FreeRTOS+FAT SL is provided WITHOUT ANY WARRANTY; without even the\r
32  * implied warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A\r
33  * PARTICULAR PURPOSE. Real Time Engineers Ltd. and HCC Embedded disclaims all\r
34  * conditions and terms, be they implied, expressed, or statutory.\r
35  *\r
36  * http://www.FreeRTOS.org\r
37  * http://www.FreeRTOS.org/FreeRTOS-Plus\r
38  *\r
39  */\r
40 \r
41 #ifndef _API_FAT_SL_H_\r
42 #define _API_FAT_SL_H_\r
43 \r
44 #include "config_fat_sl.h"\r
45 \r
46 #include "../version/ver_fat_sl.h"\r
47 #if VER_FAT_SL_MAJOR != 5 || VER_FAT_SL_MINOR != 2\r
48  #error Incompatible FAT_SL version number!\r
49 #endif\r
50 \r
51 #ifdef __cplusplus\r
52 extern "C" {\r
53 #endif\r
54 \r
55 #define F_MAXNAME 8                  /* 8 byte name */\r
56 #define F_MAXEXT  3                  /* 3 byte extension */\r
57 \r
58 typedef struct\r
59 {\r
60   char  path[F_MAXPATH];        /*  /directory1/dir2/  */\r
61   char  filename[F_MAXNAME];    /* filename */\r
62   char  fileext[F_MAXEXT];      /* extension */\r
63 } F_NAME;\r
64 \r
65 typedef struct\r
66 {\r
67   unsigned long  cluster;\r
68   unsigned long  sector;\r
69   unsigned long  sectorend;\r
70   unsigned long  pos;\r
71 } F_POS;\r
72 \r
73 typedef struct\r
74 {\r
75   char            filename[F_MAXPATH]; /*file name+ext*/\r
76   char            name[F_MAXNAME];     /*file name*/\r
77   char            ext[F_MAXEXT];       /*file extension*/\r
78   unsigned char   attr;                /*attribute of the file*/\r
79 \r
80   unsigned short  ctime;        /*creation time*/\r
81   unsigned short  cdate;        /*creation date*/\r
82   unsigned long   cluster;\r
83 \r
84   long            filesize;         /*length of file*/\r
85 \r
86   F_NAME          findfsname;   /*find properties*/\r
87   F_POS           pos;\r
88 } F_FIND;\r
89 \r
90 #define F_ATTR_ARC         0x20\r
91 #define F_ATTR_DIR         0x10\r
92 #define F_ATTR_VOLUME      0x08\r
93 #define F_ATTR_SYSTEM      0x04\r
94 #define F_ATTR_HIDDEN      0x02\r
95 #define F_ATTR_READONLY    0x01\r
96 \r
97 #define F_CLUSTER_FREE     ( (unsigned long)0x00000000 )\r
98 #define F_CLUSTER_RESERVED ( (unsigned long)0x0ffffff0 )\r
99 #define F_CLUSTER_BAD      ( (unsigned long)0x0ffffff7 )\r
100 #define F_CLUSTER_LAST     ( (unsigned long)0x0ffffff8 )\r
101 #define F_CLUSTER_LASTF32R ( (unsigned long)0x0fffffff )\r
102 \r
103 #define F_ST_MISSING       0x00000001\r
104 #define F_ST_CHANGED       0x00000002\r
105 #define F_ST_WRPROTECT     0x00000004\r
106 \r
107 typedef struct\r
108 {\r
109   unsigned long  abspos;\r
110   unsigned long  filesize;\r
111   unsigned long  startcluster;\r
112   unsigned long  relpos;\r
113   unsigned char  modified;\r
114   unsigned char  mode;\r
115   unsigned char  _tdata[F_SECTOR_SIZE];\r
116   F_POS          pos;\r
117   F_POS          dirpos;\r
118 #if F_FILE_CHANGED_EVENT\r
119   char           filename[F_MAXPATH];   /* filename with full path */\r
120 #endif\r
121 } F_FILE;\r
122 \r
123 enum\r
124 {\r
125   F_UNKNOWN_MEDIA\r
126   , F_FAT12_MEDIA\r
127   , F_FAT16_MEDIA\r
128   , F_FAT32_MEDIA\r
129 };\r
130 \r
131 enum\r
132 {\r
133 /*  0 */\r
134   F_NO_ERROR,\r
135 \r
136 /*  1 */ F_ERR_RESERVED_1,\r
137 \r
138 /*  2 */ F_ERR_NOTFORMATTED,\r
139 \r
140 /*  3 */ F_ERR_INVALIDDIR,\r
141 \r
142 /*  4 */ F_ERR_INVALIDNAME,\r
143 \r
144 /*  5 */ F_ERR_NOTFOUND,\r
145 \r
146 /*  6 */ F_ERR_DUPLICATED,\r
147 \r
148 /*  7 */ F_ERR_NOMOREENTRY,\r
149 \r
150 /*  8 */ F_ERR_NOTOPEN,\r
151 \r
152 /*  9 */ F_ERR_EOF,\r
153 \r
154 /* 10 */ F_ERR_RESERVED_2,\r
155 \r
156 /* 11 */ F_ERR_NOTUSEABLE,\r
157 \r
158 /* 12 */ F_ERR_LOCKED,\r
159 \r
160 /* 13 */ F_ERR_ACCESSDENIED,\r
161 \r
162 /* 14 */ F_ERR_NOTEMPTY,\r
163 \r
164 /* 15 */ F_ERR_INITFUNC,\r
165 \r
166 /* 16 */ F_ERR_CARDREMOVED,\r
167 \r
168 /* 17 */ F_ERR_ONDRIVE,\r
169 \r
170 /* 18 */ F_ERR_INVALIDSECTOR,\r
171 \r
172 /* 19 */ F_ERR_READ,\r
173 \r
174 /* 20 */ F_ERR_WRITE,\r
175 \r
176 /* 21 */ F_ERR_INVALIDMEDIA,\r
177 \r
178 /* 22 */ F_ERR_BUSY,\r
179 \r
180 /* 23 */ F_ERR_WRITEPROTECT,\r
181 \r
182 /* 24 */ F_ERR_INVFATTYPE,\r
183 \r
184 /* 25 */ F_ERR_MEDIATOOSMALL,\r
185 \r
186 /* 26 */ F_ERR_MEDIATOOLARGE,\r
187 \r
188 /* 27 */ F_ERR_NOTSUPPSECTORSIZE\r
189 \r
190 /* 28 */, F_ERR_ALLOCATION\r
191 \r
192 #if F_FS_THREAD_AWARE == 1\r
193 /* 29 */, F_ERR_OS = 29\r
194 #endif /* F_FS_THREAD_AWARE */\r
195 };\r
196 \r
197 typedef struct\r
198 {\r
199   unsigned long  total;\r
200   unsigned long  free;\r
201   unsigned long  used;\r
202   unsigned long  bad;\r
203 \r
204   unsigned long  total_high;\r
205   unsigned long  free_high;\r
206   unsigned long  used_high;\r
207   unsigned long  bad_high;\r
208 } F_SPACE;\r
209 \r
210 enum\r
211 {\r
212   F_SEEK_SET   /*Beginning of file*/\r
213   , F_SEEK_CUR /*Current position of file pointer*/\r
214   , F_SEEK_END /*End of file*/\r
215 };\r
216 \r
217 \r
218 /****************************************************************************\r
219  *\r
220  * for file changed events\r
221  *\r
222  ***************************************************************************/\r
223 \r
224 #if F_FILE_CHANGED_EVENT\r
225 \r
226 typedef struct\r
227 {\r
228   unsigned char   action;\r
229   unsigned char   flags;\r
230   unsigned char   attr;\r
231   unsigned short  ctime;\r
232   unsigned short  cdate;\r
233   unsigned long   filesize;\r
234   char            filename[F_MAXPATH];\r
235 } ST_FILE_CHANGED;\r
236 \r
237 typedef void ( *F_FILE_CHANGED_EVENTFUNC )( ST_FILE_CHANGED * fc );\r
238 \r
239 extern F_FILE_CHANGED_EVENTFUNC  f_filechangedevent;\r
240 \r
241  #define f_setfilechangedevent( filechangeevent ) f_filechangedevent = filechangeevent\r
242 \r
243 /* flags */\r
244 \r
245  #define FFLAGS_NONE              0x00000000\r
246 \r
247  #define FFLAGS_FILE_NAME         0x00000001\r
248  #define FFLAGS_DIR_NAME          0x00000002\r
249  #define FFLAGS_NAME              0x00000003\r
250  #define FFLAGS_ATTRIBUTES        0x00000004\r
251  #define FFLAGS_SIZE              0x00000008\r
252  #define FFLAGS_LAST_WRITE        0x00000010\r
253 \r
254 /* actions */\r
255 \r
256  #define FACTION_ADDED            0x00000001\r
257  #define FACTION_REMOVED          0x00000002\r
258  #define FACTION_MODIFIED         0x00000003\r
259  #define FACTION_RENAMED_OLD_NAME 0x00000004\r
260  #define FACTION_RENAMED_NEW_NAME 0x00000005\r
261 \r
262 #endif /* if F_FILE_CHANGED_EVENT */\r
263 \r
264 unsigned char fs_init ( void );\r
265 unsigned char fs_delete ( void );\r
266 \r
267 #define f_initvolume fn_initvolume\r
268 #define f_delvolume  fn_delvolume\r
269 \r
270 unsigned char fn_initvolume ( F_DRIVERINIT initfunc );\r
271 unsigned char fn_delvolume ( void );\r
272 \r
273 unsigned char fn_getfreespace ( F_SPACE * pspace );\r
274 \r
275 unsigned char fn_chdir ( const char * dirname );\r
276 unsigned char fn_mkdir ( const char * dirname );\r
277 unsigned char fn_rmdir ( const char * dirname );\r
278 \r
279 unsigned char fn_findfirst ( const char * filename, F_FIND * find );\r
280 unsigned char fn_findnext ( F_FIND * find );\r
281 \r
282 long fn_filelength ( const char * filename );\r
283 \r
284 unsigned char fn_close ( F_FILE * filehandle );\r
285 F_FILE * fn_open ( const char * filename, const char * mode );\r
286 \r
287 long fn_read ( void * buf, long size, long _size_t, F_FILE * filehandle );\r
288 \r
289 long fn_write ( const void * buf, long size, long _size_t, F_FILE * filehandle );\r
290 \r
291 unsigned char fn_seek ( F_FILE * filehandle, long offset, unsigned char whence );\r
292 \r
293 long fn_tell ( F_FILE * filehandle );\r
294 int fn_getc ( F_FILE * filehandle );\r
295 int fn_putc ( int ch, F_FILE * filehandle );\r
296 unsigned char fn_rewind ( F_FILE * filehandle );\r
297 unsigned char fn_eof ( F_FILE * filehandle );\r
298 \r
299 unsigned char fn_delete ( const char * filename );\r
300 \r
301 unsigned char fn_seteof ( F_FILE * );\r
302 \r
303 F_FILE * fn_truncate ( const char *, long );\r
304 \r
305 unsigned char fn_getcwd ( char * buffer, unsigned char maxlen, char root );\r
306 \r
307 unsigned char fn_hardformat ( unsigned char fattype );\r
308 \r
309 unsigned char fn_getserial ( unsigned long * );\r
310 \r
311 \r
312 #if F_FS_THREAD_AWARE == 1\r
313 \r
314 #include "FreeRTOS.h"\r
315 #include "semphr.h"\r
316 \r
317 unsigned char fr_hardformat ( unsigned char fattype );\r
318 #define f_hardformat( fattype ) fr_hardformat( fattype )\r
319 #define f_format( fattype )    fr_hardformat( fattype )\r
320 \r
321 unsigned char fr_getcwd ( char * buffer, unsigned char maxlen, char root );\r
322 #define f_getcwd( buffer, maxlen ) fr_getcwd( buffer, maxlen, 1 )\r
323 \r
324 unsigned char fr_getfreespace ( F_SPACE * pspace );\r
325 #define f_getfreespace fr_getfreespace\r
326 \r
327 \r
328 unsigned char fr_chdir ( const char * dirname );\r
329 #define f_chdir( dirname ) fr_chdir( dirname )\r
330 unsigned char fr_mkdir ( const char * dirname );\r
331 #define f_mkdir( dirname ) fr_mkdir( dirname )\r
332 unsigned char fr_rmdir ( const char * dirname );\r
333 #define f_rmdir( dirname ) fr_rmdir( dirname )\r
334 \r
335 unsigned char fr_findfirst ( const char * filename, F_FIND * find );\r
336 unsigned char fr_findnext ( F_FIND * find );\r
337 #define f_findfirst( filename, find ) fr_findfirst( filename, find )\r
338 #define f_findnext( find )            fr_findnext( find )\r
339 \r
340 long fr_filelength ( const char * filename );\r
341 #define f_filelength( filename ) fr_filelength( filename )\r
342 \r
343 unsigned char fr_close ( F_FILE * filehandle );\r
344 F_FILE * fr_open ( const char * filename, const char * mode );\r
345 \r
346 long fr_read ( void * buf, long size, long _size_t, F_FILE * filehandle );\r
347 \r
348 unsigned char fr_getserial ( unsigned long * );\r
349 #define f_getserial( serial )  fr_getserial( serial )\r
350 \r
351 unsigned char fr_flush ( F_FILE * f );\r
352 #define f_flush( filehandle ) fr_flush( filehandle )\r
353 \r
354 long fr_write ( const void * buf, long size, long _size_t, F_FILE * filehandle );\r
355 #define f_write( buf, size, _size_t, filehandle ) fr_write( buf, size, _size_t, filehandle )\r
356 \r
357 unsigned char fr_seek ( F_FILE * filehandle, long offset, unsigned char whence );\r
358 #define f_seek( filehandle, offset, whence ) fr_seek( filehandle, offset, whence )\r
359 \r
360 long fr_tell ( F_FILE * filehandle );\r
361 #define f_tell( filehandle )     fr_tell( filehandle )\r
362 int fr_getc ( F_FILE * filehandle );\r
363 #define f_getc( filehandle )     fr_getc( filehandle )\r
364 int fr_putc ( int ch, F_FILE * filehandle );\r
365 #define f_putc( ch, filehandle ) fr_putc( ch, filehandle )\r
366 unsigned char fr_rewind ( F_FILE * filehandle );\r
367 #define f_rewind( filehandle )   fr_rewind( filehandle )\r
368 unsigned char fr_eof ( F_FILE * filehandle );\r
369 #define f_eof( filehandle )      fr_eof( filehandle )\r
370 \r
371 unsigned char fr_delete ( const char * filename );\r
372 #define f_delete( filename ) fr_delete( filename )\r
373 \r
374 unsigned char fr_seteof ( F_FILE * );\r
375 #define f_seteof( file ) fr_seteof( file )\r
376 \r
377 F_FILE * fr_truncate ( const char *, long );\r
378 #define f_truncate( filename, filesize ) fr_truncate( filename, filesize )\r
379 \r
380 #define f_close( filehandle )                    fr_close( filehandle )\r
381 #define f_open( filename, mode )                 fr_open( filename, mode )\r
382 #define f_read( buf, size, _size_t, filehandle ) fr_read( buf, size, _size_t, filehandle )\r
383 \r
384 #else /* F_FS_THREAD_AWARE */\r
385 \r
386 #define f_hardformat( fattype ) fn_hardformat( fattype )\r
387 #define f_format( fattype )    fn_hardformat( fattype )\r
388 \r
389 #define f_getcwd( buffer, maxlen ) fn_getcwd( buffer, maxlen, 1 )\r
390 \r
391 unsigned char fn_getfreespace ( F_SPACE * pspace );\r
392 #define f_getfreespace fn_getfreespace\r
393 \r
394 \r
395 unsigned char fn_chdir ( const char * dirname );\r
396 #define f_chdir( dirname ) fn_chdir( dirname )\r
397 unsigned char fn_mkdir ( const char * dirname );\r
398 #define f_mkdir( dirname ) fn_mkdir( dirname )\r
399 unsigned char fn_rmdir ( const char * dirname );\r
400 #define f_rmdir( dirname ) fn_rmdir( dirname )\r
401 \r
402 unsigned char fn_findfirst ( const char * filename, F_FIND * find );\r
403 unsigned char fn_findnext ( F_FIND * find );\r
404 #define f_findfirst( filename, find ) fn_findfirst( filename, find )\r
405 #define f_findnext( find )            fn_findnext( find )\r
406 \r
407 #define f_filelength( filename ) fn_filelength( filename )\r
408 \r
409 #define f_getserial( serial )  fn_getserial( serial )\r
410 \r
411 unsigned char fn_flush ( F_FILE * f );\r
412 #define f_flush( filehandle ) fn_flush( filehandle )\r
413 \r
414 #define f_write( buf, size, _size_t, filehandle ) fn_write( buf, size, _size_t, filehandle )\r
415 \r
416 #define f_seek( filehandle, offset, whence ) fn_seek( filehandle, offset, whence )\r
417 \r
418 long fn_tell ( F_FILE * filehandle );\r
419 #define f_tell( filehandle )     fn_tell( filehandle )\r
420 int fn_getc ( F_FILE * filehandle );\r
421 #define f_getc( filehandle )     fn_getc( filehandle )\r
422 int fn_putc ( int ch, F_FILE * filehandle );\r
423 #define f_putc( ch, filehandle ) fn_putc( ch, filehandle )\r
424 unsigned char fn_rewind ( F_FILE * filehandle );\r
425 #define f_rewind( filehandle )   fn_rewind( filehandle )\r
426 unsigned char fn_eof ( F_FILE * filehandle );\r
427 #define f_eof( filehandle )      fn_eof( filehandle )\r
428 \r
429 unsigned char fn_delete ( const char * filename );\r
430 #define f_delete( filename ) fn_delete( filename )\r
431 \r
432 unsigned char fn_seteof ( F_FILE * );\r
433 #define f_seteof( file ) fn_seteof( file )\r
434 \r
435 F_FILE * fn_truncate ( const char *, long );\r
436 #define f_truncate( filename, filesize ) fn_truncate( filename, filesize )\r
437 \r
438 #define f_close( filehandle )                    fn_close( filehandle )\r
439 #define f_open( filename, mode )                 fn_open( filename, mode )\r
440 #define f_read( buf, size, _size_t, filehandle ) fn_read( buf, size, _size_t, filehandle )\r
441 \r
442 #endif /* F_FS_THREAD_AWARE */\r
443 \r
444 \r
445 /****************************************************************************\r
446  *\r
447  * end of fat_sl.h\r
448  *\r
449  ***************************************************************************/\r
450 #ifdef __cplusplus\r
451 }\r
452 #endif\r
453 \r
454 #endif /*_API_FAT_SL_H_*/\r
455 \r