DMCP interface  03.15_020
ff_ifc.h
1 #ifndef __FF_IFC_H__
2 #define __FF_IFC_H__
3 
4 
5 
6 /* These types MUST be 16-bit or 32-bit */
7 typedef int INT;
8 typedef unsigned int UINT;
9 
10 /* This type MUST be 8-bit */
11 typedef unsigned char BYTE;
12 
13 /* These types MUST be 16-bit */
14 typedef short SHORT;
15 typedef unsigned short WORD;
16 typedef unsigned short WCHAR;
17 
18 /* These types MUST be 32-bit */
19 typedef long LONG;
20 typedef unsigned long DWORD;
21 
22 /* This type MUST be 64-bit (Remove this for ANSI C (C89) compatibility) */
23 typedef unsigned long long QWORD;
24 
25 typedef char TCHAR;
26 #define _T(x) x
27 #define _TEXT(x) x
28 
29 typedef DWORD FSIZE_t;
30 
31 typedef struct __FATFS FATFS;
32 
33 
36 typedef struct {
37  FATFS* fs;
38  WORD id;
39  BYTE attr;
40  BYTE stat;
41  DWORD sclust;
42  FSIZE_t objsize;
43  UINT lockid;
44 } _FDID;
45 
66 typedef struct {
67  _FDID obj;
68  BYTE flag;
69  BYTE err;
70  FSIZE_t fptr;
71  DWORD clust;
72  DWORD sect;
73  DWORD dir_sect;
74  BYTE* dir_ptr;
75  DWORD* cltbl;
76  BYTE buf[512];
77 } FIL;
78 
79 
80 // --------------------------------------
82 // -------------------------------------
89 /* File access mode and open method flags (3rd argument of f_open) */
90 #define FA_READ 0x01
91 #define FA_WRITE 0x02
92 #define FA_OPEN_EXISTING 0x00
93 #define FA_CREATE_NEW 0x04
94 #define FA_CREATE_ALWAYS 0x08
95 #define FA_OPEN_ALWAYS 0x10
96 #define FA_OPEN_APPEND 0x30
106 typedef enum {
107  FR_OK = 0,
127 } FRESULT;
128 
129 
130 
131 FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode);
132 FRESULT f_close (FIL* fp);
133 FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br);
134 FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw);
135 FRESULT f_lseek (FIL* fp, FSIZE_t ofs);
136 FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new);
137 FRESULT f_unlink (const TCHAR* path);
139 #define f_size(fp) ((fp)->obj.objsize)
140 #define f_tell(fp) ((fp)->fptr)
141 #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
143 #ifndef EOF
144 #define EOF (-1)
145 #endif
146 
150 #endif
(1) A hard error occurred in the low level disk I/O layer
Definition: ff_ifc.h:108
BYTE * dir_ptr
FIL.dir_ptr.
Definition: ff_ifc.h:74
(18) Number of open files > _FS_LOCK
Definition: ff_ifc.h:125
(4) Could not find the file
Definition: ff_ifc.h:111
FRESULT f_read(FIL *fp, void *buff, UINT btr, UINT *br)
Read data from the file.
DWORD sect
FIL.sect.
Definition: ff_ifc.h:72
(7) Access denied due to prohibited access or directory full
Definition: ff_ifc.h:114
(17) LFN working buffer could not be allocated
Definition: ff_ifc.h:124
DWORD dir_sect
FIL.dir_sect.
Definition: ff_ifc.h:73
FatFs file structure used in file operations.
Definition: ff_ifc.h:66
(8) Access denied due to prohibited access
Definition: ff_ifc.h:115
BYTE err
FIL.err.
Definition: ff_ifc.h:69
FRESULT f_rename(const TCHAR *path_old, const TCHAR *path_new)
Rename/Move a file or directory.
FRESULT
File function return code (FRESULT)
Definition: ff_ifc.h:106
(0) Succeeded
Definition: ff_ifc.h:107
FRESULT f_write(FIL *fp, const void *buff, UINT btw, UINT *bw)
Write data to the file.
DWORD clust
FIL.clust.
Definition: ff_ifc.h:71
FRESULT f_open(FIL *fp, const TCHAR *path, BYTE mode)
Open or create a file.
DWORD * cltbl
FIL.cltbl.
Definition: ff_ifc.h:75
(5) Could not find the path
Definition: ff_ifc.h:112
(6) The path name format is invalid
Definition: ff_ifc.h:113
(11) The logical drive number is invalid
Definition: ff_ifc.h:118
FRESULT f_unlink(const TCHAR *path)
Delete an existing file or directory.
BYTE flag
FIL.flag.
Definition: ff_ifc.h:68
(15) Could not get a grant to access the volume within defined period
Definition: ff_ifc.h:122
(16) The operation is rejected according to the file sharing policy
Definition: ff_ifc.h:123
(10) The physical drive is write protected
Definition: ff_ifc.h:117
(3) The physical drive cannot work
Definition: ff_ifc.h:110
(13) There is no valid FAT volume
Definition: ff_ifc.h:120
(14) The f_mkfs() aborted due to any problem
Definition: ff_ifc.h:121
FRESULT f_lseek(FIL *fp, FSIZE_t ofs)
Move file pointer of the file object.
FSIZE_t fptr
FIL.fptr.
Definition: ff_ifc.h:70
_FDID obj
FIL.obj.
Definition: ff_ifc.h:67
(12) The volume has no work area
Definition: ff_ifc.h:119
(19) Given parameter is invalid
Definition: ff_ifc.h:126
(9) The file/directory object is invalid
Definition: ff_ifc.h:116
(2) Assertion failed
Definition: ff_ifc.h:109
FRESULT f_close(FIL *fp)
Close an open file object.