/ * Redistributions of source code must retain the above copyright notice.
/
/----------------------------------------------------------------------------*/
-
+\r
#ifndef _FATFS
#define _FATFS 8237 /* Revision ID */
-
+\r
#ifdef __cplusplus
extern "C" {
#endif
-
+\r
#include "integer.h" /* Basic integer types */
#include "ffconf.h" /* FatFs configuration options */
-
+\r
#if _FATFS != _FFCONF
#error Wrong configuration file (ffconf.h).
#endif
-
-
-
+\r
+\r
+\r
#define _DRIVES 4
/* Number of logical drives to be used. This affects the size of internal table. */
/* Definitions of volume management */
-
+\r
#if _MULTI_PARTITION /* Multiple partition configuration */
#define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive# */
#define LD2PT(vol) (VolToPart[vol].pt) /* Get partition# */
BYTE pt; /* Partition # (0-3) */
} PARTITION;
extern const PARTITION VolToPart[]; /* Volume - Physical location resolution table */
-
+\r
#else /* Single partition configuration */
#define LD2PD(vol) (vol) /* Logical drive# is bound to the same physical drive# */
#define LD2PT(vol) 0 /* Always mounts the 1st partition */
-
+\r
#endif
-
-
-
+\r
+\r
+\r
/* Type of path name strings on FatFs API */
-
+\r
#if _LFN_UNICODE /* Unicode string */
#if !_USE_LFN
#error _LFN_UNICODE must be 0 in non-LFN cfg.
#define _T(x) L ## x
#define _TEXT(x) L ## x
#endif
-
+\r
#else /* ANSI/OEM string */
#ifndef _INC_TCHAR
typedef char TCHAR;
#define _T(x) x
#define _TEXT(x) x
#endif
-
+\r
#endif
-
-
-
+\r
+\r
+\r
/* File system object structure (FATFS) */
-
+\r
typedef struct {
BYTE fs_type; /* FAT sub-type (0:Not mounted) */
BYTE drv; /* Physical drive number */
DWORD winsect; /* Current sector appearing in the win[] */
BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
} FATFS;
-
-
-
+\r
+\r
+\r
/* File object structure (FIL) */
-
+\r
typedef struct {
FATFS* fs; /* Pointer to the owner file system object */
WORD id; /* Owner file system mount ID */
BYTE buf[_MAX_SS]; /* File data read/write buffer */
#endif
} FIL_t;
-
-
-
+\r
+\r
+\r
/* Directory object structure (DIR) */
-
+\r
typedef struct {
FATFS* fs; /* Pointer to the owner file system object */
WORD id; /* Owner file system mount ID */
WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
#endif
} DIR_t;
-
-
-
+\r
+\r
+\r
/* File status structure (FILINFO) */
-
+\r
typedef struct {
DWORD fsize; /* File size */
WORD fdate; /* Last modified date */
UINT lfsize; /* Size of LFN buffer in TCHAR */
#endif
} FILINFO;
-
-
-
+\r
+\r
+\r
/* File function return code (FRESULT) */
-
+\r
typedef enum {
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES /* (18) Number of open files > _FS_SHARE */
} FRESULT;
-
-
-
+\r
+\r
+\r
/*--------------------------------------------------------------*/
/* FatFs module application interface */
-
+\r
FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
FRESULT f_open (FIL_t*, const TCHAR*, BYTE); /* Open or create a file */
FRESULT f_read (FIL_t*, void*, UINT, UINT*); /* Read data from a file */
int f_puts (const TCHAR*, FIL_t*); /* Put a string to the file */
int f_printf (FIL_t*, const TCHAR*, ...); /* Put a formatted string to the file */
TCHAR* f_gets (TCHAR*, int, FIL_t*); /* Get a string from the file */
-
+\r
#ifndef EOF
#define EOF (-1)
#endif
-
+\r
#define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
#define f_tell(fp) ((fp)->fptr)
#define f_size(fp) ((fp)->fsize)
-
-
-
-
+\r
+\r
+\r
+\r
/*--------------------------------------------------------------*/
/* Additional user defined functions */
-
+\r
/* RTC function */
#if !_FS_READONLY
DWORD get_fattime (void);
#endif
-
+\r
/* Unicode support functions */
#if _USE_LFN /* Unicode - OEM code conversion */
WCHAR ff_convert (WCHAR, UINT); /* OEM-Unicode bidirectional conversion */
void ff_memfree (void*); /* Free memory block */
#endif
#endif
-
+\r
/* Sync functions */
#if _FS_REENTRANT
int ff_cre_syncobj (BYTE, _SYNC_t*);/* Create a sync object */
void ff_rel_grant (_SYNC_t); /* Unlock sync object */
int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
#endif
-
-
-
-
+\r
+\r
+\r
+\r
/*--------------------------------------------------------------*/
/* Flags and offset address */
-
-
+\r
+\r
/* File access control and file status flags (FIL.flag) */
-
+\r
#define FA_READ 0x01
#define FA_OPEN_EXISTING 0x00
#define FA__ERROR 0x80
-
+\r
#if !_FS_READONLY
#define FA_WRITE 0x02
#define FA_CREATE_NEW 0x04
#define FA__WRITTEN 0x20
#define FA__DIRTY 0x40
#endif
-
-
+\r
+\r
/* FAT sub type (FATFS.fs_type) */
-
+\r
#define FS_FAT12 1
#define FS_FAT16 2
#define FS_FAT32 3
-
-
+\r
+\r
/* File attribute bits for directory entry */
-
+\r
#define AM_RDO 0x01 /* Read only */
#define AM_HID 0x02 /* Hidden */
#define AM_SYS 0x04 /* System */
#define AM_DIR 0x10 /* Directory */
#define AM_ARC 0x20 /* Archive */
#define AM_MASK 0x3F /* Mask of defined bits */
-
-
+\r
+\r
/* Fast seek function */
#define CREATE_LINKMAP 0xFFFFFFFF
-
-
-
+\r
+\r
+\r
/*--------------------------------*/
/* Multi-byte word access macros */
-
+\r
#if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
#define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
#define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
#define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
#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)
#endif
-
+\r
#ifdef __cplusplus
}
#endif
-
+\r
#endif /* _FATFS */