[技术问答] 谁有支持长文件名的ff.c文件,最近玩M451的U盘

[复制链接]
3006|10
 楼主| weizhiwuxian 发表于 2016-4-18 23:27 | 显示全部楼层 |阅读模式
谁有支持长文件名的ff.c文件,最近玩M451的U盘
发现ff.c文件名是8.3格式的
 楼主| weizhiwuxian 发表于 2016-4-18 23:42 | 显示全部楼层
咋没人答,要要求支持长文件英文即可,
deviceplugs 发表于 2016-4-19 11:17 | 显示全部楼层
在网上搜索一下不就可以了吗,这个应该有吧
wahahaheihei 发表于 2016-4-19 20:34 | 显示全部楼层
  1. ff.c.rar (38.75 KB, 下载次数: 15)



wahahaheihei 发表于 2016-4-19 20:35 | 显示全部楼层
ff.h
  1. /*---------------------------------------------------------------------------/
  2. /  FatFs - FAT file system module include R0.12     (C)ChaN, 2016
  3. /----------------------------------------------------------------------------/
  4. / FatFs module is a free software that opened under license policy of
  5. / following conditions.
  6. /
  7. / Copyright (C) 2016, ChaN, all right reserved.
  8. /
  9. / 1. Redistributions of source code must retain the above copyright notice,
  10. /    this condition and the following disclaimer.
  11. /
  12. / This software is provided by the copyright holder and contributors "AS IS"
  13. / and any warranties related to this software are DISCLAIMED.
  14. / The copyright owner or contributors be NOT LIABLE for any damages caused
  15. / by use of this software.
  16. /---------------------------------------------------------------------------*/


  17. #ifndef _FATFS
  18. #define _FATFS        88100        /* Revision ID */

  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif

  22. #include "integer.h"        /* Basic integer types */
  23. #include "ffconf.h"                /* FatFs configuration options */
  24. #if _FATFS != _FFCONF
  25. #error Wrong configuration file (ffconf.h).
  26. #endif



  27. /* Definitions of volume management */

  28. #if _MULTI_PARTITION                /* Multiple partition configuration */
  29. typedef struct {
  30.         BYTE pd;        /* Physical drive number */
  31.         BYTE pt;        /* Partition: 0:Auto detect, 1-4:Forced partition) */
  32. } PARTITION;
  33. extern PARTITION VolToPart[];        /* Volume - Partition resolution table */
  34. #define LD2PD(vol) (VolToPart[vol].pd)        /* Get physical drive number */
  35. #define LD2PT(vol) (VolToPart[vol].pt)        /* Get partition index */

  36. #else                                                        /* Single partition configuration */
  37. #define LD2PD(vol) (BYTE)(vol)        /* Each logical drive is bound to the same physical drive number */
  38. #define LD2PT(vol) 0                        /* Find first valid partition or in SFD */

  39. #endif



  40. /* Type of path name strings on FatFs API */

  41. #if _LFN_UNICODE                        /* Unicode string */
  42. #if _USE_LFN == 0
  43. #error _LFN_UNICODE must be 0 at non-LFN cfg.
  44. #endif
  45. #ifndef _INC_TCHAR
  46. typedef WCHAR TCHAR;
  47. #define _T(x) L ## x
  48. #define _TEXT(x) L ## x
  49. #endif

  50. #else                                                /* ANSI/OEM string */
  51. #ifndef _INC_TCHAR
  52. typedef char TCHAR;
  53. #define _T(x) x
  54. #define _TEXT(x) x
  55. #endif

  56. #endif



  57. /* File system object structure (FATFS) */

  58. typedef struct {
  59.         BYTE        fs_type;                /* File system type (0:N/A) */
  60.         BYTE        drv;                        /* Physical drive number */
  61.         BYTE        n_fats;                        /* Number of FATs (1 or 2) */
  62.         BYTE        wflag;                        /* win[] flag (b0:dirty) */
  63.         BYTE        fsi_flag;                /* FSINFO flags (b7:disabled, b0:dirty) */
  64.         WORD        id;                                /* File system mount ID */
  65.         WORD        n_rootdir;                /* Number of root directory entries (FAT12/16) */
  66.         WORD        csize;                        /* Cluster size [sectors] */
  67. #if _MAX_SS != _MIN_SS
  68.         WORD        ssize;                        /* Sector size (512, 1024, 2048 or 4096) */
  69. #endif
  70. #if _FS_EXFAT
  71.         BYTE*        dirbuf;                        /* Directory entry block scratchpad buffer */
  72. #endif
  73. #if _FS_REENTRANT
  74.         _SYNC_t        sobj;                        /* Identifier of sync object */
  75. #endif
  76. #if !_FS_READONLY
  77.         DWORD        last_clst;                /* Last allocated cluster */
  78.         DWORD        free_clst;                /* Number of free clusters */
  79. #endif
  80. #if _FS_RPATH != 0
  81.         DWORD        cdir;                        /* Current directory start cluster (0:root) */
  82. #if _FS_EXFAT
  83.         DWORD        cdc_scl;                /* Containing directory start cluster (invalid when cdir is 0) */
  84.         DWORD        cdc_size;                /* b31-b8:Size of containing directory, b7-b0: Chain status */
  85.         DWORD        cdc_ofs;                /* Offset in the containing directory (invalid when cdir is 0) */
  86. #endif
  87. #endif
  88.         DWORD        n_fatent;                /* Number of FAT entries (number of clusters + 2) */
  89.         DWORD        fsize;                        /* Size of an FAT [sectors] */
  90.         DWORD        volbase;                /* Volume base sector */
  91.         DWORD        fatbase;                /* FAT base sector */
  92.         DWORD        dirbase;                /* Root directory base sector/cluster */
  93.         DWORD        database;                /* Data base sector */
  94.         DWORD        winsect;                /* Current sector appearing in the win[] */
  95.         BYTE        win[_MAX_SS];        /* Disk access window for Directory, FAT (and file data at tiny cfg) */
  96. } FATFS;



  97. /* Type of file size variables and object identifier */

  98. #if _FS_EXFAT
  99. #if _USE_LFN == 0
  100. #error LFN must be enabled when enable exFAT
  101. #endif
  102. typedef QWORD FSIZE_t;
  103. #else
  104. typedef DWORD FSIZE_t;
  105. #endif



  106. /* Object ID and allocation information (_FDID) */

  107. typedef struct {
  108.         FATFS*        fs;                        /* Pointer to the owner file system object */
  109.         WORD        id;                        /* Owner file system mount ID */
  110.         BYTE        attr;                /* Object attribute */
  111.         BYTE        stat;                /* Object chain status (b1-0: =0:not contiguous, =2:contiguous (no data on FAT), =3:got flagmented, b2:sub-directory stretched) */
  112.         DWORD        sclust;                /* Object start cluster (0:no cluster or root directory) */
  113.         FSIZE_t        objsize;        /* Object size (valid when sclust != 0) */
  114. #if _FS_EXFAT
  115.         DWORD        n_cont;                /* Size of coutiguous part, clusters - 1 (valid when stat == 3) */
  116.         DWORD        c_scl;                /* Containing directory start cluster (valid when sclust != 0) */
  117.         DWORD        c_size;                /* b31-b8:Size of containing directory, b7-b0: Chain status (valid when c_scl != 0) */
  118.         DWORD        c_ofs;                /* Offset in the containing directory (valid when sclust != 0) */
  119. #endif
  120. #if _FS_LOCK != 0
  121.         UINT        lockid;                /* File lock ID origin from 1 (index of file semaphore table Files[]) */
  122. #endif
  123. } _FDID;



  124. /* File object structure (FIL) */

  125. typedef struct {
  126.         _FDID        obj;                        /* Object identifier */
  127.         BYTE        flag;                        /* File status flags */
  128.         BYTE        err;                        /* Abort flag (error code) */
  129.         FSIZE_t        fptr;                        /* File read/write pointer (Zeroed on file open) */
  130.         DWORD        clust;                        /* Current cluster of fpter (not valid when fprt is 0) */
  131.         DWORD        sect;                        /* Sector number appearing in buf[] (0:invalid) */
  132. #if !_FS_READONLY
  133.         DWORD        dir_sect;                /* Sector number containing the directory entry */
  134.         BYTE*        dir_ptr;                /* Pointer to the directory entry in the win[] */
  135. #endif
  136. #if _USE_FASTSEEK
  137.         DWORD*        cltbl;                        /* Pointer to the cluster link map table (Nulled on file open) */
  138. #endif
  139. #if !_FS_TINY
  140.         BYTE        buf[_MAX_SS];        /* File private data read/write window */
  141. #endif
  142. } FIL;



  143. /* Directory object structure (DIR) */

  144. typedef struct {
  145.         _FDID        obj;                        /* Object identifier */
  146.         DWORD        dptr;                        /* Current read/write offset */
  147.         DWORD        clust;                        /* Current cluster */
  148.         DWORD        sect;                        /* Current sector */
  149.         BYTE*        dir;                        /* Pointer to the directory item in the win[] */
  150.         BYTE*        fn;                                /* Pointer to the SFN (in/out) {body[8],ext[3],status[1]} */
  151. #if _USE_LFN != 0
  152.         DWORD        blk_ofs;                /* Offset of current entry block being processed (0xFFFFFFFF:Invalid) */
  153.         WCHAR*        lfn;                        /* Pointer to the LFN working buffer */
  154. #endif
  155. #if _USE_FIND
  156.         const TCHAR* pat;                /* Pointer to the name matching pattern */
  157. #endif
  158. } DIR;



  159. /* File information structure (FILINFO) */

  160. typedef struct {
  161.         FSIZE_t        fsize;                        /* File size */
  162.         WORD        fdate;                        /* Modified date */
  163.         WORD        ftime;                        /* Modified time */
  164.         BYTE        fattrib;                /* File attribute */
  165. #if _USE_LFN != 0
  166.         TCHAR        altname[13];                        /* Altenative file name */
  167.         TCHAR        fname[_MAX_LFN + 1];        /* Primary file name */
  168. #else
  169.         TCHAR        fname[13];                /* File name */
  170. #endif
  171. } FILINFO;



  172. /* File function return code (FRESULT) */

  173. typedef enum {
  174.         FR_OK = 0,                                /* (0) Succeeded */
  175.         FR_DISK_ERR,                        /* (1) A hard error occurred in the low level disk I/O layer */
  176.         FR_INT_ERR,                                /* (2) Assertion failed */
  177.         FR_NOT_READY,                        /* (3) The physical drive cannot work */
  178.         FR_NO_FILE,                                /* (4) Could not find the file */
  179.         FR_NO_PATH,                                /* (5) Could not find the path */
  180.         FR_INVALID_NAME,                /* (6) The path name format is invalid */
  181.         FR_DENIED,                                /* (7) Access denied due to prohibited access or directory full */
  182.         FR_EXIST,                                /* (8) Access denied due to prohibited access */
  183.         FR_INVALID_OBJECT,                /* (9) The file/directory object is invalid */
  184.         FR_WRITE_PROTECTED,                /* (10) The physical drive is write protected */
  185.         FR_INVALID_DRIVE,                /* (11) The logical drive number is invalid */
  186.         FR_NOT_ENABLED,                        /* (12) The volume has no work area */
  187.         FR_NO_FILESYSTEM,                /* (13) There is no valid FAT volume */
  188.         FR_MKFS_ABORTED,                /* (14) The f_mkfs() aborted due to any parameter error */
  189.         FR_TIMEOUT,                                /* (15) Could not get a grant to access the volume within defined period */
  190.         FR_LOCKED,                                /* (16) The operation is rejected according to the file sharing policy */
  191.         FR_NOT_ENOUGH_CORE,                /* (17) LFN working buffer could not be allocated */
  192.         FR_TOO_MANY_OPEN_FILES,        /* (18) Number of open files > _FS_LOCK */
  193.         FR_INVALID_PARAMETER        /* (19) Given parameter is invalid */
  194. } FRESULT;



  195. /*--------------------------------------------------------------*/
  196. /* FatFs module application interface                           */

  197. FRESULT f_open (FIL* fp, const TCHAR* path, BYTE mode);                                /* Open or create a file */
  198. FRESULT f_close (FIL* fp);                                                                                        /* Close an open file object */
  199. FRESULT f_read (FIL* fp, void* buff, UINT btr, UINT* br);                        /* Read data from a file */
  200. FRESULT f_write (FIL* fp, const void* buff, UINT btw, UINT* bw);        /* Write data to a file */
  201. FRESULT f_lseek (FIL* fp, FSIZE_t ofs);                                                                /* Move file pointer of a file object */
  202. FRESULT f_truncate (FIL* fp);                                                                                /* Truncate file */
  203. FRESULT f_sync (FIL* fp);                                                                                        /* Flush cached data of a writing file */
  204. FRESULT f_opendir (DIR* dp, const TCHAR* path);                                                /* Open a directory */
  205. FRESULT f_closedir (DIR* dp);                                                                                /* Close an open directory */
  206. FRESULT f_readdir (DIR* dp, FILINFO* fno);                                                        /* Read a directory item */
  207. FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern);        /* Find first file */
  208. FRESULT f_findnext (DIR* dp, FILINFO* fno);                                                        /* Find next file */
  209. FRESULT f_mkdir (const TCHAR* path);                                                                /* Create a sub directory */
  210. FRESULT f_unlink (const TCHAR* path);                                                                /* Delete an existing file or directory */
  211. FRESULT f_rename (const TCHAR* path_old, const TCHAR* path_new);        /* Rename/Move a file or directory */
  212. FRESULT f_stat (const TCHAR* path, FILINFO* fno);                                        /* Get file status */
  213. FRESULT f_chmod (const TCHAR* path, BYTE attr, BYTE mask);                        /* Change attribute of the file/dir */
  214. FRESULT f_utime (const TCHAR* path, const FILINFO* fno);                        /* Change timestamp of the file/dir */
  215. FRESULT f_chdir (const TCHAR* path);                                                                /* Change current directory */
  216. FRESULT f_chdrive (const TCHAR* path);                                                                /* Change current drive */
  217. FRESULT f_getcwd (TCHAR* buff, UINT len);                                                        /* Get current directory */
  218. FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs);        /* Get number of free clusters on the drive */
  219. FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* vsn);        /* Get volume label */
  220. FRESULT f_setlabel (const TCHAR* label);                                                        /* Set volume label */
  221. FRESULT f_forward (FIL* fp, UINT(*func)(const BYTE*,UINT), UINT btf, UINT* bf);        /* Forward data to the stream */
  222. FRESULT f_expand (FIL* fp, FSIZE_t szf, BYTE opt);                                        /* Allocate a contiguous block to the file */
  223. FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt);                        /* Mount/Unmount a logical drive */
  224. FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au);                                /* Create a file system on the volume */
  225. FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work);                        /* Divide a physical drive into some partitions */
  226. int f_putc (TCHAR c, FIL* fp);                                                                                /* Put a character to the file */
  227. int f_puts (const TCHAR* str, FIL* cp);                                                                /* Put a string to the file */
  228. int f_printf (FIL* fp, const TCHAR* str, ...);                                                /* Put a formatted string to the file */
  229. TCHAR* f_gets (TCHAR* buff, int len, FIL* fp);                                                /* Get a string from the file */

  230. #define f_eof(fp) ((int)((fp)->fptr == (fp)->obj.objsize))
  231. #define f_error(fp) ((fp)->err)
  232. #define f_tell(fp) ((fp)->fptr)
  233. #define f_size(fp) ((fp)->obj.objsize)
  234. #define f_rewind(fp) f_lseek((fp), 0)
  235. #define f_rewinddir(dp) f_readdir((dp), 0)

  236. #ifndef EOF
  237. #define EOF (-1)
  238. #endif




  239. /*--------------------------------------------------------------*/
  240. /* Additional user defined functions                            */

  241. /* RTC function */
  242. #if !_FS_READONLY && !_FS_NORTC
  243. DWORD get_fattime (void);
  244. #endif

  245. /* Unicode support functions */
  246. #if _USE_LFN != 0                                                /* Unicode - OEM code conversion */
  247. WCHAR ff_convert (WCHAR chr, UINT dir);        /* OEM-Unicode bidirectional conversion */
  248. WCHAR ff_wtoupper (WCHAR chr);                        /* Unicode upper-case conversion */
  249. #if _USE_LFN == 3                                                /* Memory functions */
  250. void* ff_memalloc (UINT msize);                        /* Allocate memory block */
  251. void ff_memfree (void* mblock);                        /* Free memory block */
  252. #endif
  253. #endif

  254. /* Sync functions */
  255. #if _FS_REENTRANT
  256. int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj);        /* Create a sync object */
  257. int ff_req_grant (_SYNC_t sobj);                                /* Lock sync object */
  258. void ff_rel_grant (_SYNC_t sobj);                                /* Unlock sync object */
  259. int ff_del_syncobj (_SYNC_t sobj);                                /* Delete a sync object */
  260. #endif




  261. /*--------------------------------------------------------------*/
  262. /* Flags and offset address                                     */


  263. /* File access control and file status flags (FIL.flag) */

  264. #define        FA_READ                                0x01
  265. #define        FA_WRITE                        0x02
  266. #define        FA_OPEN_EXISTING        0x00
  267. #define        FA_CREATE_NEW                0x04
  268. #define        FA_CREATE_ALWAYS        0x08
  269. #define        FA_OPEN_ALWAYS                0x10
  270. #define _FA_MODIFIED                0x20
  271. #define _FA_DIRTY                        0x40


  272. /* FAT sub type (FATFS.fs_type) */

  273. #define FS_FAT12        1
  274. #define FS_FAT16        2
  275. #define FS_FAT32        3
  276. #define FS_EXFAT        4


  277. /* File attribute bits for directory entry */

  278. #define        AM_RDO        0x01        /* Read only */
  279. #define        AM_HID        0x02        /* Hidden */
  280. #define        AM_SYS        0x04        /* System */
  281. #define        AM_VOL        0x08        /* Volume label */
  282. #define AM_LFN        0x0F        /* LFN entry */
  283. #define AM_DIR        0x10        /* Directory */
  284. #define AM_ARC        0x20        /* Archive */
  285. #define AM_MASK        0x3F        /* Mask of defined bits */


  286. /* Fast seek controls */
  287. #define CREATE_LINKMAP        ((FSIZE_t)0 - 1)


  288. #ifdef __cplusplus
  289. }
  290. #endif

  291. #endif /* _FATFS */


