]> git.sur5r.net Git - freertos/blob - Demo/Common/FileSystem/FatFs-0.7e/src/ff.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / Common / FileSystem / FatFs-0.7e / src / ff.h
1 /*---------------------------------------------------------------------------/\r
2 /  FatFs - FAT file system module include file  R0.07e       (C)ChaN, 2009\r
3 /----------------------------------------------------------------------------/\r
4 / FatFs module is a generic FAT file system module for small embedded systems.\r
5 / This is a free software that opened for education, research and commercial\r
6 / developments under license policy of following trems.\r
7 /\r
8 /  Copyright (C) 2009, ChaN, all right reserved.\r
9 /\r
10 / * The FatFs module is a free software and there is NO WARRANTY.\r
11 / * No restriction on use. You can use, modify and redistribute it for\r
12 /   personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.\r
13 / * Redistributions of source code must retain the above copyright notice.\r
14 /----------------------------------------------------------------------------*/\r
15 \r
16 #ifndef _FATFS\r
17 #define _FATFS  0x007E\r
18 \r
19 #include "fat_integer.h"        /* Basic integer types */\r
20 #include "ffconf.h"             /* FatFs configuration options */\r
21 \r
22 #if _FATFS != _FFCONFIG\r
23 #error Wrong configuration file (ffconf.h).\r
24 #endif\r
25 \r
26 \r
27 /* DBCS code ranges and SBCS extend char conversion table */\r
28 \r
29 #if _CODE_PAGE == 932   /* Japanese Shift-JIS */\r
30 #define _DF1S   0x81    /* DBC 1st byte range 1 start */\r
31 #define _DF1E   0x9F    /* DBC 1st byte range 1 end */\r
32 #define _DF2S   0xE0    /* DBC 1st byte range 2 start */\r
33 #define _DF2E   0xFC    /* DBC 1st byte range 2 end */\r
34 #define _DS1S   0x40    /* DBC 2nd byte range 1 start */\r
35 #define _DS1E   0x7E    /* DBC 2nd byte range 1 end */\r
36 #define _DS2S   0x80    /* DBC 2nd byte range 2 start */\r
37 #define _DS2E   0xFC    /* DBC 2nd byte range 2 end */\r
38 \r
39 #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */\r
40 #define _DF1S   0x81\r
41 #define _DF1E   0xFE\r
42 #define _DS1S   0x40\r
43 #define _DS1E   0x7E\r
44 #define _DS2S   0x80\r
45 #define _DS2E   0xFE\r
46 \r
47 #elif _CODE_PAGE == 949 /* Korean */\r
48 #define _DF1S   0x81\r
49 #define _DF1E   0xFE\r
50 #define _DS1S   0x41\r
51 #define _DS1E   0x5A\r
52 #define _DS2S   0x61\r
53 #define _DS2E   0x7A\r
54 #define _DS3S   0x81\r
55 #define _DS3E   0xFE\r
56 \r
57 #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */\r
58 #define _DF1S   0x81\r
59 #define _DF1E   0xFE\r
60 #define _DS1S   0x40\r
61 #define _DS1E   0x7E\r
62 #define _DS2S   0xA1\r
63 #define _DS2E   0xFE\r
64 \r
65 #elif _CODE_PAGE == 437 /* U.S. (OEM) */\r
66 #define _DF1S   0\r
67 #define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
68                                 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
69                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
70                                 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
71 \r
72 #elif _CODE_PAGE == 720 /* Arabic (OEM) */\r
73 #define _DF1S   0\r
74 #define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
75                                 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
76                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
77                                 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
78 \r
79 #elif _CODE_PAGE == 737 /* Greek (OEM) */\r
80 #define _DF1S   0\r
81 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \\r
82                                 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
83                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
84                                 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
85 \r
86 #elif _CODE_PAGE == 775 /* Baltic (OEM) */\r
87 #define _DF1S   0\r
88 #define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \\r
89                                 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
90                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
91                                 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
92 \r
93 #elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */\r
94 #define _DF1S   0\r
95 #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \\r
96                                 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
97                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
98                                 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
99 \r
100 #elif _CODE_PAGE == 852 /* Latin 2 (OEM) */\r
101 #define _DF1S   0\r
102 #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \\r
103                                 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \\r
104                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
105                                 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF}\r
106 \r
107 #elif _CODE_PAGE == 855 /* Cyrillic (OEM) */\r
108 #define _DF1S   0\r
109 #define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \\r
110                                 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \\r
111                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \\r
112                                 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF}\r
113 \r
114 #elif _CODE_PAGE == 857 /* Turkish (OEM) */\r
115 #define _DF1S   0\r
116 #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \\r
117                                 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
118                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
119                                 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
120 \r
121 #elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */\r
122 #define _DF1S   0\r
123 #define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \\r
124                                 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
125                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
126                                 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
127 \r
128 #elif _CODE_PAGE == 862 /* Hebrew (OEM) */\r
129 #define _DF1S   0\r
130 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
131                                 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
132                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
133                                 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
134 \r
135 #elif _CODE_PAGE == 866 /* Russian (OEM) */\r
136 #define _DF1S   0\r
137 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
138                                 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
139                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
140                                 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
141 \r
142 #elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */\r
143 #define _DF1S   0\r
144 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
145                                 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
146                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
147                                 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
148 \r
149 #elif _CODE_PAGE == 1250 /* Central Europe (Windows) */\r
150 #define _DF1S   0\r
151 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \\r
152                                 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \\r
153                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
154                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}\r
155 \r
156 #elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */\r
157 #define _DF1S   0\r
158 #define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \\r
159                                 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \\r
160                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
161                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF}\r
162 \r
163 #elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */\r
164 #define _DF1S   0\r
165 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \\r
166                                 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
167                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
168                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}\r
169 \r
170 #elif _CODE_PAGE == 1253 /* Greek (Windows) */\r
171 #define _DF1S   0\r
172 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
173                                 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
174                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \\r
175                                 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF}\r
176 \r
177 #elif _CODE_PAGE == 1254 /* Turkish (Windows) */\r
178 #define _DF1S   0\r
179 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \\r
180                                 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
181                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
182                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F}\r
183 \r
184 #elif _CODE_PAGE == 1255 /* Hebrew (Windows) */\r
185 #define _DF1S   0\r
186 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
187                                 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
188                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
189                                 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}\r
190 \r
191 #elif _CODE_PAGE == 1256 /* Arabic (Windows) */\r
192 #define _DF1S   0\r
193 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \\r
194                                 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
195                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
196                                 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF}\r
197 \r
198 #elif _CODE_PAGE == 1257 /* Baltic (Windows) */\r
199 #define _DF1S   0\r
200 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \\r
201                                 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \\r
202                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
203                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF}\r
204 \r
205 #elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */\r
206 #define _DF1S   0\r
207 #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \\r
208                                 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \\r
209                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \\r
210                                 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F}\r
211 \r
212 #elif _CODE_PAGE == 1   /* ASCII (for only non-LFN cfg) */\r
213 #define _DF1S   0\r
214 \r
215 #else\r
216 #error Unknown code page\r
217 \r
218 #endif\r
219 \r
220 \r
221 \r
222 /* Character code support macros */\r
223 \r
224 #define IsUpper(c)      (((c)>='A')&&((c)<='Z'))\r
225 #define IsLower(c)      (((c)>='a')&&((c)<='z'))\r
226 \r
227 #if _DF1S               /* DBCS configuration */\r
228 \r
229 #ifdef _DF2S    /* Two 1st byte areas */\r
230 #define IsDBCS1(c)      (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E))\r
231 #else                   /* One 1st byte area */\r
232 #define IsDBCS1(c)      ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E)\r
233 #endif\r
234 \r
235 #ifdef _DS3S    /* Three 2nd byte areas */\r
236 #define IsDBCS2(c)      (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E))\r
237 #else                   /* Two 2nd byte areas */\r
238 #define IsDBCS2(c)      (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E))\r
239 #endif\r
240 \r
241 #else                   /* SBCS configuration */\r
242 \r
243 #define IsDBCS1(c)      0\r
244 #define IsDBCS2(c)      0\r
245 \r
246 #endif /* _DF1S */\r
247 \r
248 \r
249 \r
250 /* Definitions corresponds to multi partition */\r
251 \r
252 #if _MULTI_PARTITION            /* Multiple partition configuration */\r
253 \r
254 typedef struct _PARTITION {\r
255         BYTE pd;        /* Physical drive# */\r
256         BYTE pt;        /* Partition # (0-3) */\r
257 } PARTITION;\r
258 \r
259 extern\r
260 const PARTITION Drives[];                       /* Logical drive# to physical location conversion table */\r
261 #define LD2PD(drv) (Drives[drv].pd)     /* Get physical drive# */\r
262 #define LD2PT(drv) (Drives[drv].pt)     /* Get partition# */\r
263 \r
264 #else                                           /* Single partition configuration */\r
265 \r
266 #define LD2PD(drv) (drv)        /* Physical drive# is equal to the logical drive# */\r
267 #define LD2PT(drv) 0            /* Always mounts the 1st partition */\r
268 \r
269 #endif\r
270 \r
271 \r
272 \r
273 /* Definitions corresponds to multiple sector size */\r
274 \r
275 #if _MAX_SS == 512              /* Single sector size */\r
276 #define SS(fs)  512U\r
277 \r
278 #elif _MAX_SS == 1024 || _MAX_SS == 2048 || _MAX_SS == 4096     /* Multiple sector size */\r
279 #define SS(fs)  ((fs)->s_size)\r
280 \r
281 #else\r
282 #error Sector size must be 512, 1024, 2048 or 4096.\r
283 \r
284 #endif\r
285 \r
286 \r
287 \r
288 /* Type of file name on FatFs API */\r
289 \r
290 #if _LFN_UNICODE && _USE_LFN\r
291 typedef WCHAR XCHAR;    /* Unicode */\r
292 #else\r
293 typedef char XCHAR;             /* SBCS, DBCS */\r
294 #endif\r
295 \r
296 \r
297 \r
298 /* File system object structure */\r
299 \r
300 typedef struct _FATFS_ {\r
301         BYTE    fs_type;        /* FAT sub type */\r
302         BYTE    drive;          /* Physical drive number */\r
303         BYTE    csize;          /* Number of sectors per cluster */\r
304         BYTE    n_fats;         /* Number of FAT copies */\r
305         BYTE    wflag;          /* win[] dirty flag (1:must be written back) */\r
306         BYTE    fsi_flag;       /* fsinfo dirty flag (1:must be written back) */\r
307         WORD    id;                     /* File system mount ID */\r
308         WORD    n_rootdir;      /* Number of root directory entries (0 on FAT32) */\r
309 #if _FS_REENTRANT\r
310         _SYNC_t sobj;           /* Identifier of sync object */\r
311 #endif\r
312 #if _MAX_SS != 512\r
313         WORD    s_size;         /* Sector size */\r
314 #endif\r
315 #if !_FS_READONLY\r
316         DWORD   last_clust;     /* Last allocated cluster */\r
317         DWORD   free_clust;     /* Number of free clusters */\r
318         DWORD   fsi_sector;     /* fsinfo sector */\r
319 #endif\r
320 #if _FS_RPATH\r
321         DWORD   cdir;           /* Current directory (0:root)*/\r
322 #endif\r
323         DWORD   sects_fat;      /* Sectors per fat */\r
324         DWORD   max_clust;      /* Maximum cluster# + 1. Number of clusters is max_clust - 2 */\r
325         DWORD   fatbase;        /* FAT start sector */\r
326         DWORD   dirbase;        /* Root directory start sector (Cluster# on FAT32) */\r
327         DWORD   database;       /* Data start sector */\r
328         DWORD   winsect;        /* Current sector appearing in the win[] */\r
329         BYTE    win[_MAX_SS];/* Disk access window for Directory/FAT */\r
330 } FATFS;\r
331 \r
332 \r
333 \r
334 /* Directory object structure */\r
335 \r
336 typedef struct _DIR_ {\r
337         FATFS*  fs;                     /* Pointer to the owner file system object */\r
338         WORD    id;                     /* Owner file system mount ID */\r
339         WORD    index;          /* Current read/write index number */\r
340         DWORD   sclust;         /* Table start cluster (0:Static table) */\r
341         DWORD   clust;          /* Current cluster */\r
342         DWORD   sect;           /* Current sector */\r
343         BYTE*   dir;            /* Pointer to the current SFN entry in the win[] */\r
344         BYTE*   fn;                     /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */\r
345 #if _USE_LFN\r
346         WCHAR*  lfn;            /* Pointer to the LFN working buffer */\r
347         WORD    lfn_idx;        /* Last matched LFN index number (0xFFFF:No LFN) */\r
348 #endif\r
349 } DIR;\r
350 \r
351 \r
352 \r
353 /* File object structure */\r
354 \r
355 typedef struct _FIL_ {\r
356         FATFS*  fs;                     /* Pointer to the owner file system object */\r
357         WORD    id;                     /* Owner file system mount ID */\r
358         BYTE    flag;           /* File status flags */\r
359         BYTE    csect;          /* Sector address in the cluster */\r
360         DWORD   fptr;           /* File R/W pointer */\r
361         DWORD   fsize;          /* File size */\r
362         DWORD   org_clust;      /* File start cluster */\r
363         DWORD   curr_clust;     /* Current cluster */\r
364         DWORD   dsect;          /* Current data sector */\r
365 #if !_FS_READONLY\r
366         DWORD   dir_sect;       /* Sector containing the directory entry */\r
367         BYTE*   dir_ptr;        /* Ponter to the directory entry in the window */\r
368 #endif\r
369 #if !_FS_TINY\r
370         BYTE    buf[_MAX_SS];/* File R/W buffer */\r
371 #endif\r
372 } FIL;\r
373 \r
374 \r
375 \r
376 /* File status structure */\r
377 \r
378 typedef struct _FILINFO_ {\r
379         DWORD   fsize;          /* File size */\r
380         WORD    fdate;          /* Last modified date */\r
381         WORD    ftime;          /* Last modified time */\r
382         BYTE    fattrib;        /* Attribute */\r
383         char    fname[13];      /* Short file name (8.3 format) */\r
384 #if _USE_LFN\r
385         XCHAR*  lfname;         /* Pointer to the LFN buffer */\r
386         int     lfsize;         /* Size of LFN buffer [chrs] */\r
387 #endif\r
388 } FILINFO;\r
389 \r
390 \r
391 \r
392 /* File function return code (FRESULT) */\r
393 \r
394 typedef enum {\r
395         FR_OK = 0,                      /* 0 */\r
396         FR_DISK_ERR,            /* 1 */\r
397         FR_INT_ERR,                     /* 2 */\r
398         FR_NOT_READY,           /* 3 */\r
399         FR_NO_FILE,                     /* 4 */\r
400         FR_NO_PATH,                     /* 5 */\r
401         FR_INVALID_NAME,        /* 6 */\r
402         FR_DENIED,                      /* 7 */\r
403         FR_EXIST,                       /* 8 */\r
404         FR_INVALID_OBJECT,      /* 9 */\r
405         FR_WRITE_PROTECTED,     /* 10 */\r
406         FR_INVALID_DRIVE,       /* 11 */\r
407         FR_NOT_ENABLED,         /* 12 */\r
408         FR_NO_FILESYSTEM,       /* 13 */\r
409         FR_MKFS_ABORTED,        /* 14 */\r
410         FR_TIMEOUT                      /* 15 */\r
411 } FRESULT;\r
412 \r
413 \r
414 \r
415 /*--------------------------------------------------------------*/\r
416 /* FatFs module application interface                           */\r
417 \r
418 FRESULT f_mount (BYTE, FATFS*);                                         /* Mount/Unmount a logical drive */\r
419 FRESULT f_open (FIL*, const XCHAR*, BYTE);                      /* Open or create a file */\r
420 FRESULT f_read (FIL*, void*, UINT, UINT*);                      /* Read data from a file */\r
421 FRESULT f_write (FIL*, const void*, UINT, UINT*);       /* Write data to a file */\r
422 FRESULT f_lseek (FIL*, DWORD);                                          /* Move file pointer of a file object */\r
423 FRESULT f_close (FIL*);                                                         /* Close an open file object */\r
424 FRESULT f_opendir (DIR*, const XCHAR*);                         /* Open an existing directory */\r
425 FRESULT f_readdir (DIR*, FILINFO*);                                     /* Read a directory item */\r
426 FRESULT f_stat (const XCHAR*, FILINFO*);                        /* Get file status */\r
427 FRESULT f_getfree (const XCHAR*, DWORD*, FATFS**);      /* Get number of free clusters on the drive */\r
428 FRESULT f_truncate (FIL*);                                                      /* Truncate file */\r
429 FRESULT f_sync (FIL*);                                                          /* Flush cached data of a writing file */\r
430 FRESULT f_unlink (const XCHAR*);                                        /* Delete an existing file or directory */\r
431 FRESULT f_mkdir (const XCHAR*);                                         /* Create a new directory */\r
432 FRESULT f_chmod (const XCHAR*, BYTE, BYTE);                     /* Change attriburte of the file/dir */\r
433 FRESULT f_utime (const XCHAR*, const FILINFO*);         /* Change timestamp of the file/dir */\r
434 FRESULT f_rename (const XCHAR*, const XCHAR*);          /* Rename/Move a file or directory */\r
435 FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*);       /* Forward data to the stream */\r
436 FRESULT f_mkfs (BYTE, BYTE, WORD);                                      /* Create a file system on the drive */\r
437 FRESULT f_chdir (const XCHAR*);                                         /* Change current directory */\r
438 FRESULT f_chdrive (BYTE);                                                       /* Change current drive */\r
439 \r
440 #if _USE_STRFUNC\r
441 int f_putc (int, FIL*);                                                         /* Put a character to the file */\r
442 int f_puts (const char*, FIL*);                                         /* Put a string to the file */\r
443 int f_printf (FIL*, const char*, ...);                          /* Put a formatted string to the file */\r
444 char* f_gets (char*, int, FIL*);                                        /* Get a string from the file */\r
445 #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)\r
446 #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)\r
447 #ifndef EOF\r
448 #define EOF -1\r
449 #endif\r
450 #endif\r
451 \r
452 \r
453 \r
454 /*--------------------------------------------------------------*/\r
455 /* User defined functions                                       */\r
456 \r
457 /* Real time clock */\r
458 #if !_FS_READONLY\r
459 DWORD get_fattime (void);       /* 31-25: Year(0-127 org.1980), 24-21: Month(1-12), 20-16: Day(1-31) */\r
460                                                         /* 15-11: Hour(0-23), 10-5: Minute(0-59), 4-0: Second(0-29 *2) */\r
461 #endif\r
462 \r
463 /* Unicode - OEM code conversion */\r
464 #if _USE_LFN\r
465 WCHAR ff_convert (WCHAR, UINT);\r
466 WCHAR ff_wtoupper (WCHAR);\r
467 #endif\r
468 \r
469 /* Sync functions */\r
470 #if _FS_REENTRANT\r
471 BOOL ff_cre_syncobj(BYTE, _SYNC_t*);\r
472 BOOL ff_del_syncobj(_SYNC_t);\r
473 BOOL ff_req_grant(_SYNC_t);\r
474 void ff_rel_grant(_SYNC_t);\r
475 #endif\r
476 \r
477 \r
478 \r
479 /*--------------------------------------------------------------*/\r
480 /* Flags and offset address                                     */\r
481 \r
482 \r
483 /* File access control and file status flags (FIL.flag) */\r
484 \r
485 #define FA_READ                         0x01\r
486 #define FA_OPEN_EXISTING        0x00\r
487 #if _FS_READONLY == 0\r
488 #define FA_WRITE                        0x02\r
489 #define FA_CREATE_NEW           0x04\r
490 #define FA_CREATE_ALWAYS        0x08\r
491 #define FA_OPEN_ALWAYS          0x10\r
492 #define FA__WRITTEN                     0x20\r
493 #define FA__DIRTY                       0x40\r
494 #endif\r
495 #define FA__ERROR                       0x80\r
496 \r
497 \r
498 /* FAT sub type (FATFS.fs_type) */\r
499 \r
500 #define FS_FAT12        1\r
501 #define FS_FAT16        2\r
502 #define FS_FAT32        3\r
503 \r
504 \r
505 /* File attribute bits for directory entry */\r
506 \r
507 #define AM_RDO  0x01    /* Read only */\r
508 #define AM_HID  0x02    /* Hidden */\r
509 #define AM_SYS  0x04    /* System */\r
510 #define AM_VOL  0x08    /* Volume label */\r
511 #define AM_LFN  0x0F    /* LFN entry */\r
512 #define AM_DIR  0x10    /* Directory */\r
513 #define AM_ARC  0x20    /* Archive */\r
514 #define AM_MASK 0x3F    /* Mask of defined bits */\r
515 \r
516 \r
517 /* FatFs refers the members in the FAT structures with byte offset instead\r
518 / of structure member because there are incompatibility of the packing option\r
519 / between various compilers. */\r
520 \r
521 #define BS_jmpBoot                      0\r
522 #define BS_OEMName                      3\r
523 #define BPB_BytsPerSec          11\r
524 #define BPB_SecPerClus          13\r
525 #define BPB_RsvdSecCnt          14\r
526 #define BPB_NumFATs                     16\r
527 #define BPB_RootEntCnt          17\r
528 #define BPB_TotSec16            19\r
529 #define BPB_Media                       21\r
530 #define BPB_FATSz16                     22\r
531 #define BPB_SecPerTrk           24\r
532 #define BPB_NumHeads            26\r
533 #define BPB_HiddSec                     28\r
534 #define BPB_TotSec32            32\r
535 #define BS_55AA                         510\r
536 \r
537 #define BS_DrvNum                       36\r
538 #define BS_BootSig                      38\r
539 #define BS_VolID                        39\r
540 #define BS_VolLab                       43\r
541 #define BS_FilSysType           54\r
542 \r
543 #define BPB_FATSz32                     36\r
544 #define BPB_ExtFlags            40\r
545 #define BPB_FSVer                       42\r
546 #define BPB_RootClus            44\r
547 #define BPB_FSInfo                      48\r
548 #define BPB_BkBootSec           50\r
549 #define BS_DrvNum32                     64\r
550 #define BS_BootSig32            66\r
551 #define BS_VolID32                      67\r
552 #define BS_VolLab32                     71\r
553 #define BS_FilSysType32         82\r
554 \r
555 #define FSI_LeadSig                     0\r
556 #define FSI_StrucSig            484\r
557 #define FSI_Free_Count          488\r
558 #define FSI_Nxt_Free            492\r
559 \r
560 #define MBR_Table                       446\r
561 \r
562 #define DIR_Name                        0\r
563 #define DIR_Attr                        11\r
564 #define DIR_NTres                       12\r
565 #define DIR_CrtTime                     14\r
566 #define DIR_CrtDate                     16\r
567 #define DIR_FstClusHI           20\r
568 #define DIR_WrtTime                     22\r
569 #define DIR_WrtDate                     24\r
570 #define DIR_FstClusLO           26\r
571 #define DIR_FileSize            28\r
572 #define LDIR_Ord                        0\r
573 #define LDIR_Attr                       11\r
574 #define LDIR_Type                       12\r
575 #define LDIR_Chksum                     13\r
576 #define LDIR_FstClusLO          26\r
577 \r
578 \r
579 \r
580 /*--------------------------------*/\r
581 /* Multi-byte word access macros  */\r
582 \r
583 #if _WORD_ACCESS == 1   /* Enable word access to the FAT structure */\r
584 #define LD_WORD(ptr)            (WORD)(*(WORD*)(BYTE*)(ptr))\r
585 #define LD_DWORD(ptr)           (DWORD)(*(DWORD*)(BYTE*)(ptr))\r
586 #define ST_WORD(ptr,val)        *(WORD*)(BYTE*)(ptr)=(WORD)(val)\r
587 #define ST_DWORD(ptr,val)       *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)\r
588 #else                                   /* Use byte-by-byte access to the FAT structure */\r
589 #define LD_WORD(ptr)            (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))\r
590 #define LD_DWORD(ptr)           (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))\r
591 #define ST_WORD(ptr,val)        *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)\r
592 #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)\r
593 #endif\r
594 \r
595 \r
596 #endif /* _FATFS */\r