Subversion Repositories KoE_projects

Rev

Blame | Last modification | View Log | Download | RSS feed | ?url?

  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.  
  17. #ifndef _FATFS
  18. #define _FATFS  8255    /* Revision ID */
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23.  
  24. #include "integer.h"    /* Basic integer types */
  25. #include "ffconf.h"             /* FatFs configuration options */
  26.  
  27. #if _FATFS != _FFCONF
  28. #error Wrong configuration file (ffconf.h).
  29. #endif
  30.  
  31.  
  32. /* DBCS code ranges and SBCS extend char conversion table */
  33.  
  34. #if _CODE_PAGE == 932   /* Japanese Shift-JIS */
  35. #define _DF1S   0x81    /* DBC 1st byte range 1 start */
  36. #define _DF1E   0x9F    /* DBC 1st byte range 1 end */
  37. #define _DF2S   0xE0    /* DBC 1st byte range 2 start */
  38. #define _DF2E   0xFC    /* DBC 1st byte range 2 end */
  39. #define _DS1S   0x40    /* DBC 2nd byte range 1 start */
  40. #define _DS1E   0x7E    /* DBC 2nd byte range 1 end */
  41. #define _DS2S   0x80    /* DBC 2nd byte range 2 start */
  42. #define _DS2E   0xFC    /* DBC 2nd byte range 2 end */
  43.  
  44. #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
  45. #define _DF1S   0x81
  46. #define _DF1E   0xFE
  47. #define _DS1S   0x40
  48. #define _DS1E   0x7E
  49. #define _DS2S   0x80
  50. #define _DS2E   0xFE
  51.  
  52. #elif _CODE_PAGE == 949 /* Korean */
  53. #define _DF1S   0x81
  54. #define _DF1E   0xFE
  55. #define _DS1S   0x41
  56. #define _DS1E   0x5A
  57. #define _DS2S   0x61
  58. #define _DS2E   0x7A
  59. #define _DS3S   0x81
  60. #define _DS3E   0xFE
  61.  
  62. #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
  63. #define _DF1S   0x81
  64. #define _DF1E   0xFE
  65. #define _DS1S   0x40
  66. #define _DS1E   0x7E
  67. #define _DS2S   0xA1
  68. #define _DS2E   0xFE
  69.  
  70. #elif _CODE_PAGE == 437 /* U.S. (OEM) */
  71. #define _DF1S   0
  72. #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, \
  73.                                 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, \
  74.                                 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, \
  75.                                 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}
  76.  
  77. #elif _CODE_PAGE == 720 /* Arabic (OEM) */
  78. #define _DF1S   0
  79. #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, \
  80.                                 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, \
  81.                                 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, \
  82.                                 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}
  83.  
  84. #elif _CODE_PAGE == 737 /* Greek (OEM) */
  85. #define _DF1S   0
  86. #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, \
  87.                                 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, \
  88.                                 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, \
  89.                                 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}
  90.  
  91. #elif _CODE_PAGE == 775 /* Baltic (OEM) */
  92. #define _DF1S   0
  93. #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, \
  94.                                 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, \
  95.                                 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, \
  96.                                 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}
  97.  
  98. #elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */
  99. #define _DF1S   0
  100. #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, \
  101.                                 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, \
  102.                                 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, \
  103.                                 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}
  104.  
  105. #elif _CODE_PAGE == 852 /* Latin 2 (OEM) */
  106. #define _DF1S   0
  107. #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, \
  108.                                 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, \
  109.                                 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, \
  110.                                 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}
  111.  
  112. #elif _CODE_PAGE == 855 /* Cyrillic (OEM) */
  113. #define _DF1S   0
  114. #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, \
  115.                                 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, \
  116.                                 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, \
  117.                                 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}
  118.  
  119. #elif _CODE_PAGE == 857 /* Turkish (OEM) */
  120. #define _DF1S   0
  121. #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, \
  122.                                 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, \
  123.                                 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, \
  124.                                 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}
  125.  
  126. #elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */
  127. #define _DF1S   0
  128. #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, \
  129.                                 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, \
  130.                                 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, \
  131.                                 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}
  132.  
  133. #elif _CODE_PAGE == 862 /* Hebrew (OEM) */
  134. #define _DF1S   0
  135. #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, \
  136.                                 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, \
  137.                                 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, \
  138.                                 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}
  139.  
  140. #elif _CODE_PAGE == 866 /* Russian (OEM) */
  141. #define _DF1S   0
  142. #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, \
  143.                                 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, \
  144.                                 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, \
  145.                                 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}
  146.  
  147. #elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */
  148. #define _DF1S   0
  149. #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, \
  150.                                 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, \
  151.                                 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, \
  152.                                 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}
  153.  
  154. #elif _CODE_PAGE == 1250 /* Central Europe (Windows) */
  155. #define _DF1S   0
  156. #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, \
  157.                                 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, \
  158.                                 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, \
  159.                                 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}
  160.  
  161. #elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */
  162. #define _DF1S   0
  163. #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, \
  164.                                 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, \
  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.                                 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}
  167.  
  168. #elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */
  169. #define _DF1S   0
  170. #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, \
  171.                                 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, \
  172.                                 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, \
  173.                                 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}
  174.  
  175. #elif _CODE_PAGE == 1253 /* Greek (Windows) */
  176. #define _DF1S   0
  177. #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, \
  178.                                 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, \
  179.                                 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, \
  180.                                 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}
  181.  
  182. #elif _CODE_PAGE == 1254 /* Turkish (Windows) */
  183. #define _DF1S   0
  184. #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, \
  185.                                 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, \
  186.                                 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, \
  187.                                 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}
  188.  
  189. #elif _CODE_PAGE == 1255 /* Hebrew (Windows) */
  190. #define _DF1S   0
  191. #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, \
  192.                                 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, \
  193.                                 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, \
  194.                                 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}
  195.  
  196. #elif _CODE_PAGE == 1256 /* Arabic (Windows) */
  197. #define _DF1S   0
  198. #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, \
  199.                                 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, \
  200.                                 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, \
  201.                                 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}
  202.  
  203. #elif _CODE_PAGE == 1257 /* Baltic (Windows) */
  204. #define _DF1S   0
  205. #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, \
  206.                                 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, \
  207.                                 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, \
  208.                                 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}
  209.  
  210. #elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */
  211. #define _DF1S   0
  212. #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, \
  213.                                 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, \
  214.                                 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, \
  215.                                 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}
  216.  
  217. #elif _CODE_PAGE == 1   /* ASCII (for only non-LFN cfg) */
  218. #define _DF1S   0
  219.  
  220. #else
  221. #error Unknown code page
  222.  
  223. #endif
  224.  
  225.  
  226.  
  227. /* Definitions of volume management */
  228.  
  229. #if _MULTI_PARTITION            /* Multiple partition configuration */
  230. #define LD2PD(vol) (VolToPart[vol].pd)  /* Get physical drive# */
  231. #define LD2PT(vol) (VolToPart[vol].pt)  /* Get partition# */
  232. typedef struct {
  233.         BYTE pd;        /* Physical drive# */
  234.         BYTE pt;        /* Partition # (0-3) */
  235. } PARTITION;
  236. extern const PARTITION VolToPart[];     /* Volume - Physical location resolution table */
  237.  
  238. #else                                           /* Single partition configuration */
  239. #define LD2PD(vol) (vol)        /* Logical drive# is bound to the same physical drive# */
  240. #define LD2PT(vol) 0            /* Always mounts the 1st partition */
  241.  
  242. #endif
  243.  
  244.  
  245.  
  246. /* Type of path name strings on FatFs API */
  247.  
  248. #if _LFN_UNICODE                        /* Unicode string */
  249. #if !_USE_LFN
  250. #error _LFN_UNICODE must be 0 in non-LFN cfg.
  251. #endif
  252. #ifndef _INC_TCHAR
  253. typedef WCHAR TCHAR;
  254. #define _T(x) L ## x
  255. #define _TEXT(x) L ## x
  256. #endif
  257.  
  258. #else                                           /* ANSI/OEM string */
  259. #ifndef _INC_TCHAR
  260. typedef char TCHAR;
  261. #define _T(x) x
  262. #define _TEXT(x) x
  263. #endif
  264.  
  265. #endif
  266.  
  267.  
  268.  
  269. /* File system object structure (FATFS) */
  270.  
  271. typedef struct {
  272.         BYTE    fs_type;                /* FAT sub-type (0:Not mounted) */
  273.         BYTE    drv;                    /* Physical drive number */
  274.         BYTE    csize;                  /* Sectors per cluster (1,2,4...128) */
  275.         BYTE    n_fats;                 /* Number of FAT copies (1,2) */
  276.         BYTE    wflag;                  /* win[] dirty flag (1:must be written back) */
  277.         BYTE    fsi_flag;               /* fsinfo dirty flag (1:must be written back) */
  278.         WORD    id;                             /* File system mount ID */
  279.         WORD    n_rootdir;              /* Number of root directory entries (FAT12/16) */
  280. #if _MAX_SS != 512
  281.         WORD    ssize;                  /* Bytes per sector (512,1024,2048,4096) */
  282. #endif
  283. #if _FS_REENTRANT
  284.         _SYNC_t sobj;                   /* Identifier of sync object */
  285. #endif
  286. #if !_FS_READONLY
  287.         DWORD   last_clust;             /* Last allocated cluster */
  288.         DWORD   free_clust;             /* Number of free clusters */
  289.         DWORD   fsi_sector;             /* fsinfo sector (FAT32) */
  290. #endif
  291. #if _FS_RPATH
  292.         DWORD   cdir;                   /* Current directory start cluster (0:root) */
  293. #endif
  294.         DWORD   n_fatent;               /* Number of FAT entries (= number of clusters + 2) */
  295.         DWORD   fsize;                  /* Sectors per FAT */
  296.         DWORD   fatbase;                /* FAT start sector */
  297.         DWORD   dirbase;                /* Root directory start sector (FAT32:Cluster#) */
  298.         DWORD   database;               /* Data start sector */
  299.         DWORD   winsect;                /* Current sector appearing in the win[] */
  300.         BYTE    win[_MAX_SS];   /* Disk access window for Directory, FAT (and Data on tiny cfg) */
  301. } FATFS;
  302.  
  303.  
  304.  
  305. /* File object structure (FIL) */
  306.  
  307. typedef struct {
  308.         FATFS*  fs;                             /* Pointer to the owner file system object */
  309.         WORD    id;                             /* Owner file system mount ID */
  310.         BYTE    flag;                   /* File status flags */
  311.         BYTE    pad1;
  312.         DWORD   fptr;                   /* File read/write pointer (0 on file open) */
  313.         DWORD   fsize;                  /* File size */
  314.         DWORD   org_clust;              /* File start cluster (0 when fsize==0) */
  315.         DWORD   curr_clust;             /* Current cluster */
  316.         DWORD   dsect;                  /* Current data sector */
  317. #if !_FS_READONLY
  318.         DWORD   dir_sect;               /* Sector containing the directory entry */
  319.         BYTE*   dir_ptr;                /* Ponter to the directory entry in the window */
  320. #endif
  321. #if _USE_FASTSEEK
  322.         DWORD*  cltbl;                  /* Pointer to the cluster link map table (null on file open) */
  323. #endif
  324. #if _FS_SHARE
  325.         UINT    lockid;                 /* File lock ID (index of file semaphore table) */
  326. #endif
  327. #if !_FS_TINY
  328.         BYTE    buf[_MAX_SS];   /* File data read/write buffer */
  329. #endif
  330. } FIL;
  331.  
  332.  
  333.  
  334. /* Directory object structure (DIR) */
  335.  
  336. typedef struct {
  337.         FATFS*  fs;                             /* Pointer to the owner file system object */
  338.         WORD    id;                             /* Owner file system mount ID */
  339.         WORD    index;                  /* Current read/write index number */
  340.         DWORD   sclust;                 /* Table start cluster (0:Root dir) */
  341.         DWORD   clust;                  /* Current cluster */
  342.         DWORD   sect;                   /* Current sector */
  343.         BYTE*   dir;                    /* Pointer to the current SFN entry in the win[] */
  344.         BYTE*   fn;                             /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
  345. #if _USE_LFN
  346.         WCHAR*  lfn;                    /* Pointer to the LFN working buffer */
  347.         WORD    lfn_idx;                /* Last matched LFN index number (0xFFFF:No LFN) */
  348. #endif
  349. } DIR;
  350.  
  351.  
  352.  
  353. /* File status structure (FILINFO) */
  354.  
  355. typedef struct {
  356.         DWORD   fsize;                  /* File size */
  357.         WORD    fdate;                  /* Last modified date */
  358.         WORD    ftime;                  /* Last modified time */
  359.         BYTE    fattrib;                /* Attribute */
  360.         TCHAR   fname[13];              /* Short file name (8.3 format) */
  361. #if _USE_LFN
  362.         TCHAR*  lfname;                 /* Pointer to the LFN buffer */
  363.         UINT    lfsize;                 /* Size of LFN buffer in TCHAR */
  364. #endif
  365. } FILINFO;
  366.  
  367.  
  368.  
  369. /* File function return code (FRESULT) */
  370.  
  371. typedef enum {
  372.         FR_OK = 0,                              /* (0) Succeeded */
  373.         FR_DISK_ERR,                    /* (1) A hard error occured in the low level disk I/O layer */
  374.         FR_INT_ERR,                             /* (2) Assertion failed */
  375.         FR_NOT_READY,                   /* (3) The physical drive cannot work */
  376.         FR_NO_FILE,                             /* (4) Could not find the file */
  377.         FR_NO_PATH,                             /* (5) Could not find the path */
  378.         FR_INVALID_NAME,                /* (6) The path name format is invalid */
  379.         FR_DENIED,                              /* (7) Acces denied due to prohibited access or directory full */
  380.         FR_EXIST,                               /* (8) Acces denied due to prohibited access */
  381.         FR_INVALID_OBJECT,              /* (9) The file/directory object is invalid */
  382.         FR_WRITE_PROTECTED,             /* (10) The physical drive is write protected */
  383.         FR_INVALID_DRIVE,               /* (11) The logical drive number is invalid */
  384.         FR_NOT_ENABLED,                 /* (12) The volume has no work area */
  385.         FR_NO_FILESYSTEM,               /* (13) There is no valid FAT volume on the physical drive */
  386.         FR_MKFS_ABORTED,                /* (14) The f_mkfs() aborted due to any parameter error */
  387.         FR_TIMEOUT,                             /* (15) Could not get a grant to access the volume within defined period */
  388.         FR_LOCKED,                              /* (16) The operation is rejected according to the file shareing policy */
  389.         FR_NOT_ENOUGH_CORE,             /* (17) LFN working buffer could not be allocated */
  390.         FR_TOO_MANY_OPEN_FILES  /* (18) Number of open files > _FS_SHARE */
  391. } FRESULT;
  392.  
  393.  
  394.  
  395. /*--------------------------------------------------------------*/
  396. /* FatFs module application interface                           */
  397.  
  398. FRESULT f_mount (BYTE, FATFS*);                                         /* Mount/Unmount a logical drive */
  399. FRESULT f_open (FIL*, const TCHAR*, BYTE);                      /* Open or create a file */
  400. FRESULT f_read (FIL*, void*, UINT, UINT*);                      /* Read data from a file */
  401. FRESULT f_lseek (FIL*, DWORD);                                          /* Move file pointer of a file object */
  402. FRESULT f_close (FIL*);                                                         /* Close an open file object */
  403. FRESULT f_opendir (DIR*, const TCHAR*);                         /* Open an existing directory */
  404. FRESULT f_readdir (DIR*, FILINFO*);                                     /* Read a directory item */
  405. FRESULT f_stat (const TCHAR*, FILINFO*);                        /* Get file status */
  406.  
  407. #if !_FS_READONLY
  408. FRESULT f_write (FIL*, const void*, UINT, UINT*);       /* Write data to a file */
  409. FRESULT f_getfree (const TCHAR*, DWORD*, FATFS**);      /* Get number of free clusters on the drive */
  410. FRESULT f_truncate (FIL*);                                                      /* Truncate file */
  411. FRESULT f_sync (FIL*);                                                          /* Flush cached data of a writing file */
  412. FRESULT f_unlink (const TCHAR*);                                        /* Delete an existing file or directory */
  413. FRESULT f_mkdir (const TCHAR*);                                         /* Create a new directory */
  414. FRESULT f_chmod (const TCHAR*, BYTE, BYTE);                     /* Change attriburte of the file/dir */
  415. FRESULT f_utime (const TCHAR*, const FILINFO*);         /* Change timestamp of the file/dir */
  416. FRESULT f_rename (const TCHAR*, const TCHAR*);          /* Rename/Move a file or directory */
  417. #endif
  418.  
  419. #if _USE_FORWARD
  420. FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*);       /* Forward data to the stream */
  421. #endif
  422.  
  423. #if _USE_MKFS
  424. FRESULT f_mkfs (BYTE, BYTE, UINT);                                      /* Create a file system on the drive */
  425. #endif
  426.  
  427. #if _FS_RPATH
  428. FRESULT f_chdrive (BYTE);                                                       /* Change current drive */
  429. FRESULT f_chdir (const TCHAR*);                                         /* Change current directory */
  430. FRESULT f_getcwd (TCHAR*, UINT);                                        /* Get current directory */
  431. #endif
  432.  
  433. #if _USE_STRFUNC
  434. int f_putc (TCHAR, FIL*);                                                       /* Put a character to the file */
  435. int f_puts (const TCHAR*, FIL*);                                        /* Put a string to the file */
  436. int f_printf (FIL*, const TCHAR*, ...);                         /* Put a formatted string to the file */
  437. TCHAR* f_gets (TCHAR*, int, FIL*);                                      /* Get a string from the file */
  438. #ifndef EOF
  439. #define EOF (-1)
  440. #endif
  441. #endif
  442.  
  443. #define f_eof(fp) (((fp)->fptr == (fp)->fsize) ? 1 : 0)
  444. #define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
  445. #define f_tell(fp) ((fp)->fptr)
  446. #define f_size(fp) ((fp)->fsize)
  447.  
  448.  
  449.  
  450. /*--------------------------------------------------------------*/
  451. /* Additional user defined functions                            */
  452.  
  453. /* RTC function */
  454. #if !_FS_READONLY
  455. DWORD get_fattime (void);
  456. #endif
  457.  
  458. /* Unicode support functions */
  459. #if _USE_LFN                                            /* Unicode - OEM code conversion */
  460. WCHAR ff_convert (WCHAR, UINT);         /* OEM-Unicode bidirectional conversion */
  461. WCHAR ff_wtoupper (WCHAR);                      /* Unicode upper-case conversion */
  462. #if _USE_LFN == 3                                       /* Memory functions */
  463. void* ff_memalloc (UINT);                       /* Allocate memory block */
  464. void ff_memfree (void*);                        /* Free memory block */
  465. #endif
  466. #endif
  467.  
  468. /* Sync functions */
  469. #if _FS_REENTRANT
  470. int ff_cre_syncobj (BYTE, _SYNC_t*);/* Create a sync object */
  471. int ff_del_syncobj (_SYNC_t);           /* Delete a sync object */
  472. int ff_req_grant (_SYNC_t);                     /* Lock sync object */
  473. void ff_rel_grant (_SYNC_t);            /* Unlock sync object */
  474. #endif
  475.  
  476.  
  477.  
  478.  
  479. /*--------------------------------------------------------------*/
  480. /* Flags and offset address                                     */
  481.  
  482.  
  483. /* File access control and file status flags (FIL.flag) */
  484.  
  485. #define FA_READ                         0x01
  486. #define FA_OPEN_EXISTING        0x00
  487. #define FA__ERROR                       0x80
  488.  
  489. #if !_FS_READONLY
  490. #define FA_WRITE                        0x02
  491. #define FA_CREATE_NEW           0x04
  492. #define FA_CREATE_ALWAYS        0x08
  493. #define FA_OPEN_ALWAYS          0x10
  494. #define FA__WRITTEN                     0x20
  495. #define FA__DIRTY                       0x40
  496. #endif
  497.  
  498.  
  499. /* FAT sub type (FATFS.fs_type) */
  500.  
  501. #define FS_FAT12        1
  502. #define FS_FAT16        2
  503. #define FS_FAT32        3
  504.  
  505.  
  506. /* File attribute bits for directory entry */
  507.  
  508. #define AM_RDO  0x01    /* Read only */
  509. #define AM_HID  0x02    /* Hidden */
  510. #define AM_SYS  0x04    /* System */
  511. #define AM_VOL  0x08    /* Volume label */
  512. #define AM_LFN  0x0F    /* LFN entry */
  513. #define AM_DIR  0x10    /* Directory */
  514. #define AM_ARC  0x20    /* Archive */
  515. #define AM_MASK 0x3F    /* Mask of defined bits */
  516.  
  517.  
  518. /* Fast seek function */
  519. #define CREATE_LINKMAP  0xFFFFFFFF
  520.  
  521.  
  522. /*--------------------------------*/
  523. /* Multi-byte word access macros  */
  524.  
  525. #if _WORD_ACCESS == 1   /* Enable word access to the FAT structure */
  526. #define LD_WORD(ptr)            (WORD)(*(WORD*)(BYTE*)(ptr))
  527. #define LD_DWORD(ptr)           (DWORD)(*(DWORD*)(BYTE*)(ptr))
  528. #define ST_WORD(ptr,val)        *(WORD*)(BYTE*)(ptr)=(WORD)(val)
  529. #define ST_DWORD(ptr,val)       *(DWORD*)(BYTE*)(ptr)=(DWORD)(val)
  530. #else                                   /* Use byte-by-byte access to the FAT structure */
  531. #define LD_WORD(ptr)            (WORD)(((WORD)*(BYTE*)((ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
  532. #define LD_DWORD(ptr)           (DWORD)(((DWORD)*(BYTE*)((ptr)+3)<<24)|((DWORD)*(BYTE*)((ptr)+2)<<16)|((WORD)*(BYTE*)((ptr)+1)<<8)|*(BYTE*)(ptr))
  533. #define ST_WORD(ptr,val)        *(BYTE*)(ptr)=(BYTE)(val); *(BYTE*)((ptr)+1)=(BYTE)((WORD)(val)>>8)
  534. #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)
  535. #endif
  536.  
  537. #ifdef __cplusplus
  538. }
  539. #endif
  540.  
  541. #endif /* _FATFS */
  542.