wahahaheihei 发表于 2016-4-19 20:36 | 显示全部楼层
diskio.c
  1. /*-----------------------------------------------------------------------*/
  2. /* Low level disk I/O module skeleton for FatFs     (C)ChaN, 2016        */
  3. /*-----------------------------------------------------------------------*/
  4. /* If a working storage control module is available, it should be        */
  5. /* attached to the FatFs via a glue function rather than modifying it.   */
  6. /* This is an example of glue functions to attach various exsisting      */
  7. /* storage control modules to the FatFs module with a defined API.       */
  8. /*-----------------------------------------------------------------------*/

  9. #include "diskio.h"                /* FatFs lower layer API */
  10. #include "usbdisk.h"        /* Example: Header file of existing USB MSD control module */
  11. #include "atadrive.h"        /* Example: Header file of existing ATA harddisk control module */
  12. #include "sdcard.h"                /* Example: Header file of existing MMC/SDC contorl module */

  13. /* Definitions of physical drive number for each drive */
  14. #define ATA                0        /* Example: Map ATA harddisk to physical drive 0 */
  15. #define MMC                1        /* Example: Map MMC/SD card to physical drive 1 */
  16. #define USB                2        /* Example: Map USB MSD to physical drive 2 */


  17. /*-----------------------------------------------------------------------*/
  18. /* Get Drive Status                                                      */
  19. /*-----------------------------------------------------------------------*/

  20. DSTATUS disk_status (
  21.         BYTE pdrv                /* Physical drive nmuber to identify the drive */
  22. )
  23. {
  24.         DSTATUS stat;
  25.         int result;

  26.         switch (pdrv) {
  27.         case ATA :
  28.                 result = ATA_disk_status();

  29.                 // translate the reslut code here

  30.                 return stat;

  31.         case MMC :
  32.                 result = MMC_disk_status();

  33.                 // translate the reslut code here

  34.                 return stat;

  35.         case USB :
  36.                 result = USB_disk_status();

  37.                 // translate the reslut code here

  38.                 return stat;
  39.         }
  40.         return STA_NOINIT;
  41. }



  42. /*-----------------------------------------------------------------------*/
  43. /* Inidialize a Drive                                                    */
  44. /*-----------------------------------------------------------------------*/

  45. DSTATUS disk_initialize (
  46.         BYTE pdrv                                /* Physical drive nmuber to identify the drive */
  47. )
  48. {
  49.         DSTATUS stat;
  50.         int result;

  51.         switch (pdrv) {
  52.         case ATA :
  53.                 result = ATA_disk_initialize();

  54.                 // translate the reslut code here

  55.                 return stat;

  56.         case MMC :
  57.                 result = MMC_disk_initialize();

  58.                 // translate the reslut code here

  59.                 return stat;

  60.         case USB :
  61.                 result = USB_disk_initialize();

  62.                 // translate the reslut code here

  63.                 return stat;
  64.         }
  65.         return STA_NOINIT;
  66. }



  67. /*-----------------------------------------------------------------------*/
  68. /* Read Sector(s)                                                        */
  69. /*-----------------------------------------------------------------------*/

  70. DRESULT disk_read (
  71.         BYTE pdrv,                /* Physical drive nmuber to identify the drive */
  72.         BYTE *buff,                /* Data buffer to store read data */
  73.         DWORD sector,        /* Sector address in LBA */
  74.         UINT count                /* Number of sectors to read */
  75. )
  76. {
  77.         DRESULT res;
  78.         int result;

  79.         switch (pdrv) {
  80.         case ATA :
  81.                 // translate the arguments here

  82.                 result = ATA_disk_read(buff, sector, count);

  83.                 // translate the reslut code here

  84.                 return res;

  85.         case MMC :
  86.                 // translate the arguments here

  87.                 result = MMC_disk_read(buff, sector, count);

  88.                 // translate the reslut code here

  89.                 return res;

  90.         case USB :
  91.                 // translate the arguments here

  92.                 result = USB_disk_read(buff, sector, count);

  93.                 // translate the reslut code here

  94.                 return res;
  95.         }

  96.         return RES_PARERR;
  97. }



  98. /*-----------------------------------------------------------------------*/
  99. /* Write Sector(s)                                                       */
  100. /*-----------------------------------------------------------------------*/

  101. DRESULT disk_write (
  102.         BYTE pdrv,                        /* Physical drive nmuber to identify the drive */
  103.         const BYTE *buff,        /* Data to be written */
  104.         DWORD sector,                /* Sector address in LBA */
  105.         UINT count                        /* Number of sectors to write */
  106. )
  107. {
  108.         DRESULT res;
  109.         int result;

  110.         switch (pdrv) {
  111.         case ATA :
  112.                 // translate the arguments here

  113.                 result = ATA_disk_write(buff, sector, count);

  114.                 // translate the reslut code here

  115.                 return res;

  116.         case MMC :
  117.                 // translate the arguments here

  118.                 result = MMC_disk_write(buff, sector, count);

  119.                 // translate the reslut code here

  120.                 return res;

  121.         case USB :
  122.                 // translate the arguments here

  123.                 result = USB_disk_write(buff, sector, count);

  124.                 // translate the reslut code here

  125.                 return res;
  126.         }

  127.         return RES_PARERR;
  128. }



  129. /*-----------------------------------------------------------------------*/
  130. /* Miscellaneous Functions                                               */
  131. /*-----------------------------------------------------------------------*/

  132. DRESULT disk_ioctl (
  133.         BYTE pdrv,                /* Physical drive nmuber (0..) */
  134.         BYTE cmd,                /* Control code */
  135.         void *buff                /* Buffer to send/receive control data */
  136. )
  137. {
  138.         DRESULT res;
  139.         int result;

  140.         switch (pdrv) {
  141.         case ATA :

  142.                 // Process of the command for the ATA drive

  143.                 return res;

  144.         case MMC :

  145.                 // Process of the command for the MMC/SD card

  146.                 return res;

  147.         case USB :

  148.                 // Process of the command the USB drive

  149.                 return res;
  150.         }

  151.         return RES_PARERR;
  152. }


