Skip to content

Commit bfd8343

Browse files
committed
Add SD support for F7
Signed-off-by: Frederic.Pillon <[email protected]>
1 parent 3034262 commit bfd8343

File tree

2 files changed

+298
-0
lines changed

2 files changed

+298
-0
lines changed

variants/DISCO_F746NG/ffconf.h

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

variants/DISCO_F746NG/sd_conf.h

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
******************************************************************************
3+
* @file sd_conf.h
4+
* @author fpiSTM
5+
* @date 2017
6+
* @brief This file contains hw config for SD
7+
*******************************************************************************
8+
*/
9+
10+
/* Define to prevent recursive inclusion -------------------------------------*/
11+
#ifndef __SD_CONF_H
12+
#define __SD_CONF_H
13+
14+
#ifdef __cplusplus
15+
extern "C" {
16+
#endif
17+
18+
/* Includes ------------------------------------------------------------------*/
19+
#include "stm32_def.h"
20+
21+
#define SD_DATATIMEOUT ((uint32_t)100000000)
22+
23+
/*SD-detect signal */
24+
#define SD_DETECT_PIN GPIO_PIN_13
25+
#define SD_DETECT_GPIO_PORT GPIOC
26+
#define SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
27+
#define SD_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE()
28+
#define SD_DETECT_EXTI_IRQn EXTI15_10_IRQn
29+
30+
/* Definition for BSP SD */
31+
#define SD_INSTANCE SDMMC1
32+
33+
#define SD_CLK_ENABLE __HAL_RCC_SDMMC1_CLK_ENABLE
34+
#define SD_CLK_DISABLE __HAL_RCC_SDMMC1_CLK_DISABLE
35+
#define SD_CLK_EDGE SDMMC_CLOCK_EDGE_RISING
36+
#define SD_CLK_BYPASS SDMMC_CLOCK_BYPASS_DISABLE
37+
#define SD_CLK_PWR_SAVE SDMMC_CLOCK_POWER_SAVE_DISABLE
38+
#define SD_BUS_WIDE_1B SDMMC_BUS_WIDE_1B
39+
#define SD_BUS_WIDE_4B SDMMC_BUS_WIDE_4B
40+
#define SD_HW_FLOW_CTRL SDMMC_HARDWARE_FLOW_CONTROL_DISABLE
41+
#define SD_CLK_DIV SDMMC_TRANSFER_CLK_DIV
42+
43+
/* Definition for MSP SD */
44+
#define SD_AF GPIO_AF12_SDMMC1
45+
46+
47+
#ifdef __cplusplus
48+
}
49+
#endif
50+
51+
#endif /* __SD_CONF_H */

0 commit comments

Comments
 (0)