ff.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. /*---------------------------------------------------------------------------/
  2. / FatFs - FAT file system module include file R0.08a (C)ChaN, 2010
  3. /----------------------------------------------------------------------------/
  4. / FatFs module is a generic FAT file system module for small embedded systems.
  5. / This is a free software that opened for education, research and commercial
  6. / developments under license policy of following trems.
  7. /
  8. / Copyright (C) 2010, ChaN, all right reserved.
  9. /
  10. / * The FatFs module is a free software and there is NO WARRANTY.
  11. / * No restriction on use. You can use, modify and redistribute it for
  12. / personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY.
  13. / * Redistributions of source code must retain the above copyright notice.
  14. /
  15. /----------------------------------------------------------------------------*/
  16. #ifndef _FATFS
  17. #define _FATFS 8255 /* Revision ID */
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include "integer.h" /* Basic integer types */
  22. #include "ffconf.h" /* FatFs configuration options */
  23. #if _FATFS != _FFCONF
  24. #error Wrong configuration file (ffconf.h).
  25. #endif
  26. /* DBCS code ranges and SBCS extend char conversion table */
  27. #if _CODE_PAGE == 932 /* Japanese Shift-JIS */
  28. #define _DF1S 0x81 /* DBC 1st byte range 1 start */
  29. #define _DF1E 0x9F /* DBC 1st byte range 1 end */
  30. #define _DF2S 0xE0 /* DBC 1st byte range 2 start */
  31. #define _DF2E 0xFC /* DBC 1st byte range 2 end */
  32. #define _DS1S 0x40 /* DBC 2nd byte range 1 start */
  33. #define _DS1E 0x7E /* DBC 2nd byte range 1 end */
  34. #define _DS2S 0x80 /* DBC 2nd byte range 2 start */
  35. #define _DS2E 0xFC /* DBC 2nd byte range 2 end */
  36. #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
  37. #define _DF1S 0x81
  38. #define _DF1E 0xFE
  39. #define _DS1S 0x40
  40. #define _DS1E 0x7E
  41. #define _DS2S 0x80
  42. #define _DS2E 0xFE
  43. #elif _CODE_PAGE == 949 /* Korean */
  44. #define _DF1S 0x81
  45. #define _DF1E 0xFE
  46. #define _DS1S 0x41
  47. #define _DS1E 0x5A
  48. #define _DS2S 0x61
  49. #define _DS2E 0x7A
  50. #define _DS3S 0x81
  51. #define _DS3E 0xFE
  52. #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
  53. #define _DF1S 0x81
  54. #define _DF1E 0xFE
  55. #define _DS1S 0x40
  56. #define _DS1E 0x7E
  57. #define _DS2S 0xA1
  58. #define _DS2E 0xFE
  59. #elif _CODE_PAGE == 437 /* U.S. (OEM) */
  60. #define _DF1S 0
  61. #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, \
  62. 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB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,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  71. #elif _CODE_PAGE == 737 /* Greek (OEM) */
  72. #define _DF1S 0
  73. #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, \
  74. 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, \
  75. 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, \
  76. 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}
  77. #elif _CODE_PAGE == 775 /* Baltic (OEM) */
  78. #define _DF1S 0
  79. #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, \
  80. 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0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0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
  89. #elif _CODE_PAGE == 852 /* Latin 2 (OEM) */
  90. #define _DF1S 0
  91. #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, \
  92. 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, \
  93. 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, \
  94. 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}
  95. #elif _CODE_PAGE == 855 /* Cyrillic (OEM) */
  96. #define _DF1S 0
  97. #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, \
  98. 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0x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,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}
  107. #elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */
  108. #define _DF1S 0
  109. #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, \
  110. 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, \
  111. 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, \
  112. 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}
  113. #elif _CODE_PAGE == 862 /* Hebrew (OEM) */
  114. #define _DF1S 0
  115. #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,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DD,0xDE,0xDF, \
  124. 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}
  125. #elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */
  126. #define _DF1S 0
  127. #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, \
  128. 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, \
  129. 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, \
  130. 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}
  131. #elif _CODE_PAGE == 1250 /* Central Europe (Windows) */
  132. #define _DF1S 0
  133. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x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,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  142. 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}
  143. #elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */
  144. #define _DF1S 0
  145. #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, \
  146. 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, \
  147. 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, \
  148. 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}
  149. #elif _CODE_PAGE == 1253 /* Greek (Windows) */
  150. #define _DF1S 0
  151. #define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0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CD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
  160. 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}
  161. #elif _CODE_PAGE == 1255 /* Hebrew (Windows) */
  162. #define _DF1S 0
  163. #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, \
  164. 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, \
  165. 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, \
  166. 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}
  167. #elif _CODE_PAGE == 1256 /* Arabic (Windows) */
  168. #define _DF1S 0
  169. #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, \
  170. 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, \
  171. 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, \
  172. 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}
  173. #elif _CODE_PAGE == 1257 /* Baltic (Windows) */
  174. #define _DF1S 0
  175. #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, \
  176. 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, \
  177. 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, \
  178. 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}
  179. #elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */
  180. #define _DF1S 0
  181. #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, \
  182. 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, \
  183. 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, \
  184. 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}
  185. #elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */
  186. #define _DF1S 0
  187. #else
  188. #error Unknown code page
  189. #endif
  190. /* Definitions of volume management */
  191. #if _MULTI_PARTITION /* Multiple partition configuration */
  192. #define LD2PD(vol) (VolToPart[vol].pd) /* Get physical drive# */
  193. #define LD2PT(vol) (VolToPart[vol].pt) /* Get partition# */
  194. typedef struct {
  195. BYTE pd; /* Physical drive# */
  196. BYTE pt; /* Partition # (0-3) */
  197. } PARTITION;
  198. extern const PARTITION VolToPart[]; /* Volume - Physical location resolution table */
  199. #else /* Single partition configuration */
  200. #define LD2PD(vol) (vol) /* Logical drive# is bound to the same physical drive# */
  201. #define LD2PT(vol) 0 /* Always mounts the 1st partition */
  202. #endif
  203. /* Type of path name strings on FatFs API */
  204. #if _LFN_UNICODE /* Unicode string */
  205. #if !_USE_LFN
  206. #error _LFN_UNICODE must be 0 in non-LFN cfg.
  207. #endif
  208. #ifndef _INC_TCHAR
  209. typedef WCHAR TCHAR;
  210. #define _T(x) L ## x
  211. #define _TEXT(x) L ## x
  212. #endif
  213. #else /* ANSI/OEM string */
  214. #ifndef _INC_TCHAR
  215. typedef char TCHAR;
  216. #define _T(x) x
  217. #define _TEXT(x) x
  218. #endif
  219. #endif
  220. /* File system object structure (FATFS) */
  221. typedef struct {
  222. BYTE fs_type; /* FAT sub-type (0:Not mounted) */
  223. BYTE drv; /* Physical drive number */
  224. BYTE csize; /* Sectors per cluster (1,2,4...128) */
  225. BYTE n_fats; /* Number of FAT copies (1,2) */
  226. BYTE wflag; /* win[] dirty flag (1:must be written back) */
  227. BYTE fsi_flag; /* fsinfo dirty flag (1:must be written back) */
  228. WORD id; /* File system mount ID */
  229. WORD n_rootdir; /* Number of root directory entries (FAT12/16) */
  230. #if _MAX_SS != 512
  231. WORD ssize; /* Bytes per sector (512,1024,2048,4096) */
  232. #endif
  233. #if _FS_REENTRANT
  234. _SYNC_t sobj; /* Identifier of sync object */
  235. #endif
  236. #if !_FS_READONLY
  237. DWORD last_clust; /* Last allocated cluster */
  238. DWORD free_clust; /* Number of free clusters */
  239. DWORD fsi_sector; /* fsinfo sector (FAT32) */
  240. #endif
  241. #if _FS_RPATH
  242. DWORD cdir; /* Current directory start cluster (0:root) */
  243. #endif
  244. DWORD n_fatent; /* Number of FAT entries (= number of clusters + 2) */
  245. DWORD fsize; /* Sectors per FAT */
  246. DWORD fatbase; /* FAT start sector */
  247. DWORD dirbase; /* Root directory start sector (FAT32:Cluster#) */
  248. DWORD database; /* Data start sector */
  249. DWORD winsect; /* Current sector appearing in the win[] */
  250. BYTE win[_MAX_SS]; /* Disk access window for Directory, FAT (and Data on tiny cfg) */
  251. } FATFS;
  252. /* File object structure (FIL) */
  253. typedef struct {
  254. FATFS* fs; /* Pointer to the owner file system object */
  255. WORD id; /* Owner file system mount ID */
  256. BYTE flag; /* File status flags */
  257. BYTE pad1;
  258. DWORD fptr; /* File read/write pointer (0 on file open) */
  259. DWORD fsize; /* File size */
  260. DWORD org_clust; /* File start cluster (0 when fsize==0) */
  261. DWORD curr_clust; /* Current cluster */
  262. DWORD dsect; /* Current data sector */
  263. #if !_FS_READONLY
  264. DWORD dir_sect; /* Sector containing the directory entry */
  265. BYTE* dir_ptr; /* Ponter to the directory entry in the window */
  266. #endif
  267. #if _USE_FASTSEEK
  268. DWORD* cltbl; /* Pointer to the cluster link map table (null on file open) */
  269. #endif
  270. #if _FS_SHARE
  271. UINT lockid; /* File lock ID (index of file semaphore table) */
  272. #endif
  273. #if !_FS_TINY
  274. BYTE buf[_MAX_SS]; /* File data read/write buffer */
  275. #endif
  276. } FIL;
  277. /* Directory object structure (DIR) */
  278. typedef struct {
  279. FATFS* fs; /* Pointer to the owner file system object */
  280. WORD id; /* Owner file system mount ID */
  281. WORD index; /* Current read/write index number */
  282. DWORD sclust; /* Table start cluster (0:Root dir) */
  283. DWORD clust; /* Current cluster */
  284. DWORD sect; /* Current sector */
  285. BYTE* dir; /* Pointer to the current SFN entry in the win[] */
  286. BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
  287. #if _USE_LFN
  288. WCHAR* lfn; /* Pointer to the LFN working buffer */
  289. WORD lfn_idx; /* Last matched LFN index number (0xFFFF:No LFN) */
  290. #endif
  291. } DIR;
  292. /* File status structure (FILINFO) */
  293. typedef struct {
  294. DWORD fsize; /* File size */
  295. WORD fdate; /* Last modified date */
  296. WORD ftime; /* Last modified time */
  297. BYTE fattrib; /* Attribute */
  298. TCHAR fname[13]; /* Short file name (8.3 format) */
  299. DWORD clust; /* start cluster */
  300. #if _USE_LFN
  301. TCHAR* lfname; /* Pointer to the LFN buffer */
  302. UINT lfsize; /* Size of LFN buffer in TCHAR */
  303. #endif
  304. } FILINFO;
  305. /* File function return code (FRESULT) */
  306. typedef enum {
  307. FR_OK = 0, /* (0) Succeeded */
  308. FR_DISK_ERR, /* (1) A hard error occured in the low level disk I/O layer */
  309. FR_INT_ERR, /* (2) Assertion failed */
  310. FR_NOT_READY, /* (3) The physical drive cannot work */
  311. FR_NO_FILE, /* (4) Could not find the file */
  312. FR_NO_PATH, /* (5) Could not find the path */
  313. FR_INVALID_NAME, /* (6) The path name format is invalid */
  314. FR_DENIED, /* (7) Acces denied due to prohibited access or directory full */
  315. FR_EXIST, /* (8) Acces denied due to prohibited access */
  316. FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
  317. FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
  318. FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
  319. FR_NOT_ENABLED, /* (12) The volume has no work area */
  320. FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume on the physical drive */
  321. FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
  322. FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
  323. FR_LOCKED, /* (16) The operation is rejected according to the file shareing policy */
  324. FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
  325. FR_TOO_MANY_OPEN_FILES /* (18) Number of open files > _FS_SHARE */
  326. } FRESULT;
  327. /*--------------------------------------------------------------*/
  328. /* FatFs module application interface */
  329. /* Low Level functions */
  330. FRESULT l_openfilebycluster(FATFS *fs, FIL *fp, const TCHAR *path, DWORD clust, DWORD fsize); /* Open a file by its start cluster using supplied file size */
  331. /* application level functions */
  332. FRESULT f_mount (BYTE, FATFS*); /* Mount/Unmount a logical drive */
  333. FRESULT f_open (FIL*, const TCHAR*, BYTE); /* Open or create a file */
  334. FRESULT f_read (FIL*, void*, UINT, UINT*); /* Read data from a file */
  335. FRESULT f_lseek (FIL*, DWORD); /* Move file pointer of a file object */
  336. FRESULT f_close (FIL*); /* Close an open file object */
  337. FRESULT f_opendir (DIR*, const TCHAR*); /* Open an existing directory */
  338. FRESULT f_readdir (DIR*, FILINFO*); /* Read a directory item */
  339. FRESULT f_stat (const TCHAR*, FILINFO*); /* Get file status */
  340. #if !_FS_READONLY
  341. FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
  342. FRESULT f_getfree (const TCHAR*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
  343. FRESULT f_truncate (FIL*); /* Truncate file */
  344. FRESULT f_sync (FIL*); /* Flush cached data of a writing file */
  345. FRESULT f_unlink (const TCHAR*); /* Delete an existing file or directory */
  346. FRESULT f_mkdir (const TCHAR*); /* Create a new directory */
  347. FRESULT f_chmod (const TCHAR*, BYTE, BYTE); /* Change attriburte of the file/dir */
  348. FRESULT f_utime (const TCHAR*, const FILINFO*); /* Change timestamp of the file/dir */
  349. FRESULT f_rename (const TCHAR*, const TCHAR*); /* Rename/Move a file or directory */
  350. #endif
  351. #if _USE_FORWARD
  352. FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
  353. #endif
  354. #if _USE_MKFS
  355. FRESULT f_mkfs (BYTE, BYTE, UINT); /* Create a file system on the drive */
  356. #endif
  357. #if _FS_RPATH
  358. FRESULT f_chdrive (BYTE); /* Change current drive */
  359. FRESULT f_chdir (const TCHAR*); /* Change current directory */
  360. FRESULT f_getcwd (TCHAR*, UINT); /* Get current directory */
  361. #endif
  362. #if _USE_STRFUNC
  363. int f_putc (TCHAR, FIL*); /* Put a character to the file */
  364. int f_puts (const TCHAR*, FIL*); /* Put a string to the file */
  365. int f_printf (FIL*, const TCHAR*, ...); /* Put a formatted string to the file */
  366. TCHAR* f_gets (TCHAR*, int, FIL*); /* Get a string from the file */
  367. #ifndef EOF
  368. #define EOF (-1)
  369. #endif
  370. #endif
  371. #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
  372. #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
  373. #define f_tell(fp) ((fp)->fptr)
  374. #define f_size(fp) ((fp)->fsize)
  375. /*--------------------------------------------------------------*/
  376. /* Additional user defined functions */
  377. /* RTC function */
  378. #if !_FS_READONLY
  379. DWORD get_fattime (void);
  380. #endif
  381. /* Unicode support functions */
  382. #if _USE_LFN /* Unicode - OEM code conversion */
  383. WCHAR ff_convert (WCHAR, UINT); /* OEM-Unicode bidirectional conversion */
  384. WCHAR ff_wtoupper (WCHAR); /* Unicode upper-case conversion */
  385. #if _USE_LFN == 3 /* Memory functions */
  386. void* ff_memalloc (UINT); /* Allocate memory block */
  387. void ff_memfree (void*); /* Free memory block */
  388. #endif
  389. #endif
  390. /* Sync functions */
  391. #if _FS_REENTRANT
  392. int ff_cre_syncobj (BYTE, _SYNC_t*);/* Create a sync object */
  393. int ff_del_syncobj (_SYNC_t); /* Delete a sync object */
  394. int ff_req_grant (_SYNC_t); /* Lock sync object */
  395. void ff_rel_grant (_SYNC_t); /* Unlock sync object */
  396. #endif
  397. /*--------------------------------------------------------------*/
  398. /* Flags and offset address */
  399. /* File access control and file status flags (FIL.flag) */
  400. #define FA_READ 0x01
  401. #define FA_OPEN_EXISTING 0x00
  402. #define FA__ERROR 0x80
  403. #if !_FS_READONLY
  404. #define FA_WRITE 0x02
  405. #define FA_CREATE_NEW 0x04
  406. #define FA_CREATE_ALWAYS 0x08
  407. #define FA_OPEN_ALWAYS 0x10
  408. #define FA__WRITTEN 0x20
  409. #define FA__DIRTY 0x40
  410. #endif
  411. /* FAT sub type (FATFS.fs_type) */
  412. #define FS_FAT12 1
  413. #define FS_FAT16 2
  414. #define FS_FAT32 3
  415. /* File attribute bits for directory entry */
  416. #define AM_RDO 0x01 /* Read only */
  417. #define AM_HID 0x02 /* Hidden */
  418. #define AM_SYS 0x04 /* System */
  419. #define AM_VOL 0x08 /* Volume label */
  420. #define AM_LFN 0x0F /* LFN entry */
  421. #define AM_DIR 0x10 /* Directory */
  422. #define AM_ARC 0x20 /* Archive */
  423. #define AM_MASK 0x3F /* Mask of defined bits */
  424. /* Fast seek function */
  425. #define CREATE_LINKMAP 0xFFFFFFFF
  426. /*--------------------------------*/
  427. /* Multi-byte word access macros */
  428. #if _WORD_ACCESS == 1 /* Enable word access to the FAT structure */
  429. #define LD_WORD(ptr) (WORD)(*(WORD*)(BYTE*)(ptr))
  430. #define LD_DWORD(ptr) (DWORD)(*(DWORD*)(BYTE*)(ptr))
  431. #define ST_WORD(ptr,val) *(WORD*)(BYTE*)(ptr)=(WORD)(val)
  432. #define ST_DWORD(ptr,val) *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
  433. #else /* Use byte-by-byte access to the FAT structure */
  434. #define LD_WORD(ptr) (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
  435. #define LD_DWORD(ptr) (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))
  436. #define ST_WORD(ptr,val) *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
  437. #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)
  438. #endif
  439. #ifdef __cplusplus
  440. }
  441. #endif
  442. #endif /* _FATFS */