wahahaheihei 发表于 2016-4-19 20:36 | 显示全部楼层
ffconf.h
------------------------------

  1. /*---------------------------------------------------------------------------/
  2. /  FatFs - FAT file system module configuration file  R0.12  (C)ChaN, 2016
  3. /---------------------------------------------------------------------------*/

  4. #define _FFCONF 88100        /* Revision ID */

  5. /*---------------------------------------------------------------------------/
  6. / Function Configurations
  7. /---------------------------------------------------------------------------*/

  8. #define _FS_READONLY        0
  9. /* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
  10. /  Read-only configuration removes writing API functions, f_write(), f_sync(),
  11. /  f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
  12. /  and optional writing functions as well. */


  13. #define _FS_MINIMIZE        0
  14. /* This option defines minimization level to remove some basic API functions.
  15. /
  16. /   0: All basic functions are enabled.
  17. /   1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_truncate() and f_rename()
  18. /      are removed.
  19. /   2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
  20. /   3: f_lseek() function is removed in addition to 2. */


  21. #define        _USE_STRFUNC        0
  22. /* This option switches string functions, f_gets(), f_putc(), f_puts() and
  23. /  f_printf().
  24. /
  25. /  0: Disable string functions.
  26. /  1: Enable without LF-CRLF conversion.
  27. /  2: Enable with LF-CRLF conversion. */


  28. #define _USE_FIND                0
  29. /* This option switches filtered directory read functions, f_findfirst() and
  30. /  f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */


  31. #define        _USE_MKFS                0
  32. /* This option switches f_mkfs() function. (0:Disable or 1:Enable) */


  33. #define        _USE_FASTSEEK        0
  34. /* This option switches fast seek function. (0:Disable or 1:Enable) */


  35. #define        _USE_EXPAND                0
  36. /* This option switches f_expand function. (0:Disable or 1:Enable) */


  37. #define _USE_CHMOD                0
  38. /* This option switches attribute manipulation functions, f_chmod() and f_utime().
  39. /  (0:Disable or 1:Enable) Also _FS_READONLY needs to be 0 to enable this option. */


  40. #define _USE_LABEL                0
  41. /* This option switches volume label functions, f_getlabel() and f_setlabel().
  42. /  (0:Disable or 1:Enable) */


  43. #define        _USE_FORWARD        0
  44. /* This option switches f_forward() function. (0:Disable or 1:Enable)
  45. /  To enable it, also _FS_TINY need to be 1. */


  46. /*---------------------------------------------------------------------------/
  47. / Locale and Namespace Configurations
  48. /---------------------------------------------------------------------------*/

  49. #define _CODE_PAGE        932
  50. /* This option specifies the OEM code page to be used on the target system.
  51. /  Incorrect setting of the code page can cause a file open failure.
  52. /
  53. /   1   - ASCII (No extended character. Non-LFN cfg. only)
  54. /   437 - U.S.
  55. /   720 - Arabic
  56. /   737 - Greek
  57. /   771 - KBL
  58. /   775 - Baltic
  59. /   850 - Latin 1
  60. /   852 - Latin 2
  61. /   855 - Cyrillic
  62. /   857 - Turkish
  63. /   860 - Portuguese
  64. /   861 - Icelandic
  65. /   862 - Hebrew
  66. /   863 - Canadian French
  67. /   864 - Arabic
  68. /   865 - Nordic
  69. /   866 - Russian
  70. /   869 - Greek 2
  71. /   932 - Japanese (DBCS)
  72. /   936 - Simplified Chinese (DBCS)
  73. /   949 - Korean (DBCS)
  74. /   950 - Traditional Chinese (DBCS)
  75. */


  76. #define        _USE_LFN        0
  77. #define        _MAX_LFN        255
  78. /* The _USE_LFN switches the support of long file name (LFN).
  79. /
  80. /   0: Disable support of LFN. _MAX_LFN has no effect.
  81. /   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
  82. /   2: Enable LFN with dynamic working buffer on the STACK.
  83. /   3: Enable LFN with dynamic working buffer on the HEAP.
  84. /
  85. /  To enable the LFN, Unicode handling functions (option/unicode.c) must be added
  86. /  to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and
  87. /  additional 608 bytes at exFAT enabled. _MAX_LFN can be in range from 12 to 255.
  88. /  It should be set 255 to support full featured LFN operations.
  89. /  When use stack for the working buffer, take care on stack overflow. When use heap
  90. /  memory for the working buffer, memory management functions, ff_memalloc() and
  91. /  ff_memfree(), must be added to the project. */


  92. #define        _LFN_UNICODE        0
  93. /* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
  94. /  To use Unicode string for the path name, enable LFN and set _LFN_UNICODE = 1.
  95. /  This option also affects behavior of string I/O functions. */


  96. #define _STRF_ENCODE        3
  97. /* When _LFN_UNICODE == 1, this option selects the character encoding on the file to
  98. /  be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
  99. /
  100. /  0: ANSI/OEM
  101. /  1: UTF-16LE
  102. /  2: UTF-16BE
  103. /  3: UTF-8
  104. /
  105. /  This option has no effect when _LFN_UNICODE == 0. */


  106. #define _FS_RPATH        0
  107. /* This option configures support of relative path.
  108. /
  109. /   0: Disable relative path and remove related functions.
  110. /   1: Enable relative path. f_chdir() and f_chdrive() are available.
  111. /   2: f_getcwd() function is available in addition to 1.
  112. */


  113. /*---------------------------------------------------------------------------/
  114. / Drive/Volume Configurations
  115. /---------------------------------------------------------------------------*/

  116. #define _VOLUMES        1
  117. /* Number of volumes (logical drives) to be used. */


  118. #define _STR_VOLUME_ID        0
  119. #define _VOLUME_STRS        "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
  120. /* _STR_VOLUME_ID switches string support of volume ID.
  121. /  When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
  122. /  number in the path name. _VOLUME_STRS defines the drive ID strings for each
  123. /  logical drives. Number of items must be equal to _VOLUMES. Valid characters for
  124. /  the drive ID strings are: A-Z and 0-9. */


  125. #define        _MULTI_PARTITION        0
  126. /* This option switches support of multi-partition on a physical drive.
  127. /  By default (0), each logical drive number is bound to the same physical drive
  128. /  number and only an FAT volume found on the physical drive will be mounted.
  129. /  When multi-partition is enabled (1), each logical drive number can be bound to
  130. /  arbitrary physical drive and partition listed in the VolToPart[]. Also f_fdisk()
  131. /  funciton will be available. */


  132. #define        _MIN_SS                512
  133. #define        _MAX_SS                512
  134. /* These options configure the range of sector size to be supported. (512, 1024,
  135. /  2048 or 4096) Always set both 512 for most systems, all type of memory cards and
  136. /  harddisk. But a larger value may be required for on-board flash memory and some
  137. /  type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
  138. /  to variable sector size and GET_SECTOR_SIZE command must be implemented to the
  139. /  disk_ioctl() function. */


  140. #define        _USE_TRIM        0
  141. /* This option switches support of ATA-TRIM. (0:Disable or 1:Enable)
  142. /  To enable Trim function, also CTRL_TRIM command should be implemented to the
  143. /  disk_ioctl() function. */


  144. #define _FS_NOFSINFO        0
  145. /* If you need to know correct free space on the FAT32 volume, set bit 0 of this
  146. /  option, and f_getfree() function at first time after volume mount will force
  147. /  a full FAT scan. Bit 1 controls the use of last allocated cluster number.
  148. /
  149. /  bit0=0: Use free cluster count in the FSINFO if available.
  150. /  bit0=1: Do not trust free cluster count in the FSINFO.
  151. /  bit1=0: Use last allocated cluster number in the FSINFO if available.
  152. /  bit1=1: Do not trust last allocated cluster number in the FSINFO.
  153. */



  154. /*---------------------------------------------------------------------------/
  155. / System Configurations
  156. /---------------------------------------------------------------------------*/

  157. #define        _FS_TINY        0
  158. /* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
  159. /  At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS bytes.
  160. /  Instead of private sector buffer eliminated from the file object, common sector
  161. /  buffer in the file system object (FATFS) is used for the file data transfer. */


  162. #define _FS_EXFAT        0
  163. /* This option switches support of exFAT file system in addition to the traditional
  164. /  FAT file system. (0:Disable or 1:Enable) To enable exFAT, also LFN must be enabled.
  165. /  Note that enabling exFAT discards C89 compatibility. */


  166. #define _FS_NORTC        0
  167. #define _NORTC_MON        3
  168. #define _NORTC_MDAY        1
  169. #define _NORTC_YEAR        2016
  170. /* The option _FS_NORTC switches timestamp functiton. If the system does not have
  171. /  any RTC function or valid timestamp is not needed, set _FS_NORTC = 1 to disable
  172. /  the timestamp function. All objects modified by FatFs will have a fixed timestamp
  173. /  defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time.
  174. /  To enable timestamp function (_FS_NORTC = 0), get_fattime() function need to be
  175. /  added to the project to get current time form real-time clock. _NORTC_MON,
  176. /  _NORTC_MDAY and _NORTC_YEAR have no effect.
  177. /  These options have no effect at read-only configuration (_FS_READONLY = 1). */


  178. #define        _FS_LOCK        0
  179. /* The option _FS_LOCK switches file lock function to control duplicated file open
  180. /  and illegal operation to open objects. This option must be 0 when _FS_READONLY
  181. /  is 1.
  182. /
  183. /  0:  Disable file lock function. To avoid volume corruption, application program
  184. /      should avoid illegal open, remove and rename to the open objects.
  185. /  >0: Enable file lock function. The value defines how many files/sub-directories
  186. /      can be opened simultaneously under file lock control. Note that the file
  187. /      lock control is independent of re-entrancy. */


  188. #define _FS_REENTRANT        0
  189. #define _FS_TIMEOUT                1000
  190. #define        _SYNC_t                        HANDLE
  191. /* The option _FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
  192. /  module itself. Note that regardless of this option, file access to different
  193. /  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
  194. /  and f_fdisk() function, are always not re-entrant. Only file/directory access
  195. /  to the same volume is under control of this function.
  196. /
  197. /   0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
  198. /   1: Enable re-entrancy. Also user provided synchronization handlers,
  199. /      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
  200. /      function, must be added to the project. Samples are available in
  201. /      option/syscall.c.
  202. /
  203. /  The _FS_TIMEOUT defines timeout period in unit of time tick.
  204. /  The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
  205. /  SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
  206. /  included somewhere in the scope of ff.c. */


  207. /*--- End of configuration options ---*/


