Skip to content

Commit bf4d1d3

Browse files
committed
Allow use of custom FatFs options file (ffconf_custom.h)
Add a file named "ffconf_custom.h" in the sketch folder will be used instead of the default config (ffconf_default.h). Signed-off-by: Frederic Pillon <[email protected]>
1 parent 9a603c7 commit bf4d1d3

File tree

2 files changed

+259
-0
lines changed

2 files changed

+259
-0
lines changed

src/ffconf.h

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* @file ffconf.h
3+
* @brief Include header file to match Arduino library format
4+
*/
5+
#ifndef _ARDUINO_FFCONF_H
6+
#define _ARDUINO_FFCONF_H
7+
8+
#include "stm32_def.h"
9+
#include "bsp_sd.h"
10+
11+
/* FatFs specific configuration options. */
12+
#if __has_include("ffconf_custom.h")
13+
#include "ffconf_custom.h"
14+
#else
15+
#include "ffconf_default.h"
16+
#endif
17+
#endif /* _ARDUINO_FFCONF_H */

src/ffconf_default.h

+242
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
/*---------------------------------------------------------------------------/
2+
/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015
3+
/----------------------------------------------------------------------------/
4+
/
5+
/ CAUTION! Do not forget to make clean the project after any changes to
6+
/ the configuration options.
7+
/
8+
/----------------------------------------------------------------------------*/
9+
#ifndef _FFCONF
10+
#define _FFCONF 32020 /* Revision ID */
11+
12+
/*-----------------------------------------------------------------------------/
13+
/ Functions and Buffer Configurations
14+
/-----------------------------------------------------------------------------*/
15+
16+
#define _FS_TINY 0 /* 0:Normal or 1:Tiny */
17+
/* When _FS_TINY is set to 1, FatFs uses the sector buffer in the file system
18+
/ object instead of the sector buffer in the individual file object for file
19+
/ data transfer. This reduces memory consumption 512 bytes each file object. */
20+
21+
22+
#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */
23+
/* Setting _FS_READONLY to 1 defines read only configuration. This removes
24+
/ writing functions, f_write, f_sync, f_unlink, f_mkdir, f_chmod, f_rename,
25+
/ f_truncate and useless f_getfree. */
26+
27+
28+
#define _FS_MINIMIZE 0 /* 0 to 3 */
29+
/* The _FS_MINIMIZE option defines minimization level to remove some functions.
30+
/
31+
/ 0: Full function.
32+
/ 1: f_stat, f_getfree, f_unlink, f_mkdir, f_chmod, f_truncate, f_utime
33+
/ and f_rename are removed.
34+
/ 2: f_opendir and f_readdir are removed in addition to 1.
35+
/ 3: f_lseek is removed in addition to 2. */
36+
37+
38+
#define _USE_STRFUNC 2 /* 0:Disable or 1-2:Enable */
39+
/* To enable string functions, set _USE_STRFUNC to 1 or 2. */
40+
41+
42+
#define _USE_MKFS 1 /* 0:Disable or 1:Enable */
43+
/* To enable f_mkfs function, set _USE_MKFS to 1 and set _FS_READONLY to 0 */
44+
45+
46+
#define _USE_FASTSEEK 1 /* 0:Disable or 1:Enable */
47+
/* To enable fast seek feature, set _USE_FASTSEEK to 1. */
48+
49+
50+
#define _USE_LABEL 0 /* 0:Disable or 1:Enable */
51+
/* To enable volume label functions, set _USE_LAVEL to 1 */
52+
53+
54+
#define _USE_FORWARD 0 /* 0:Disable or 1:Enable */
55+
/* To enable f_forward function, set _USE_FORWARD to 1 and set _FS_TINY to 1. */
56+
57+
#define _USE_FIND 0
58+
/* This option switches filtered directory read feature and related functions,
59+
/� f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
60+
61+
62+
/* This option is available only for usbh diskio interface and allow to disable
63+
/ the management of the unaligned buffer.
64+
/ When STM32 USB OTG HS or FS IP is used with internal DMA enabled, this define
65+
/ must be set to 0 to align data into 32bits through an internal scratch buffer
66+
/ before being processed by the DMA . Otherwise (DMA not used), this define must
67+
/ be set to 1 to avoid Data alignment and improve the performance.
68+
/ Please note that if _USE_BUFF_WO_ALIGNMENT is set to 1 and an unaligned 32bits
69+
/ buffer is forwarded to the FatFs Write/Read functions, an error will be returned.
70+
/ (0: default value or 1: unaligned buffer return an error). */
71+
72+
73+
/*-----------------------------------------------------------------------------/
74+
/ Local and Namespace Configurations
75+
/-----------------------------------------------------------------------------*/
76+
77+
#define _CODE_PAGE 1252
78+
/* The _CODE_PAGE specifies the OEM code page to be used on the target system.
79+
/ Incorrect setting of the code page can cause a file open failure.
80+
/
81+
/ 932 - Japanese Shift-JIS (DBCS, OEM, Windows)
82+
/ 936 - Simplified Chinese GBK (DBCS, OEM, Windows)
83+
/ 949 - Korean (DBCS, OEM, Windows)
84+
/ 950 - Traditional Chinese Big5 (DBCS, OEM, Windows)
85+
/ 1250 - Central Europe (Windows)
86+
/ 1251 - Cyrillic (Windows)
87+
/ 1252 - Latin 1 (Windows)
88+
/ 1253 - Greek (Windows)
89+
/ 1254 - Turkish (Windows)
90+
/ 1255 - Hebrew (Windows)
91+
/ 1256 - Arabic (Windows)
92+
/ 1257 - Baltic (Windows)
93+
/ 1258 - Vietnam (OEM, Windows)
94+
/ 437 - U.S. (OEM)
95+
/ 720 - Arabic (OEM)
96+
/ 737 - Greek (OEM)
97+
/ 775 - Baltic (OEM)
98+
/ 850 - Multilingual Latin 1 (OEM)
99+
/ 858 - Multilingual Latin 1 + Euro (OEM)
100+
/ 852 - Latin 2 (OEM)
101+
/ 855 - Cyrillic (OEM)
102+
/ 866 - Russian (OEM)
103+
/ 857 - Turkish (OEM)
104+
/ 862 - Hebrew (OEM)
105+
/ 874 - Thai (OEM, Windows)
106+
/ 1 - ASCII only (Valid for non LFN cfg.)
107+
*/
108+
109+
110+
#define _USE_LFN 1 /* 0 to 3 */
111+
#define _MAX_LFN 255 /* Maximum LFN length to handle (12 to 255) */
112+
/* The _USE_LFN option switches the LFN feature.
113+
/
114+
/ 0: Disable LFN feature. _MAX_LFN has no effect.
115+
/ 1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
116+
/ 2: Enable LFN with dynamic working buffer on the STACK.
117+
/ 3: Enable LFN with dynamic working buffer on the HEAP.
118+
/
119+
/ To enable LFN feature, Unicode handling functions ff_convert() and ff_wtoupper()
120+
/ function must be added to the project.
121+
/ The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes. When use stack for the
122+
/ working buffer, take care on stack overflow. When use heap memory for the working
123+
/ buffer, memory management functions, ff_memalloc() and ff_memfree(), must be added
124+
/ to the project. */
125+
126+
127+
#define _LFN_UNICODE 0 /* 0:ANSI/OEM or 1:Unicode */
128+
/* To switch the character encoding on the FatFs API to Unicode, enable LFN feature
129+
/ and set _LFN_UNICODE to 1. */
130+
131+
132+
#define _STRF_ENCODE 3 /* 0:ANSI/OEM, 1:UTF-16LE, 2:UTF-16BE, 3:UTF-8 */
133+
/* When Unicode API is enabled, character encoding on the all FatFs API is switched
134+
/ to Unicode. This option selects the character encoding on the file to be read/written
135+
/ via string functions, f_gets(), f_putc(), f_puts and f_printf().
136+
/ This option has no effect when _LFN_UNICODE is 0. */
137+
138+
139+
#define _FS_RPATH 0/* 0 to 2 */
140+
/* The _FS_RPATH option configures relative path feature.
141+
/
142+
/ 0: Disable relative path feature and remove related functions.
143+
/ 1: Enable relative path. f_chdrive() and f_chdir() function are available.
144+
/ 2: f_getcwd() function is available in addition to 1.
145+
/
146+
/ Note that output of the f_readdir() fnction is affected by this option. */
147+
148+
149+
/*---------------------------------------------------------------------------/
150+
/ Drive/Volume Configurations
151+
/----------------------------------------------------------------------------*/
152+
153+
#define _VOLUMES 1
154+
/* Number of volumes (logical drives) to be used. */
155+
156+
157+
#define _MULTI_PARTITION 0 /* 0:Single partition, 1:Enable multiple partition */
158+
/* When set to 0, each volume is bound to the same physical drive number and
159+
/ it can mount only first primaly partition. When it is set to 1, each volume
160+
/ is tied to the partitions listed in VolToPart[]. */
161+
162+
163+
#define _MIN_SS 512
164+
#define _MAX_SS 512
165+
/* These options configure the range of sector size to be supported. (512, 1024, 2048 or
166+
/ 4096) Always set both 512 for most systems, all memory card and harddisk. But a larger
167+
/ value may be required for on-board flash memory and some type of optical media.
168+
/ When _MAX_SS is larger than _MIN_SS, FatFs is configured to variable sector size and
169+
/ GET_SECTOR_SIZE command must be implemented to the disk_ioctl() function. */
170+
171+
172+
#define _USE_TRIM 0 /* 0:Disable or 1:Enable */
173+
/* To enable sector erase feature, set _USE_TRIM to 1. Also CTRL_ERASE_SECTOR command
174+
/ should be added to the disk_ioctl() function. */
175+
176+
177+
#define _FS_NOFSINFO 0 /* 0 or 1 */
178+
/* If you need to know the correct free space on the FAT32 volume, set this
179+
/ option to 1 and f_getfree() function at first time after volume mount will
180+
/ force a full FAT scan.
181+
/
182+
/ 0: Load all informations in the FSINFO if available.
183+
/ 1: Do not trust free cluster count in the FSINFO.
184+
*/
185+
186+
187+
/*---------------------------------------------------------------------------/
188+
/ System Configurations
189+
/----------------------------------------------------------------------------*/
190+
191+
#define _WORD_ACCESS 0 /* 0 or 1 */
192+
/* The _WORD_ACCESS option is an only platform dependent option. It defines
193+
/ which access method is used to the word data on the FAT volume.
194+
/
195+
/ 0: Byte-by-byte access. Always compatible with all platforms.
196+
/ 1: Word access. Do not choose this unless under both the following conditions.
197+
/
198+
/ * Byte order on the memory is little-endian.
199+
/ * Address miss-aligned word access is always allowed for all instructions.
200+
/
201+
/ If it is the case, _WORD_ACCESS can also be set to 1 to improve performance
202+
/ and reduce code size.
203+
*/
204+
205+
206+
/* A header file that defines sync object types on the O/S, such as
207+
/ windows.h, ucos_ii.h and semphr.h, must be included prior to ff.h. */
208+
209+
#define _FS_REENTRANT 0 /* 0:Disable or 1:Enable */
210+
#define _FS_TIMEOUT 1000 /* Timeout period in unit of time ticks */
211+
#define _SYNC_t 0 /* O/S dependent type of sync object. e.g. HANDLE, OS_EVENT*, ID and etc.. */
212+
213+
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs module.
214+
/
215+
/ 0: Disable re-entrancy. _SYNC_t and _FS_TIMEOUT have no effect.
216+
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
217+
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
218+
/ function must be added to the project. */
219+
220+
221+
#define _FS_LOCK 0 /* 0:Disable or >=1:Enable */
222+
/* To enable file lock control feature, set _FS_LOCK to 1 or greater.
223+
The value defines how many files can be opened simultaneously. */
224+
225+
#define _FS_NORTC 0
226+
#define _NORTC_MON 2
227+
#define _NORTC_MDAY 1
228+
#define _NORTC_YEAR 2015
229+
/* The _FS_NORTC option switches timestamp feature. If the system does not have
230+
/� an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
231+
/� the timestamp feature. All objects modified by FatFs will have a fixed timestamp
232+
/� defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
233+
/� When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
234+
/� to be added to the project to read current time form RTC. _NORTC_MON,
235+
/� _NORTC_MDAY and _NORTC_YEAR have no effect.
236+
/� These options have no effect at read-only configuration (_FS_READONLY == 1). */
237+
238+
#if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31
239+
#error Invalid _FS_NORTC settings
240+
#endif
241+
242+
#endif /* _FFCONFIG */

0 commit comments

Comments
 (0)