从官网下载到最新的文件系统FatFS版本 Sep 06,’11 R0.09
需要修改的文件是 ffconf.h 和 diskio.c(新版本不提供该文件,连模板都没有提供,完全需要自己编写)。 ffconf.h是文件系统配置文件,主要是配置文件系统的各种功能。 diskio.c是底层驱动,从diskio.h中知道diskio.c应该包含如下函数:
1 2 3 4 5 6 7 8 | int assign_drives (int, int); DSTATUS disk_initialize (BYTE); DSTATUS disk_status (BYTE); DRESULT disk_read (BYTE, BYTE*, DWORD, BYTE); #if _READONLY == 0 DRESULT disk_write (BYTE, const BYTE*, DWORD, BYTE); #endif DRESULT disk_ioctl (BYTE, BYTE, void*); |
ffconf.h文件中我修改了如下几个地方:
1 2 | #define _USE_STRFUNC 1 /* 0:Disable or 1-2:Enable */ /* To enable string functions, set _USE_STRFUNC to 1 or 2. */ |
1 2 3 | #define _CODE_PAGE 850 /* The _CODE_PAGE specifies the OEM code page to be used on the target system. / Incorrect setting of the code page can cause a file open failure. |
1 2 3 | #define _USE_LFN 1 /* 0 to 3 */ #define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */ /* The _USE_LFN option switches the LFN support. |
遇到过的问题:
1._CODE_PAGE 配置错误导致文件打开失败。根据文件里的注释,中文应该选择_CODE_PAGE=936,同时应该添加cc936.c文件。我的应用中只需要支持英文长文件名就可以了。所以使用 850 就可以,同时添加ccsbcs.c文件。
1 | 2.长文件名支持:第93行,#define _USE_LFN 1,支持长文件名。 |
不错,过来看看,欢迎回访