wahahaheihei 发表于 2016-4-19 20:37 | 显示全部楼层
integer.h


  1. /*-------------------------------------------*/
  2. /* Integer type definitions for FatFs module */
  3. /*-------------------------------------------*/

  4. #ifndef _FF_INTEGER
  5. #define _FF_INTEGER

  6. #ifdef _WIN32        /* FatFs development platform */

  7. #include <windows.h>
  8. #include <tchar.h>
  9. typedef unsigned __int64 QWORD;


  10. #else                        /* Embedded platform */

  11. /* These types MUST be 16-bit or 32-bit */
  12. typedef int                                INT;
  13. typedef unsigned int        UINT;

  14. /* This type MUST be 8-bit */
  15. typedef unsigned char        BYTE;

  16. /* These types MUST be 16-bit */
  17. typedef short                        SHORT;
  18. typedef unsigned short        WORD;
  19. typedef unsigned short        WCHAR;

  20. /* These types MUST be 32-bit */
  21. typedef long                        LONG;
  22. typedef unsigned long        DWORD;

  23. /* This type MUST be 64-bit (Remove this for C89 compatibility) */
  24. typedef unsigned long long QWORD;

  25. #endif

  26. #endif


wahahaheihei 发表于 2016-4-19 20:38 | 显示全部楼层
ff12.zip (1.59 MB, 下载次数: 23)

还是全部打包给你吧。
 楼主| weizhiwuxian 发表于 2016-4-19 21:04 | 显示全部楼层
wahahaheihei 发表于 2016-4-19 20:38
还是全部打包给你吧。

谢谢!明天测试下.
wahahaheihei 发表于 2016-4-22 23:32 | 显示全部楼层

我从小日本那里找的,应该是没问题的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

6

主题

14

帖子

2

粉丝
快速回复 在线客服 返回列表 返回顶部