2 * FreeRTOS+FAT SL V1.0.1 (C) 2014 HCC Embedded
\r
4 * The FreeRTOS+FAT SL license terms are different to the FreeRTOS license
\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
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
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
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
36 * http://www.FreeRTOS.org
\r
37 * http://www.FreeRTOS.org/FreeRTOS-Plus
\r
41 #ifndef _API_FAT_SL_H_
\r
42 #define _API_FAT_SL_H_
\r
44 #include "config_fat_sl.h"
\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
55 #define F_MAXNAME 8 /* 8 byte name */
\r
56 #define F_MAXEXT 3 /* 3 byte extension */
\r
60 char path[F_MAXPATH]; /* /directory1/dir2/ */
\r
61 char filename[F_MAXNAME]; /* filename */
\r
62 char fileext[F_MAXEXT]; /* extension */
\r
67 unsigned long cluster;
\r
68 unsigned long sector;
\r
69 unsigned long sectorend;
\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
80 unsigned short ctime; /*creation time*/
\r
81 unsigned short cdate; /*creation date*/
\r
82 unsigned long cluster;
\r
84 long filesize; /*length of file*/
\r
86 F_NAME findfsname; /*find properties*/
\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
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
103 #define F_ST_MISSING 0x00000001
\r
104 #define F_ST_CHANGED 0x00000002
\r
105 #define F_ST_WRPROTECT 0x00000004
\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
118 #if F_FILE_CHANGED_EVENT
\r
119 char filename[F_MAXPATH]; /* filename with full path */
\r
136 /* 1 */ F_ERR_RESERVED_1,
\r
138 /* 2 */ F_ERR_NOTFORMATTED,
\r
140 /* 3 */ F_ERR_INVALIDDIR,
\r
142 /* 4 */ F_ERR_INVALIDNAME,
\r
144 /* 5 */ F_ERR_NOTFOUND,
\r
146 /* 6 */ F_ERR_DUPLICATED,
\r
148 /* 7 */ F_ERR_NOMOREENTRY,
\r
150 /* 8 */ F_ERR_NOTOPEN,
\r
154 /* 10 */ F_ERR_RESERVED_2,
\r
156 /* 11 */ F_ERR_NOTUSEABLE,
\r
158 /* 12 */ F_ERR_LOCKED,
\r
160 /* 13 */ F_ERR_ACCESSDENIED,
\r
162 /* 14 */ F_ERR_NOTEMPTY,
\r
164 /* 15 */ F_ERR_INITFUNC,
\r
166 /* 16 */ F_ERR_CARDREMOVED,
\r
168 /* 17 */ F_ERR_ONDRIVE,
\r
170 /* 18 */ F_ERR_INVALIDSECTOR,
\r
172 /* 19 */ F_ERR_READ,
\r
174 /* 20 */ F_ERR_WRITE,
\r
176 /* 21 */ F_ERR_INVALIDMEDIA,
\r
178 /* 22 */ F_ERR_BUSY,
\r
180 /* 23 */ F_ERR_WRITEPROTECT,
\r
182 /* 24 */ F_ERR_INVFATTYPE,
\r
184 /* 25 */ F_ERR_MEDIATOOSMALL,
\r
186 /* 26 */ F_ERR_MEDIATOOLARGE,
\r
188 /* 27 */ F_ERR_NOTSUPPSECTORSIZE
\r
190 /* 28 */, F_ERR_ALLOCATION
\r
192 #if F_FS_THREAD_AWARE == 1
\r
193 /* 29 */, F_ERR_OS = 29
\r
194 #endif /* F_FS_THREAD_AWARE */
\r
199 unsigned long total;
\r
200 unsigned long free;
\r
201 unsigned long used;
\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
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
218 /****************************************************************************
\r
220 * for file changed events
\r
222 ***************************************************************************/
\r
224 #if F_FILE_CHANGED_EVENT
\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
237 typedef void ( *F_FILE_CHANGED_EVENTFUNC )( ST_FILE_CHANGED * fc );
\r
239 extern F_FILE_CHANGED_EVENTFUNC f_filechangedevent;
\r
241 #define f_setfilechangedevent( filechangeevent ) f_filechangedevent = filechangeevent
\r
245 #define FFLAGS_NONE 0x00000000
\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
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
262 #endif /* if F_FILE_CHANGED_EVENT */
\r
264 unsigned char fs_init ( void );
\r
265 unsigned char fs_delete ( void );
\r
267 #define f_initvolume fn_initvolume
\r
268 #define f_delvolume fn_delvolume
\r
270 unsigned char fn_initvolume ( F_DRIVERINIT initfunc );
\r
271 unsigned char fn_delvolume ( void );
\r
273 unsigned char fn_getfreespace ( F_SPACE * pspace );
\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
279 unsigned char fn_findfirst ( const char * filename, F_FIND * find );
\r
280 unsigned char fn_findnext ( F_FIND * find );
\r
282 long fn_filelength ( const char * filename );
\r
284 unsigned char fn_close ( F_FILE * filehandle );
\r
285 F_FILE * fn_open ( const char * filename, const char * mode );
\r
287 long fn_read ( void * buf, long size, long _size_t, F_FILE * filehandle );
\r
289 long fn_write ( const void * buf, long size, long _size_t, F_FILE * filehandle );
\r
291 unsigned char fn_seek ( F_FILE * filehandle, long offset, unsigned char whence );
\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
299 unsigned char fn_delete ( const char * filename );
\r
301 unsigned char fn_seteof ( F_FILE * );
\r
303 F_FILE * fn_truncate ( const char *, long );
\r
305 unsigned char fn_getcwd ( char * buffer, unsigned char maxlen, char root );
\r
307 unsigned char fn_hardformat ( unsigned char fattype );
\r
309 unsigned char fn_getserial ( unsigned long * );
\r
312 #if F_FS_THREAD_AWARE == 1
\r
314 #include "FreeRTOS.h"
\r
315 #include "semphr.h"
\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
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
324 unsigned char fr_getfreespace ( F_SPACE * pspace );
\r
325 #define f_getfreespace fr_getfreespace
\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
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
340 long fr_filelength ( const char * filename );
\r
341 #define f_filelength( filename ) fr_filelength( filename )
\r
343 unsigned char fr_close ( F_FILE * filehandle );
\r
344 F_FILE * fr_open ( const char * filename, const char * mode );
\r
346 long fr_read ( void * buf, long size, long _size_t, F_FILE * filehandle );
\r
348 unsigned char fr_getserial ( unsigned long * );
\r
349 #define f_getserial( serial ) fr_getserial( serial )
\r
351 unsigned char fr_flush ( F_FILE * f );
\r
352 #define f_flush( filehandle ) fr_flush( filehandle )
\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
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
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
371 unsigned char fr_delete ( const char * filename );
\r
372 #define f_delete( filename ) fr_delete( filename )
\r
374 unsigned char fr_seteof ( F_FILE * );
\r
375 #define f_seteof( file ) fr_seteof( file )
\r
377 F_FILE * fr_truncate ( const char *, long );
\r
378 #define f_truncate( filename, filesize ) fr_truncate( filename, filesize )
\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
384 #else /* F_FS_THREAD_AWARE */
\r
386 #define f_hardformat( fattype ) fn_hardformat( fattype )
\r
387 #define f_format( fattype ) fn_hardformat( fattype )
\r
389 #define f_getcwd( buffer, maxlen ) fn_getcwd( buffer, maxlen, 1 )
\r
391 unsigned char fn_getfreespace ( F_SPACE * pspace );
\r
392 #define f_getfreespace fn_getfreespace
\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
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
407 #define f_filelength( filename ) fn_filelength( filename )
\r
409 #define f_getserial( serial ) fn_getserial( serial )
\r
411 unsigned char fn_flush ( F_FILE * f );
\r
412 #define f_flush( filehandle ) fn_flush( filehandle )
\r
414 #define f_write( buf, size, _size_t, filehandle ) fn_write( buf, size, _size_t, filehandle )
\r
416 #define f_seek( filehandle, offset, whence ) fn_seek( filehandle, offset, whence )
\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
429 unsigned char fn_delete ( const char * filename );
\r
430 #define f_delete( filename ) fn_delete( filename )
\r
432 unsigned char fn_seteof ( F_FILE * );
\r
433 #define f_seteof( file ) fn_seteof( file )
\r
435 F_FILE * fn_truncate ( const char *, long );
\r
436 #define f_truncate( filename, filesize ) fn_truncate( filename, filesize )
\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
442 #endif /* F_FS_THREAD_AWARE */
\r
445 /****************************************************************************
\r
449 ***************************************************************************/
\r
454 #endif /*_API_FAT_SL_H_*/
\r