Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32f1xx_ll_fsmc.c |
3 | * @file stm32f1xx_ll_fsmc.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @version V1.0.1 |
5 | * @version V1.0.4 |
6 | * @date 31-July-2015 |
6 | * @date 29-April-2016 |
7 | * @brief FSMC Low Layer HAL module driver. |
7 | * @brief FSMC Low Layer HAL module driver. |
8 | * |
8 | * |
9 | * This file provides firmware functions to manage the following |
9 | * This file provides firmware functions to manage the following |
10 | * functionalities of the Flexible Static Memory Controller (FSMC) peripheral memories: |
10 | * functionalities of the Flexible Static Memory Controller (FSMC) peripheral memories: |
11 | * + Initialization/de-initialization functions |
11 | * + Initialization/de-initialization functions |
12 | * + Peripheral Control functions |
12 | * + Peripheral Control functions |
13 | * + Peripheral State functions |
13 | * + Peripheral State functions |
14 | * |
14 | * |
15 | @verbatim |
15 | @verbatim |
16 | ============================================================================= |
16 | ============================================================================= |
17 | ##### FSMC peripheral features ##### |
17 | ##### FSMC peripheral features ##### |
18 | ============================================================================= |
18 | ============================================================================= |
19 | [..] The Flexible static memory controller (FSMC) includes following memory controllers: |
19 | [..] The Flexible static memory controller (FSMC) includes following memory controllers: |
20 | (+) The NOR/PSRAM memory controller |
20 | (+) The NOR/PSRAM memory controller |
21 | (+) The NAND/PC Card memory controller (except STM32F100xE devices) |
21 | (+) The PC Card memory controller |
- | 22 | (+) The NAND memory controller |
|
- | 23 | (PC Card and NAND controllers available only on STM32F101xE, STM32F103xE, STM32F101xG and STM32F103xG) |
|
22 | |
24 | |
23 | [..] The FSMC functional block makes the interface with synchronous and asynchronous static |
25 | [..] The FSMC functional block makes the interface with synchronous and asynchronous static |
24 | memories and 16-bit PC memory cards. Its main purposes are: |
26 | memories and 16-bit PC memory cards. Its main purposes are: |
25 | (+) to translate AHB transactions into the appropriate external device protocol. |
27 | (+) to translate AHB transactions into the appropriate external device protocol. |
26 | (+) to meet the access time requirements of the external memory devices. |
28 | (+) to meet the access time requirements of the external memory devices. |
27 | |
29 | |
28 | [..] All external memories share the addresses, data and control signals with the controller. |
30 | [..] All external memories share the addresses, data and control signals with the controller. |
29 | Each external device is accessed by means of a unique Chip Select. The FSMC performs |
31 | Each external device is accessed by means of a unique Chip Select. The FSMC performs |
30 | only one access at a time to an external device. |
32 | only one access at a time to an external device. |
31 | The main features of the FSMC controller are the following: |
33 | The main features of the FSMC controller are the following: |
32 | (+) Interface with static-memory mapped devices including: |
34 | (+) Interface with static-memory mapped devices including: |
Line 36... | Line 38... | ||
36 | (++) 16-bit PC Card compatible devices |
38 | (++) 16-bit PC Card compatible devices |
37 | (++) Two banks of NAND Flash memory with ECC hardware to check up to 8 Kbytes of |
39 | (++) Two banks of NAND Flash memory with ECC hardware to check up to 8 Kbytes of |
38 | data |
40 | data |
39 | (+) Independent Chip Select control for each memory bank |
41 | (+) Independent Chip Select control for each memory bank |
40 | (+) Independent configuration for each memory bank |
42 | (+) Independent configuration for each memory bank |
41 | |
43 | |
42 | @endverbatim |
44 | @endverbatim |
43 | ****************************************************************************** |
45 | ****************************************************************************** |
44 | * @attention |
46 | * @attention |
45 | * |
47 | * |
46 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
48 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
47 | * |
49 | * |
48 | * Redistribution and use in source and binary forms, with or without modification, |
50 | * Redistribution and use in source and binary forms, with or without modification, |
49 | * are permitted provided that the following conditions are met: |
51 | * are permitted provided that the following conditions are met: |
50 | * 1. Redistributions of source code must retain the above copyright notice, |
52 | * 1. Redistributions of source code must retain the above copyright notice, |
51 | * this list of conditions and the following disclaimer. |
53 | * this list of conditions and the following disclaimer. |
Line 66... | Line 68... | ||
66 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
68 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
67 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
69 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
68 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
70 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
69 | * |
71 | * |
70 | ****************************************************************************** |
72 | ****************************************************************************** |
71 | */ |
73 | */ |
72 | 74 | ||
73 | /* Includes ------------------------------------------------------------------*/ |
75 | /* Includes ------------------------------------------------------------------*/ |
74 | #include "stm32f1xx_hal.h" |
76 | #include "stm32f1xx_hal.h" |
75 | 77 | ||
76 | /** @addtogroup STM32F1xx_HAL_Driver |
78 | /** @addtogroup STM32F1xx_HAL_Driver |
77 | * @{ |
79 | * @{ |
78 | */ |
80 | */ |
79 | 81 | ||
80 | #if defined (HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) |
82 | #if defined(HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) |
81 | 83 | ||
82 | #if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) || defined(STM32F100xE) |
84 | #if defined(FSMC_BANK1) |
83 | 85 | ||
84 | /** @defgroup FSMC_LL FSMC_LL |
86 | /** @defgroup FSMC_LL FSMC Low Layer |
85 | * @brief FSMC driver modules |
87 | * @brief FSMC driver modules |
86 | * @{ |
88 | * @{ |
87 | */ |
89 | */ |
88 | 90 | ||
89 | /* Private typedef -----------------------------------------------------------*/ |
91 | /* Private typedef -----------------------------------------------------------*/ |
90 | /* Private define ------------------------------------------------------------*/ |
92 | /* Private define ------------------------------------------------------------*/ |
91 | /** @defgroup FSMC_LL_Private_Constants FSMC Low Layer Private Constants |
93 | /** @defgroup FSMC_LL_Private_Constants FSMC Low Layer Private Constants |
92 | * @{ |
94 | * @{ |
93 | */ |
95 | */ |
94 | 96 | ||
95 | /* ----------------------- FMC registers bit mask --------------------------- */ |
97 | /* ----------------------- FSMC registers bit mask --------------------------- */ |
96 | /* --- PCR Register ---*/ |
98 | /* --- PCR Register ---*/ |
97 | /* PCR register clear mask */ |
99 | /* PCR register clear mask */ |
98 | #define PCR_CLEAR_MASK ((uint32_t)(FSMC_PCRx_PWAITEN | FSMC_PCRx_PTYP | FSMC_PCRx_PWID | \ |
100 | #define PCR_CLEAR_MASK ((uint32_t)(FSMC_PCRx_PWAITEN | FSMC_PCRx_PBKEN | \ |
- | 101 | FSMC_PCRx_PTYP | FSMC_PCRx_PWID | \ |
|
99 | FSMC_PCRx_ECCEN | FSMC_PCRx_TCLR | \ |
102 | FSMC_PCRx_ECCEN | FSMC_PCRx_TCLR | \ |
100 | FSMC_PCRx_TAR | FSMC_PCRx_ECCPS)) |
103 | FSMC_PCRx_TAR | FSMC_PCRx_ECCPS)) |
101 | 104 | ||
102 | /* --- SR Register ---*/ |
105 | /* --- SR Register ---*/ |
103 | /* SR register clear mask */ |
106 | /* SR register clear mask */ |
104 | #define SR_CLEAR_MASK ((uint32_t)(FSMC_SRx_IRS | FSMC_SRx_ILS | FSMC_SRx_IFS | \ |
107 | #define SR_CLEAR_MASK ((uint32_t)(FSMC_SRx_IRS | FSMC_SRx_ILS | FSMC_SRx_IFS | \ |
105 | FSMC_SRx_IREN | FSMC_SRx_ILEN | FSMC_SRx_IFEN)) |
108 | FSMC_SRx_IREN | FSMC_SRx_ILEN | FSMC_SRx_IFEN)) |
106 | 109 | ||
107 | /* --- PMEM Register ---*/ |
110 | /* --- PMEM Register ---*/ |
108 | /* PMEM register clear mask */ |
111 | /* PMEM register clear mask */ |
109 | #define PMEM_CLEAR_MASK ((uint32_t)(FSMC_PMEMx_MEMSETx | FSMC_PMEMx_MEMWAITx |\ |
112 | #define PMEM_CLEAR_MASK ((uint32_t)(FSMC_PMEMx_MEMSETx | FSMC_PMEMx_MEMWAITx |\ |
110 | FSMC_PMEMx_MEMHOLDx | FSMC_PMEMx_MEMHIZx)) |
113 | FSMC_PMEMx_MEMHOLDx | FSMC_PMEMx_MEMHIZx)) |
111 | 114 | ||
112 | /* --- PATT Register ---*/ |
115 | /* --- PATT Register ---*/ |
113 | /* PATT register clear mask */ |
116 | /* PATT register clear mask */ |
114 | #define PATT_CLEAR_MASK ((uint32_t)(FSMC_PATTx_ATTSETx | FSMC_PATTx_ATTWAITx |\ |
117 | #define PATT_CLEAR_MASK ((uint32_t)(FSMC_PATTx_ATTSETx | FSMC_PATTx_ATTWAITx |\ |
115 | FSMC_PATTx_ATTHOLDx | FSMC_PATTx_ATTHIZx)) |
118 | FSMC_PATTx_ATTHOLDx | FSMC_PATTx_ATTHIZx)) |
116 | 119 | ||
- | 120 | /* --- BCR Register ---*/ |
|
- | 121 | /* BCR register clear mask */ |
|
- | 122 | #define BCR_CLEAR_MASK ((uint32_t)(FSMC_BCRx_FACCEN | FSMC_BCRx_MUXEN | \ |
|
- | 123 | FSMC_BCRx_MTYP | FSMC_BCRx_MWID | \ |
|
- | 124 | FSMC_BCRx_BURSTEN | FSMC_BCRx_WAITPOL | \ |
|
- | 125 | FSMC_BCRx_WRAPMOD | FSMC_BCRx_WAITCFG | \ |
|
- | 126 | FSMC_BCRx_WREN | FSMC_BCRx_WAITEN | \ |
|
- | 127 | FSMC_BCRx_EXTMOD | FSMC_BCRx_ASYNCWAIT | \ |
|
- | 128 | FSMC_BCRx_CBURSTRW)) |
|
- | 129 | /* --- BTR Register ---*/ |
|
- | 130 | /* BTR register clear mask */ |
|
- | 131 | #define BTR_CLEAR_MASK ((uint32_t)(FSMC_BTRx_ADDSET | FSMC_BTRx_ADDHLD |\ |
|
- | 132 | FSMC_BTRx_DATAST | FSMC_BTRx_BUSTURN |\ |
|
- | 133 | FSMC_BTRx_CLKDIV | FSMC_BTRx_DATLAT |\ |
|
- | 134 | FSMC_BTRx_ACCMOD)) |
|
- | 135 | ||
- | 136 | /* --- BWTR Register ---*/ |
|
- | 137 | /* BWTR register clear mask */ |
|
- | 138 | #if (defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)) |
|
- | 139 | #define BWTR_CLEAR_MASK ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD | \ |
|
- | 140 | FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD | \ |
|
- | 141 | FSMC_BWTRx_BUSTURN)) |
|
- | 142 | #else |
|
- | 143 | #define BWTR_CLEAR_MASK ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD | \ |
|
- | 144 | FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD | \ |
|
- | 145 | FSMC_BWTRx_CLKDIV | FSMC_BWTRx_DATLAT)) |
|
- | 146 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
|
- | 147 | ||
117 | /* --- PIO4 Register ---*/ |
148 | /* --- PIO4 Register ---*/ |
118 | /* PIO4 register clear mask */ |
149 | /* PIO4 register clear mask */ |
119 | #define PIO4_CLEAR_MASK ((uint32_t)(FSMC_PIO4_IOSET4 | FSMC_PIO4_IOWAIT4 | \ |
150 | #define PIO4_CLEAR_MASK ((uint32_t)(FSMC_PIO4_IOSET4 | FSMC_PIO4_IOWAIT4 | \ |
120 | FSMC_PIO4_IOHOLD4 | FSMC_PIO4_IOHIZ4)) |
151 | FSMC_PIO4_IOHOLD4 | FSMC_PIO4_IOHIZ4)) |
121 | /** |
152 | /** |
122 | * @} |
153 | * @} |
123 | */ |
154 | */ |
124 | 155 | ||
125 | /* Private macro -------------------------------------------------------------*/ |
156 | /* Private macro -------------------------------------------------------------*/ |
126 | /** @defgroup FSMC_LL_Private_Macros FSMC Low Layer Private Macros |
157 | /** @defgroup FSMC_LL_Private_Macros FSMC Low Layer Private Macros |
127 | * @{ |
158 | * @{ |
128 | */ |
159 | */ |
129 | 160 | ||
130 | /** |
161 | /** |
Line 138... | Line 169... | ||
138 | /** @defgroup FSMC_LL_Exported_Functions FSMC Low Layer Exported Functions |
169 | /** @defgroup FSMC_LL_Exported_Functions FSMC Low Layer Exported Functions |
139 | * @{ |
170 | * @{ |
140 | */ |
171 | */ |
141 | 172 | ||
142 | /** @defgroup FSMC_NORSRAM FSMC NORSRAM Controller functions |
173 | /** @defgroup FSMC_NORSRAM FSMC NORSRAM Controller functions |
143 | * @brief NORSRAM Controller functions |
174 | * @brief NORSRAM Controller functions |
144 | * |
175 | * |
145 | @verbatim |
176 | @verbatim |
146 | ============================================================================== |
177 | ============================================================================== |
147 | ##### How to use NORSRAM device driver ##### |
178 | ##### How to use NORSRAM device driver ##### |
148 | ============================================================================== |
179 | ============================================================================== |
149 | |
180 | |
150 | [..] |
181 | [..] |
151 | This driver contains a set of APIs to interface with the FSMC NORSRAM banks in order |
182 | This driver contains a set of APIs to interface with the FSMC NORSRAM banks in order |
152 | to run the NORSRAM external devices. |
183 | to run the NORSRAM external devices. |
153 | |
184 | |
154 | (+) FSMC NORSRAM bank reset using the function FSMC_NORSRAM_DeInit() |
185 | (+) FSMC NORSRAM bank reset using the function FSMC_NORSRAM_DeInit() |
155 | (+) FSMC NORSRAM bank control configuration using the function FSMC_NORSRAM_Init() |
186 | (+) FSMC NORSRAM bank control configuration using the function FSMC_NORSRAM_Init() |
156 | (+) FSMC NORSRAM bank timing configuration using the function FSMC_NORSRAM_Timing_Init() |
187 | (+) FSMC NORSRAM bank timing configuration using the function FSMC_NORSRAM_Timing_Init() |
157 | (+) FSMC NORSRAM bank extended timing configuration using the function |
188 | (+) FSMC NORSRAM bank extended timing configuration using the function |
158 | FSMC_NORSRAM_Extended_Timing_Init() |
189 | FSMC_NORSRAM_Extended_Timing_Init() |
159 | (+) FSMC NORSRAM bank enable/disable write operation using the functions |
190 | (+) FSMC NORSRAM bank enable/disable write operation using the functions |
160 | FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable() |
191 | FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable() |
161 | |
192 | |
162 | 193 | ||
163 | @endverbatim |
194 | @endverbatim |
164 | * @{ |
195 | * @{ |
165 | */ |
196 | */ |
166 | 197 | ||
167 | /** @defgroup FSMC_NORSRAM_Group1 Initialization/de-initialization functions |
198 | /** @defgroup FSMC_NORSRAM_Group1 Initialization/de-initialization functions |
168 | * @brief Initialization and Configuration functions |
199 | * @brief Initialization and Configuration functions |
169 | * |
200 | * |
170 | @verbatim |
201 | @verbatim |
171 | ============================================================================== |
202 | ============================================================================== |
172 | ##### Initialization and de_initialization functions ##### |
203 | ##### Initialization and de_initialization functions ##### |
173 | ============================================================================== |
204 | ============================================================================== |
174 | [..] |
205 | [..] |
175 | This section provides functions allowing to: |
206 | This section provides functions allowing to: |
176 | (+) Initialize and configure the FSMC NORSRAM interface |
207 | (+) Initialize and configure the FSMC NORSRAM interface |
177 | (+) De-initialize the FSMC NORSRAM interface |
208 | (+) De-initialize the FSMC NORSRAM interface |
178 | (+) Configure the FSMC clock and associated GPIOs |
209 | (+) Configure the FSMC clock and associated GPIOs |
179 | |
210 | |
180 | @endverbatim |
211 | @endverbatim |
181 | * @{ |
212 | * @{ |
182 | */ |
213 | */ |
183 | 214 | ||
184 | /** |
215 | /** |
185 | * @brief Initialize the FSMC_NORSRAM device according to the specified |
216 | * @brief Initialize the FSMC_NORSRAM device according to the specified |
186 | * control parameters in the FSMC_NORSRAM_InitTypeDef |
217 | * control parameters in the FSMC_NORSRAM_InitTypeDef |
187 | * @param Device: Pointer to NORSRAM device instance |
218 | * @param Device: Pointer to NORSRAM device instance |
188 | * @param Init: Pointer to NORSRAM Initialization structure |
219 | * @param Init: Pointer to NORSRAM Initialization structure |
189 | * @retval HAL status |
220 | * @retval HAL status |
190 | */ |
221 | */ |
191 | HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef* Init) |
222 | HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef *Init) |
192 | { |
223 | { |
193 | /* Check the parameters */ |
224 | /* Check the parameters */ |
194 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
225 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
195 | assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank)); |
226 | assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank)); |
196 | assert_param(IS_FSMC_MUX(Init->DataAddressMux)); |
227 | assert_param(IS_FSMC_MUX(Init->DataAddressMux)); |
197 | assert_param(IS_FSMC_MEMORY(Init->MemoryType)); |
228 | assert_param(IS_FSMC_MEMORY(Init->MemoryType)); |
Line 203... | Line 234... | ||
203 | assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation)); |
234 | assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation)); |
204 | assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal)); |
235 | assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal)); |
205 | assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode)); |
236 | assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode)); |
206 | assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait)); |
237 | assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait)); |
207 | assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst)); |
238 | assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst)); |
208 | 239 | ||
209 | /* Disable NORSRAM Device */ |
240 | /* Disable NORSRAM Device */ |
210 | __FSMC_NORSRAM_DISABLE(Device, Init->NSBank); |
241 | __FSMC_NORSRAM_DISABLE(Device, Init->NSBank); |
211 | 242 | ||
212 | /* Set NORSRAM device control parameters */ |
243 | /* Set NORSRAM device control parameters */ |
213 | if(Init->MemoryType == FSMC_MEMORY_TYPE_NOR) |
244 | if (Init->MemoryType == FSMC_MEMORY_TYPE_NOR) |
214 | { |
245 | { |
215 | MODIFY_REG(Device->BTCR[Init->NSBank], \ |
246 | MODIFY_REG(Device->BTCR[Init->NSBank], BCR_CLEAR_MASK, (uint32_t)(FSMC_NORSRAM_FLASH_ACCESS_ENABLE |
216 | (FSMC_BCRx_FACCEN | FSMC_BCRx_MUXEN | FSMC_BCRx_MTYP | \ |
247 | | Init->DataAddressMux |
- | 248 | | Init->MemoryType |
|
217 | FSMC_BCRx_MWID | FSMC_BCRx_BURSTEN | FSMC_BCRx_WAITPOL | FSMC_BCRx_WRAPMOD | FSMC_BCRx_WAITCFG | \ |
249 | | Init->MemoryDataWidth |
218 | FSMC_BCRx_WREN | FSMC_BCRx_WAITEN | FSMC_BCRx_EXTMOD | FSMC_BCRx_ASYNCWAIT | FSMC_BCRx_CBURSTRW), \ |
250 | | Init->BurstAccessMode |
219 | (FSMC_NORSRAM_FLASH_ACCESS_ENABLE | Init->DataAddressMux | Init->MemoryType | \ |
251 | | Init->WaitSignalPolarity |
- | 252 | | Init->WrapMode |
|
220 | Init->MemoryDataWidth | Init->BurstAccessMode | Init->WaitSignalPolarity | Init->WrapMode | Init->WaitSignalActive |\ |
253 | | Init->WaitSignalActive |
- | 254 | | Init->WriteOperation |
|
- | 255 | | Init->WaitSignal |
|
- | 256 | | Init->ExtendedMode |
|
- | 257 | | Init->AsynchronousWait |
|
- | 258 | | Init->WriteBurst |
|
221 | Init->WriteOperation | Init->WaitSignal | Init->ExtendedMode | Init->AsynchronousWait | Init->WriteBurst ) \ |
259 | ) |
222 | ); |
260 | ); |
223 | } |
261 | } |
224 | else |
262 | else |
225 | { |
263 | { |
226 | MODIFY_REG(Device->BTCR[Init->NSBank], \ |
264 | MODIFY_REG(Device->BTCR[Init->NSBank], BCR_CLEAR_MASK, (uint32_t)(FSMC_NORSRAM_FLASH_ACCESS_DISABLE |
227 | (FSMC_BCRx_FACCEN | FSMC_BCRx_MUXEN | FSMC_BCRx_MTYP | \ |
265 | | Init->DataAddressMux |
- | 266 | | Init->MemoryType |
|
228 | FSMC_BCRx_MWID | FSMC_BCRx_BURSTEN | FSMC_BCRx_WAITPOL | FSMC_BCRx_WRAPMOD | FSMC_BCRx_WAITCFG | \ |
267 | | Init->MemoryDataWidth |
229 | FSMC_BCRx_WREN | FSMC_BCRx_WAITEN | FSMC_BCRx_EXTMOD | FSMC_BCRx_ASYNCWAIT | FSMC_BCRx_CBURSTRW), \ |
268 | | Init->BurstAccessMode |
230 | (FSMC_NORSRAM_FLASH_ACCESS_DISABLE | Init->DataAddressMux | Init->MemoryType | \ |
269 | | Init->WaitSignalPolarity |
- | 270 | | Init->WrapMode |
|
231 | Init->MemoryDataWidth | Init->BurstAccessMode | Init->WaitSignalPolarity | Init->WrapMode | Init->WaitSignalActive |\ |
271 | | Init->WaitSignalActive |
- | 272 | | Init->WriteOperation |
|
- | 273 | | Init->WaitSignal |
|
- | 274 | | Init->ExtendedMode |
|
- | 275 | | Init->AsynchronousWait |
|
- | 276 | | Init->WriteBurst |
|
232 | Init->WriteOperation | Init->WaitSignal | Init->ExtendedMode | Init->AsynchronousWait | Init->WriteBurst ) \ |
277 | ) |
233 | ); |
278 | ); |
234 | } |
279 | } |
235 | 280 | ||
236 | return HAL_OK; |
281 | return HAL_OK; |
237 | } |
282 | } |
238 | 283 | ||
239 | 284 | ||
240 | /** |
285 | /** |
241 | * @brief DeInitialize the FSMC_NORSRAM peripheral |
286 | * @brief DeInitialize the FSMC_NORSRAM peripheral |
242 | * @param Device: Pointer to NORSRAM device instance |
287 | * @param Device: Pointer to NORSRAM device instance |
243 | * @param ExDevice: Pointer to NORSRAM extended mode device instance |
288 | * @param ExDevice: Pointer to NORSRAM extended mode device instance |
244 | * @param Bank: NORSRAM bank number |
289 | * @param Bank: NORSRAM bank number |
245 | * @retval HAL status |
290 | * @retval HAL status |
246 | */ |
291 | */ |
247 | HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank) |
292 | HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank) |
248 | { |
293 | { |
249 | /* Check the parameters */ |
294 | /* Check the parameters */ |
Line 251... | Line 296... | ||
251 | assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice)); |
296 | assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice)); |
252 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
297 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
253 | 298 | ||
254 | /* Disable the FSMC_NORSRAM device */ |
299 | /* Disable the FSMC_NORSRAM device */ |
255 | __FSMC_NORSRAM_DISABLE(Device, Bank); |
300 | __FSMC_NORSRAM_DISABLE(Device, Bank); |
256 | 301 | ||
257 | /* De-initialize the FSMC_NORSRAM device */ |
302 | /* De-initialize the FSMC_NORSRAM device */ |
258 | /* FSMC_NORSRAM_BANK1 */ |
303 | /* FSMC_NORSRAM_BANK1 */ |
259 | if(Bank == FSMC_NORSRAM_BANK1) |
304 | if (Bank == FSMC_NORSRAM_BANK1) |
260 | { |
305 | { |
261 | Device->BTCR[Bank] = 0x000030DB; |
306 | Device->BTCR[Bank] = 0x000030DB; |
262 | } |
307 | } |
263 | /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */ |
308 | /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */ |
264 | else |
309 | else |
265 | { |
310 | { |
266 | Device->BTCR[Bank] = 0x000030D2; |
311 | Device->BTCR[Bank] = 0x000030D2; |
267 | } |
312 | } |
268 | 313 | ||
269 | Device->BTCR[Bank + 1] = 0x0FFFFFFF; |
314 | Device->BTCR[Bank + 1] = 0x0FFFFFFF; |
270 | ExDevice->BWTR[Bank] = 0x0FFFFFFF; |
315 | ExDevice->BWTR[Bank] = 0x0FFFFFFF; |
271 | 316 | ||
272 | return HAL_OK; |
317 | return HAL_OK; |
273 | } |
318 | } |
274 | 319 | ||
275 | 320 | ||
276 | /** |
321 | /** |
277 | * @brief Initialize the FSMC_NORSRAM Timing according to the specified |
322 | * @brief Initialize the FSMC_NORSRAM Timing according to the specified |
278 | * parameters in the FSMC_NORSRAM_TimingTypeDef |
323 | * parameters in the FSMC_NORSRAM_TimingTypeDef |
279 | * @param Device: Pointer to NORSRAM device instance |
324 | * @param Device: Pointer to NORSRAM device instance |
280 | * @param Timing: Pointer to NORSRAM Timing structure |
325 | * @param Timing: Pointer to NORSRAM Timing structure |
281 | * @param Bank: NORSRAM bank number |
326 | * @param Bank: NORSRAM bank number |
282 | * @retval HAL status |
327 | * @retval HAL status |
283 | */ |
328 | */ |
284 | HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank) |
329 | HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank) |
285 | { |
330 | { |
286 | /* Check the parameters */ |
331 | /* Check the parameters */ |
Line 291... | Line 336... | ||
291 | assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration)); |
336 | assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration)); |
292 | assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision)); |
337 | assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision)); |
293 | assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency)); |
338 | assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency)); |
294 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
339 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
295 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
340 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
296 | - | ||
297 | /* Set FSMC_NORSRAM device timing parameters */ |
- | |
298 | MODIFY_REG(Device->BTCR[Bank + 1], \ |
- | |
299 | (FSMC_BTRx_ADDSET | FSMC_BTRx_ADDHLD | FSMC_BTRx_DATAST | FSMC_BTRx_BUSTURN | \ |
- | |
300 | FSMC_BTRx_CLKDIV | FSMC_BTRx_DATLAT | FSMC_BTRx_ACCMOD), \ |
- | |
301 | ( Timing->AddressSetupTime | \ |
- | |
302 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BTRx_ADDHLD)) | \ |
- | |
303 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BTRx_DATAST)) | \ |
- | |
304 | ((Timing->BusTurnAroundDuration) << POSITION_VAL(FSMC_BTRx_BUSTURN)) | \ |
- | |
305 | (((Timing->CLKDivision)-1) << POSITION_VAL(FSMC_BTRx_CLKDIV)) | \ |
- | |
306 | (((Timing->DataLatency)-2) << POSITION_VAL(FSMC_BTRx_DATLAT)) | \ |
- | |
307 | (Timing->AccessMode))); |
- | |
308 | 341 | ||
- | 342 | /* Set FSMC_NORSRAM device timing parameters */ |
|
- | 343 | MODIFY_REG(Device->BTCR[Bank + 1], \ |
|
- | 344 | BTR_CLEAR_MASK, \ |
|
- | 345 | (uint32_t)(Timing->AddressSetupTime | \ |
|
- | 346 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BTRx_ADDHLD)) | \ |
|
- | 347 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BTRx_DATAST)) | \ |
|
- | 348 | ((Timing->BusTurnAroundDuration) << POSITION_VAL(FSMC_BTRx_BUSTURN)) | \ |
|
- | 349 | (((Timing->CLKDivision) - 1) << POSITION_VAL(FSMC_BTRx_CLKDIV)) | \ |
|
- | 350 | (((Timing->DataLatency) - 2) << POSITION_VAL(FSMC_BTRx_DATLAT)) | \ |
|
- | 351 | (Timing->AccessMode))); |
|
- | 352 | ||
309 | return HAL_OK; |
353 | return HAL_OK; |
310 | } |
354 | } |
311 | 355 | ||
312 | /** |
356 | /** |
313 | * @brief Initialize the FSMC_NORSRAM Extended mode Timing according to the specified |
357 | * @brief Initialize the FSMC_NORSRAM Extended mode Timing according to the specified |
314 | * parameters in the FSMC_NORSRAM_TimingTypeDef |
358 | * parameters in the FSMC_NORSRAM_TimingTypeDef |
315 | * @param Device: Pointer to NORSRAM device instance |
359 | * @param Device: Pointer to NORSRAM device instance |
316 | * @param Timing: Pointer to NORSRAM Timing structure |
360 | * @param Timing: Pointer to NORSRAM Timing structure |
317 | * @param Bank: NORSRAM bank number |
361 | * @param Bank: NORSRAM bank number |
318 | * @param ExtendedMode: FSMC Extended Mode |
362 | * @param ExtendedMode: FSMC Extended Mode |
319 | * This parameter can be one of the following values: |
363 | * This parameter can be one of the following values: |
320 | * @arg FSMC_EXTENDED_MODE_DISABLE |
364 | * @arg FSMC_EXTENDED_MODE_DISABLE |
321 | * @arg FSMC_EXTENDED_MODE_ENABLE |
365 | * @arg FSMC_EXTENDED_MODE_ENABLE |
322 | * @retval HAL status |
366 | * @retval HAL status |
323 | */ |
367 | */ |
324 | HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode) |
368 | HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode) |
325 | { |
369 | { |
326 | /* Check the parameters */ |
370 | /* Check the parameters */ |
327 | assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode)); |
371 | assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode)); |
328 | 372 | ||
329 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
373 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
330 | if(ExtendedMode == FSMC_EXTENDED_MODE_ENABLE) |
374 | if (ExtendedMode == FSMC_EXTENDED_MODE_ENABLE) |
331 | { |
375 | { |
332 | /* Check the parameters */ |
376 | /* Check the parameters */ |
333 | assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(Device)); |
377 | assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(Device)); |
334 | assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime)); |
378 | assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime)); |
335 | assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime)); |
379 | assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime)); |
336 | assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime)); |
380 | assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime)); |
337 | #if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) |
381 | #if (defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)) |
338 | assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration)); |
382 | assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration)); |
339 | #else |
383 | #else |
340 | assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision)); |
384 | assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision)); |
341 | assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency)); |
385 | assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency)); |
342 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
386 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
343 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
387 | assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode)); |
344 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
388 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
345 | 389 | ||
- | 390 | /* Set NORSRAM device timing register for write configuration, if extended mode is used */ |
|
346 | #if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) |
391 | #if (defined(STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)) |
347 | MODIFY_REG(Device->BWTR[Bank], \ |
392 | MODIFY_REG(Device->BWTR[Bank], \ |
348 | (FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD | FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD | FSMC_BWTRx_BUSTURN), \ |
393 | BWTR_CLEAR_MASK, \ |
349 | (Timing->AddressSetupTime | \ |
394 | (uint32_t)(Timing->AddressSetupTime | \ |
350 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BWTRx_ADDHLD)) | \ |
395 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BWTRx_ADDHLD)) | \ |
351 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BWTRx_DATAST)) | \ |
396 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BWTRx_DATAST)) | \ |
352 | Timing->AccessMode | \ |
397 | Timing->AccessMode | \ |
353 | ((Timing->BusTurnAroundDuration) << POSITION_VAL(FSMC_BWTRx_BUSTURN)))); |
398 | ((Timing->BusTurnAroundDuration) << POSITION_VAL(FSMC_BWTRx_BUSTURN)))); |
354 | #else |
399 | #else |
355 | MODIFY_REG(Device->BWTR[Bank], \ |
400 | MODIFY_REG(Device->BWTR[Bank], \ |
356 | (FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD | FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD | FSMC_BWTRx_CLKDIV | FSMC_BWTRx_DATLAT), \ |
401 | BWTR_CLEAR_MASK, \ |
357 | (Timing->AddressSetupTime | \ |
402 | (uint32_t)(Timing->AddressSetupTime | \ |
358 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BWTRx_ADDHLD)) | \ |
403 | ((Timing->AddressHoldTime) << POSITION_VAL(FSMC_BWTRx_ADDHLD)) | \ |
359 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BWTRx_DATAST)) | \ |
404 | ((Timing->DataSetupTime) << POSITION_VAL(FSMC_BWTRx_DATAST)) | \ |
360 | Timing->AccessMode | \ |
405 | Timing->AccessMode | \ |
361 | (((Timing->CLKDivision)-1) << POSITION_VAL(FSMC_BTRx_CLKDIV)) | \ |
406 | (((Timing->CLKDivision) - 1) << POSITION_VAL(FSMC_BTRx_CLKDIV)) | \ |
362 | (((Timing->DataLatency)-2) << POSITION_VAL(FSMC_BWTRx_DATLAT)))); |
407 | (((Timing->DataLatency) - 2) << POSITION_VAL(FSMC_BWTRx_DATLAT)))); |
363 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
408 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
364 | } |
409 | } |
365 | else |
410 | else |
366 | { |
411 | { |
367 | Device->BWTR[Bank] = 0x0FFFFFFF; |
412 | Device->BWTR[Bank] = 0x0FFFFFFF; |
368 | } |
413 | } |
369 | 414 | ||
370 | return HAL_OK; |
415 | return HAL_OK; |
371 | } |
416 | } |
372 | 417 | ||
373 | 418 | ||
374 | /** |
419 | /** |
375 | * @} |
420 | * @} |
376 | */ |
421 | */ |
377 | 422 | ||
378 | 423 | ||
379 | /** @defgroup FSMC_NORSRAM_Group2 Control functions |
424 | /** @defgroup FSMC_NORSRAM_Group2 Control functions |
380 | * @brief management functions |
425 | * @brief management functions |
381 | * |
426 | * |
382 | @verbatim |
427 | @verbatim |
383 | ============================================================================== |
428 | ============================================================================== |
384 | ##### FSMC_NORSRAM Control functions ##### |
429 | ##### FSMC_NORSRAM Control functions ##### |
385 | ============================================================================== |
430 | ============================================================================== |
386 | [..] |
431 | [..] |
387 | This subsection provides a set of functions allowing to control dynamically |
432 | This subsection provides a set of functions allowing to control dynamically |
388 | the FSMC NORSRAM interface. |
433 | the FSMC NORSRAM interface. |
389 | 434 | ||
390 | @endverbatim |
435 | @endverbatim |
391 | * @{ |
436 | * @{ |
392 | */ |
437 | */ |
393 | 438 | ||
394 | /** |
439 | /** |
395 | * @brief Enables dynamically FSMC_NORSRAM write operation. |
440 | * @brief Enables dynamically FSMC_NORSRAM write operation. |
396 | * @param Device: Pointer to NORSRAM device instance |
441 | * @param Device: Pointer to NORSRAM device instance |
397 | * @param Bank: NORSRAM bank number |
442 | * @param Bank: NORSRAM bank number |
398 | * @retval HAL status |
443 | * @retval HAL status |
399 | */ |
444 | */ |
400 | HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank) |
445 | HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank) |
401 | { |
446 | { |
402 | /* Check the parameters */ |
447 | /* Check the parameters */ |
403 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
448 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
404 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
449 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
405 | 450 | ||
406 | /* Enable write operation */ |
451 | /* Enable write operation */ |
407 | SET_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE); |
452 | SET_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE); |
408 | 453 | ||
409 | return HAL_OK; |
454 | return HAL_OK; |
410 | } |
455 | } |
411 | 456 | ||
412 | /** |
457 | /** |
413 | * @brief Disables dynamically FSMC_NORSRAM write operation. |
458 | * @brief Disables dynamically FSMC_NORSRAM write operation. |
414 | * @param Device: Pointer to NORSRAM device instance |
459 | * @param Device: Pointer to NORSRAM device instance |
415 | * @param Bank: NORSRAM bank number |
460 | * @param Bank: NORSRAM bank number |
416 | * @retval HAL status |
461 | * @retval HAL status |
417 | */ |
462 | */ |
418 | HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank) |
463 | HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank) |
419 | { |
464 | { |
420 | /* Check the parameters */ |
465 | /* Check the parameters */ |
421 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
466 | assert_param(IS_FSMC_NORSRAM_DEVICE(Device)); |
422 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
467 | assert_param(IS_FSMC_NORSRAM_BANK(Bank)); |
423 | 468 | ||
424 | /* Disable write operation */ |
469 | /* Disable write operation */ |
425 | CLEAR_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE); |
470 | CLEAR_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE); |
426 | 471 | ||
427 | return HAL_OK; |
472 | return HAL_OK; |
428 | } |
473 | } |
429 | 474 | ||
430 | /** |
475 | /** |
431 | * @} |
476 | * @} |
432 | */ |
477 | */ |
433 | 478 | ||
434 | /** |
479 | /** |
435 | * @} |
480 | * @} |
436 | */ |
481 | */ |
437 | #if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG) |
482 | #if (defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)) |
438 | /** @defgroup FSMC_NAND FSMC NAND Controller functions |
483 | /** @defgroup FSMC_NAND FSMC NAND Controller functions |
439 | * @brief NAND Controller functions |
484 | * @brief NAND Controller functions |
440 | * |
485 | * |
441 | @verbatim |
486 | @verbatim |
442 | ============================================================================== |
487 | ============================================================================== |
443 | ##### How to use NAND device driver ##### |
488 | ##### How to use NAND device driver ##### |
444 | ============================================================================== |
489 | ============================================================================== |
445 | [..] |
490 | [..] |
446 | This driver contains a set of APIs to interface with the FSMC NAND banks in order |
491 | This driver contains a set of APIs to interface with the FSMC NAND banks in order |
447 | to run the NAND external devices. |
492 | to run the NAND external devices. |
448 | |
493 | |
449 | (+) FSMC NAND bank reset using the function FSMC_NAND_DeInit() |
494 | (+) FSMC NAND bank reset using the function FSMC_NAND_DeInit() |
450 | (+) FSMC NAND bank control configuration using the function FSMC_NAND_Init() |
495 | (+) FSMC NAND bank control configuration using the function FSMC_NAND_Init() |
451 | (+) FSMC NAND bank common space timing configuration using the function |
496 | (+) FSMC NAND bank common space timing configuration using the function |
452 | FSMC_NAND_CommonSpace_Timing_Init() |
497 | FSMC_NAND_CommonSpace_Timing_Init() |
453 | (+) FSMC NAND bank attribute space timing configuration using the function |
498 | (+) FSMC NAND bank attribute space timing configuration using the function |
454 | FSMC_NAND_AttributeSpace_Timing_Init() |
499 | FSMC_NAND_AttributeSpace_Timing_Init() |
455 | (+) FSMC NAND bank enable/disable ECC correction feature using the functions |
500 | (+) FSMC NAND bank enable/disable ECC correction feature using the functions |
456 | FSMC_NAND_ECC_Enable()/FSMC_NAND_ECC_Disable() |
501 | FSMC_NAND_ECC_Enable()/FSMC_NAND_ECC_Disable() |
457 | (+) FSMC NAND bank get ECC correction code using the function FSMC_NAND_GetECC() |
502 | (+) FSMC NAND bank get ECC correction code using the function FSMC_NAND_GetECC() |
458 | 503 | ||
459 | @endverbatim |
504 | @endverbatim |
460 | * @{ |
505 | * @{ |
461 | */ |
506 | */ |
462 | 507 | ||
463 | /** @defgroup FSMC_NAND_Exported_Functions_Group1 Initialization and de-initialization functions |
508 | /** @defgroup FSMC_NAND_Exported_Functions_Group1 Initialization and de-initialization functions |
464 | * @brief Initialization and Configuration functions |
509 | * @brief Initialization and Configuration functions |
465 | * |
510 | * |
466 | @verbatim |
511 | @verbatim |
467 | ============================================================================== |
512 | ============================================================================== |
468 | ##### Initialization and de_initialization functions ##### |
513 | ##### Initialization and de_initialization functions ##### |
469 | ============================================================================== |
514 | ============================================================================== |
470 | [..] |
515 | [..] |
471 | This section provides functions allowing to: |
516 | This section provides functions allowing to: |
472 | (+) Initialize and configure the FSMC NAND interface |
517 | (+) Initialize and configure the FSMC NAND interface |
473 | (+) De-initialize the FSMC NAND interface |
518 | (+) De-initialize the FSMC NAND interface |
474 | (+) Configure the FSMC clock and associated GPIOs |
519 | (+) Configure the FSMC clock and associated GPIOs |
475 | |
520 | |
476 | @endverbatim |
521 | @endverbatim |
477 | * @{ |
522 | * @{ |
478 | */ |
523 | */ |
479 | 524 | ||
480 | /** |
525 | /** |
481 | * @brief Initializes the FSMC_NAND device according to the specified |
526 | * @brief Initializes the FSMC_NAND device according to the specified |
482 | * control parameters in the FSMC_NAND_HandleTypeDef |
527 | * control parameters in the FSMC_NAND_HandleTypeDef |
483 | * @param Device: Pointer to NAND device instance |
528 | * @param Device: Pointer to NAND device instance |
484 | * @param Init: Pointer to NAND Initialization structure |
529 | * @param Init: Pointer to NAND Initialization structure |
Line 492... | Line 537... | ||
492 | assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature)); |
537 | assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature)); |
493 | assert_param(IS_FSMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth)); |
538 | assert_param(IS_FSMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth)); |
494 | assert_param(IS_FSMC_ECC_STATE(Init->EccComputation)); |
539 | assert_param(IS_FSMC_ECC_STATE(Init->EccComputation)); |
495 | assert_param(IS_FSMC_ECCPAGE_SIZE(Init->ECCPageSize)); |
540 | assert_param(IS_FSMC_ECCPAGE_SIZE(Init->ECCPageSize)); |
496 | assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime)); |
541 | assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime)); |
497 | assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime)); |
542 | assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime)); |
498 | 543 | ||
- | 544 | /* Set NAND device control parameters */ |
|
499 | if(Init->NandBank == FSMC_NAND_BANK2) |
545 | if (Init->NandBank == FSMC_NAND_BANK2) |
500 | { |
546 | { |
501 | /* NAND bank 2 registers configuration */ |
547 | /* NAND bank 2 registers configuration */ |
502 | MODIFY_REG(Device->PCR2, PCR_CLEAR_MASK, (Init->Waitfeature |\ |
548 | MODIFY_REG(Device->PCR2, PCR_CLEAR_MASK, (Init->Waitfeature | \ |
503 | FSMC_PCR_MEMORY_TYPE_NAND |\ |
549 | FSMC_PCR_MEMORY_TYPE_NAND | \ |
504 | Init->MemoryDataWidth |\ |
550 | Init->MemoryDataWidth | \ |
505 | Init->EccComputation |\ |
551 | Init->EccComputation | \ |
506 | Init->ECCPageSize |\ |
552 | Init->ECCPageSize | \ |
507 | ((Init->TCLRSetupTime) << POSITION_VAL(FSMC_PCRx_TCLR)) |\ |
553 | ((Init->TCLRSetupTime) << POSITION_VAL(FSMC_PCRx_TCLR)) | \ |
508 | ((Init->TARSetupTime) << POSITION_VAL(FSMC_PCRx_TAR)))); |
554 | ((Init->TARSetupTime) << POSITION_VAL(FSMC_PCRx_TAR)))); |
509 | } |
555 | } |
510 | else |
556 | else |
511 | { |
557 | { |
512 | /* NAND bank 3 registers configuration */ |
558 | /* NAND bank 3 registers configuration */ |
513 | MODIFY_REG(Device->PCR3, PCR_CLEAR_MASK, (Init->Waitfeature |\ |
559 | MODIFY_REG(Device->PCR3, PCR_CLEAR_MASK, (Init->Waitfeature | \ |
514 | FSMC_PCR_MEMORY_TYPE_NAND |\ |
560 | FSMC_PCR_MEMORY_TYPE_NAND | \ |
515 | Init->MemoryDataWidth |\ |
561 | Init->MemoryDataWidth | \ |
516 | Init->EccComputation |\ |
562 | Init->EccComputation | \ |
517 | Init->ECCPageSize |\ |
563 | Init->ECCPageSize | \ |
518 | ((Init->TCLRSetupTime) << POSITION_VAL(FSMC_PCRx_TCLR)) |\ |
564 | ((Init->TCLRSetupTime) << POSITION_VAL(FSMC_PCRx_TCLR)) | \ |
519 | ((Init->TARSetupTime) << POSITION_VAL(FSMC_PCRx_TAR)))); |
565 | ((Init->TARSetupTime) << POSITION_VAL(FSMC_PCRx_TAR)))); |
520 | } |
566 | } |
521 | 567 | ||
522 | return HAL_OK; |
568 | return HAL_OK; |
523 | 569 | ||
524 | } |
570 | } |
525 | 571 | ||
526 | /** |
572 | /** |
527 | * @brief Initializes the FSMC_NAND Common space Timing according to the specified |
573 | * @brief Initializes the FSMC_NAND Common space Timing according to the specified |
528 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
574 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
529 | * @param Device: Pointer to NAND device instance |
575 | * @param Device: Pointer to NAND device instance |
530 | * @param Timing: Pointer to NAND timing structure |
576 | * @param Timing: Pointer to NAND timing structure |
531 | * @param Bank: NAND bank number |
577 | * @param Bank: NAND bank number |
532 | * @retval HAL status |
578 | * @retval HAL status |
533 | */ |
579 | */ |
534 | HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank) |
580 | HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank) |
535 | { |
581 | { |
536 | /* Check the parameters */ |
582 | /* Check the parameters */ |
Line 538... | Line 584... | ||
538 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
584 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
539 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
585 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
540 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
586 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
541 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
587 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
542 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
588 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
543 | 589 | ||
- | 590 | /* Set FMC_NAND device timing parameters */ |
|
544 | if(Bank == FSMC_NAND_BANK2) |
591 | if (Bank == FSMC_NAND_BANK2) |
545 | { |
592 | { |
546 | /* NAND bank 2 registers configuration */ |
593 | /* NAND bank 2 registers configuration */ |
547 | MODIFY_REG(Device->PMEM2, PMEM_CLEAR_MASK, (Timing->SetupTime |\ |
594 | MODIFY_REG(Device->PMEM2, PMEM_CLEAR_MASK, (Timing->SetupTime | \ |
548 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMWAITx)) |\ |
595 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMWAITx)) | \ |
549 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHOLDx)) |\ |
596 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHOLDx)) | \ |
550 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHIZx)))); |
597 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHIZx)))); |
551 | - | ||
552 | } |
598 | } |
553 | else |
599 | else |
554 | { |
600 | { |
555 | /* NAND bank 3 registers configuration */ |
601 | /* NAND bank 3 registers configuration */ |
556 | MODIFY_REG(Device->PMEM3, PMEM_CLEAR_MASK, (Timing->SetupTime |\ |
602 | MODIFY_REG(Device->PMEM3, PMEM_CLEAR_MASK, (Timing->SetupTime | \ |
557 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMWAITx)) |\ |
603 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMWAITx)) | \ |
558 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHOLDx)) |\ |
604 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHOLDx)) | \ |
559 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHIZx)))); |
605 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHIZx)))); |
560 | } |
606 | } |
561 | 607 | ||
562 | return HAL_OK; |
608 | return HAL_OK; |
563 | } |
609 | } |
564 | 610 | ||
565 | /** |
611 | /** |
566 | * @brief Initializes the FSMC_NAND Attribute space Timing according to the specified |
612 | * @brief Initializes the FSMC_NAND Attribute space Timing according to the specified |
567 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
613 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
568 | * @param Device: Pointer to NAND device instance |
614 | * @param Device: Pointer to NAND device instance |
569 | * @param Timing: Pointer to NAND timing structure |
615 | * @param Timing: Pointer to NAND timing structure |
570 | * @param Bank: NAND bank number |
616 | * @param Bank: NAND bank number |
571 | * @retval HAL status |
617 | * @retval HAL status |
572 | */ |
618 | */ |
573 | HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank) |
619 | HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank) |
574 | { |
620 | { |
575 | /* Check the parameters */ |
621 | /* Check the parameters */ |
576 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
622 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
577 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
623 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
578 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
624 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
579 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
625 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
580 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
626 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
581 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
627 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
582 | 628 | ||
- | 629 | /* Set FMC_NAND device timing parameters */ |
|
583 | if(Bank == FSMC_NAND_BANK2) |
630 | if (Bank == FSMC_NAND_BANK2) |
584 | { |
631 | { |
585 | /* NAND bank 2 registers configuration */ |
632 | /* NAND bank 2 registers configuration */ |
586 | MODIFY_REG(Device->PATT2, PATT_CLEAR_MASK, (Timing->SetupTime |\ |
633 | MODIFY_REG(Device->PATT2, PATT_CLEAR_MASK, (Timing->SetupTime | \ |
587 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PATTx_ATTWAITx)) |\ |
634 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PATTx_ATTWAITx)) | \ |
588 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHOLDx)) |\ |
635 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHOLDx)) | \ |
589 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHIZx)))); |
636 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHIZx)))); |
590 | } |
637 | } |
591 | else |
638 | else |
592 | { |
639 | { |
593 | /* NAND bank 3 registers configuration */ |
640 | /* NAND bank 3 registers configuration */ |
594 | MODIFY_REG(Device->PATT3, PATT_CLEAR_MASK, (Timing->SetupTime |\ |
641 | MODIFY_REG(Device->PATT3, PATT_CLEAR_MASK, (Timing->SetupTime | \ |
595 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PATTx_ATTWAITx)) |\ |
642 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PATTx_ATTWAITx)) | \ |
596 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHOLDx)) |\ |
643 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHOLDx)) | \ |
597 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHIZx)))); |
644 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHIZx)))); |
598 | } |
645 | } |
599 | 646 | ||
600 | return HAL_OK; |
647 | return HAL_OK; |
601 | } |
648 | } |
602 | 649 | ||
603 | 650 | ||
604 | /** |
651 | /** |
605 | * @brief DeInitializes the FSMC_NAND device |
652 | * @brief DeInitializes the FSMC_NAND device |
606 | * @param Device: Pointer to NAND device instance |
653 | * @param Device: Pointer to NAND device instance |
607 | * @param Bank: NAND bank number |
654 | * @param Bank: NAND bank number |
608 | * @retval HAL status |
655 | * @retval HAL status |
609 | */ |
656 | */ |
610 | HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank) |
657 | HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank) |
611 | { |
658 | { |
612 | /* Check the parameters */ |
659 | /* Check the parameters */ |
613 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
660 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
614 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
661 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
615 | 662 | ||
616 | /* Disable the NAND Bank */ |
663 | /* Disable the NAND Bank */ |
617 | __FSMC_NAND_DISABLE(Device, Bank); |
664 | __FSMC_NAND_DISABLE(Device, Bank); |
618 | 665 | ||
619 | /* De-initialize the NAND Bank */ |
666 | /* De-initialize the NAND Bank */ |
620 | if(Bank == FSMC_NAND_BANK2) |
667 | if (Bank == FSMC_NAND_BANK2) |
621 | { |
668 | { |
622 | /* Set the FSMC_NAND_BANK2 registers to their reset values */ |
669 | /* Set the FSMC_NAND_BANK2 registers to their reset values */ |
623 | WRITE_REG(Device->PCR2, 0x00000018); |
670 | WRITE_REG(Device->PCR2, 0x00000018); |
624 | WRITE_REG(Device->SR2, 0x00000040); |
671 | WRITE_REG(Device->SR2, 0x00000040); |
625 | WRITE_REG(Device->PMEM2, 0xFCFCFCFC); |
672 | WRITE_REG(Device->PMEM2, 0xFCFCFCFC); |
626 | WRITE_REG(Device->PATT2, 0xFCFCFCFC); |
673 | WRITE_REG(Device->PATT2, 0xFCFCFCFC); |
627 | } |
674 | } |
628 | /* FSMC_Bank3_NAND */ |
675 | /* FSMC_Bank3_NAND */ |
629 | else |
676 | else |
630 | { |
677 | { |
631 | /* Set the FSMC_NAND_BANK3 registers to their reset values */ |
678 | /* Set the FSMC_NAND_BANK3 registers to their reset values */ |
632 | WRITE_REG(Device->PCR3, 0x00000018); |
679 | WRITE_REG(Device->PCR3, 0x00000018); |
633 | WRITE_REG(Device->SR3, 0x00000040); |
680 | WRITE_REG(Device->SR3, 0x00000040); |
634 | WRITE_REG(Device->PMEM3, 0xFCFCFCFC); |
681 | WRITE_REG(Device->PMEM3, 0xFCFCFCFC); |
635 | WRITE_REG(Device->PATT3, 0xFCFCFCFC); |
682 | WRITE_REG(Device->PATT3, 0xFCFCFCFC); |
636 | } |
683 | } |
637 | 684 | ||
638 | return HAL_OK; |
685 | return HAL_OK; |
639 | } |
686 | } |
640 | 687 | ||
641 | /** |
688 | /** |
642 | * @} |
689 | * @} |
643 | */ |
690 | */ |
644 | 691 | ||
645 | 692 | ||
646 | /** @defgroup FSMC_NAND_Exported_Functions_Group2 Peripheral Control functions |
693 | /** @defgroup FSMC_NAND_Exported_Functions_Group2 Peripheral Control functions |
647 | * @brief management functions |
694 | * @brief management functions |
648 | * |
695 | * |
649 | @verbatim |
696 | @verbatim |
650 | ============================================================================== |
697 | ============================================================================== |
651 | ##### FSMC_NAND Control functions ##### |
698 | ##### FSMC_NAND Control functions ##### |
652 | ============================================================================== |
699 | ============================================================================== |
653 | [..] |
700 | [..] |
654 | This subsection provides a set of functions allowing to control dynamically |
701 | This subsection provides a set of functions allowing to control dynamically |
655 | the FSMC NAND interface. |
702 | the FSMC NAND interface. |
656 | 703 | ||
657 | @endverbatim |
704 | @endverbatim |
658 | * @{ |
705 | * @{ |
659 | */ |
706 | */ |
- | 707 | ||
660 | 708 | ||
661 | - | ||
662 | /** |
709 | /** |
663 | * @brief Enables dynamically FSMC_NAND ECC feature. |
710 | * @brief Enables dynamically FSMC_NAND ECC feature. |
664 | * @param Device: Pointer to NAND device instance |
711 | * @param Device: Pointer to NAND device instance |
665 | * @param Bank: NAND bank number |
712 | * @param Bank: NAND bank number |
666 | * @retval HAL status |
713 | * @retval HAL status |
667 | */ |
714 | */ |
668 | HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank) |
715 | HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank) |
669 | { |
716 | { |
670 | /* Check the parameters */ |
717 | /* Check the parameters */ |
671 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
718 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
672 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
719 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
673 | 720 | ||
674 | /* Enable ECC feature */ |
721 | /* Enable ECC feature */ |
675 | if(Bank == FSMC_NAND_BANK2) |
722 | if (Bank == FSMC_NAND_BANK2) |
676 | { |
723 | { |
677 | SET_BIT(Device->PCR2, FSMC_PCRx_ECCEN); |
724 | SET_BIT(Device->PCR2, FSMC_PCRx_ECCEN); |
678 | } |
725 | } |
679 | else |
726 | else |
680 | { |
727 | { |
681 | SET_BIT(Device->PCR3, FSMC_PCRx_ECCEN); |
728 | SET_BIT(Device->PCR3, FSMC_PCRx_ECCEN); |
682 | } |
729 | } |
683 | 730 | ||
684 | return HAL_OK; |
731 | return HAL_OK; |
685 | } |
732 | } |
686 | 733 | ||
687 | 734 | ||
688 | /** |
735 | /** |
689 | * @brief Disables dynamically FSMC_NAND ECC feature. |
736 | * @brief Disables dynamically FSMC_NAND ECC feature. |
690 | * @param Device: Pointer to NAND device instance |
737 | * @param Device: Pointer to NAND device instance |
691 | * @param Bank: NAND bank number |
738 | * @param Bank: NAND bank number |
692 | * @retval HAL status |
739 | * @retval HAL status |
693 | */ |
740 | */ |
694 | HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank) |
741 | HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank) |
695 | { |
742 | { |
696 | /* Check the parameters */ |
743 | /* Check the parameters */ |
697 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
744 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
698 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
745 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
699 | 746 | ||
700 | /* Disable ECC feature */ |
747 | /* Disable ECC feature */ |
701 | if(Bank == FSMC_NAND_BANK2) |
748 | if (Bank == FSMC_NAND_BANK2) |
702 | { |
749 | { |
703 | CLEAR_BIT(Device->PCR2, FSMC_PCRx_ECCEN); |
750 | CLEAR_BIT(Device->PCR2, FSMC_PCRx_ECCEN); |
704 | } |
751 | } |
705 | else |
752 | else |
706 | { |
753 | { |
707 | CLEAR_BIT(Device->PCR3, FSMC_PCRx_ECCEN); |
754 | CLEAR_BIT(Device->PCR3, FSMC_PCRx_ECCEN); |
708 | } |
755 | } |
709 | 756 | ||
710 | return HAL_OK; |
757 | return HAL_OK; |
711 | } |
758 | } |
712 | 759 | ||
713 | /** |
760 | /** |
714 | * @brief Disables dynamically FSMC_NAND ECC feature. |
761 | * @brief Disables dynamically FSMC_NAND ECC feature. |
715 | * @param Device: Pointer to NAND device instance |
762 | * @param Device: Pointer to NAND device instance |
716 | * @param ECCval: Pointer to ECC value |
763 | * @param ECCval: Pointer to ECC value |
717 | * @param Bank: NAND bank number |
764 | * @param Bank: NAND bank number |
718 | * @param Timeout: Timeout wait value |
765 | * @param Timeout: Timeout wait value |
719 | * @retval HAL status |
766 | * @retval HAL status |
720 | */ |
767 | */ |
721 | HAL_StatusTypeDef FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout) |
768 | HAL_StatusTypeDef FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout) |
722 | { |
769 | { |
723 | uint32_t tickstart = 0; |
770 | uint32_t tickstart = 0; |
724 | 771 | ||
725 | /* Check the parameters */ |
772 | /* Check the parameters */ |
726 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
773 | assert_param(IS_FSMC_NAND_DEVICE(Device)); |
727 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
774 | assert_param(IS_FSMC_NAND_BANK(Bank)); |
728 | 775 | ||
729 | /* Get tick */ |
776 | /* Get tick */ |
730 | tickstart = HAL_GetTick(); |
777 | tickstart = HAL_GetTick(); |
731 | 778 | ||
732 | /* Wait untill FIFO is empty */ |
779 | /* Wait untill FIFO is empty */ |
733 | while(__FSMC_NAND_GET_FLAG(Device, Bank, FSMC_FLAG_FEMPT) == RESET) |
780 | while (__FSMC_NAND_GET_FLAG(Device, Bank, FSMC_FLAG_FEMPT) == RESET) |
734 | { |
781 | { |
735 | /* Check for the Timeout */ |
782 | /* Check for the Timeout */ |
736 | if(Timeout != HAL_MAX_DELAY) |
783 | if (Timeout != HAL_MAX_DELAY) |
737 | { |
784 | { |
738 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
785 | if ((Timeout == 0) || ((HAL_GetTick() - tickstart) > Timeout)) |
739 | { |
786 | { |
740 | return HAL_TIMEOUT; |
787 | return HAL_TIMEOUT; |
741 | } |
788 | } |
742 | } |
789 | } |
743 | } |
790 | } |
744 | 791 | ||
745 | if(Bank == FSMC_NAND_BANK2) |
792 | if (Bank == FSMC_NAND_BANK2) |
746 | { |
793 | { |
747 | /* Get the ECCR2 register value */ |
794 | /* Get the ECCR2 register value */ |
748 | *ECCval = (uint32_t)Device->ECCR2; |
795 | *ECCval = (uint32_t)Device->ECCR2; |
749 | } |
796 | } |
750 | else |
797 | else |
751 | { |
798 | { |
752 | /* Get the ECCR3 register value */ |
799 | /* Get the ECCR3 register value */ |
753 | *ECCval = (uint32_t)Device->ECCR3; |
800 | *ECCval = (uint32_t)Device->ECCR3; |
754 | } |
801 | } |
755 | 802 | ||
756 | return HAL_OK; |
803 | return HAL_OK; |
757 | } |
804 | } |
758 | 805 | ||
759 | /** |
806 | /** |
760 | * @} |
807 | * @} |
761 | */ |
808 | */ |
762 | 809 | ||
763 | /** |
810 | /** |
764 | * @} |
811 | * @} |
765 | */ |
812 | */ |
766 | 813 | ||
- | 814 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
|
- | 815 | #if (defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)) |
|
767 | /** @defgroup FSMC_PCCARD FSMC PCCARD Controller functions |
816 | /** @defgroup FSMC_PCCARD FSMC PCCARD Controller functions |
768 | * @brief PCCARD Controller functions |
817 | * @brief PCCARD Controller functions |
769 | * |
818 | * |
770 | @verbatim |
819 | @verbatim |
771 | ============================================================================== |
820 | ============================================================================== |
772 | ##### How to use PCCARD device driver ##### |
821 | ##### How to use PCCARD device driver ##### |
773 | ============================================================================== |
822 | ============================================================================== |
774 | [..] |
823 | [..] |
775 | This driver contains a set of APIs to interface with the FSMC PCCARD bank in order |
824 | This driver contains a set of APIs to interface with the FSMC PCCARD bank in order |
776 | to run the PCCARD/compact flash external devices. |
825 | to run the PCCARD/compact flash external devices. |
777 | |
826 | |
778 | (+) FSMC PCCARD bank reset using the function FSMC_PCCARD_DeInit() |
827 | (+) FSMC PCCARD bank reset using the function FSMC_PCCARD_DeInit() |
779 | (+) FSMC PCCARD bank control configuration using the function FSMC_PCCARD_Init() |
828 | (+) FSMC PCCARD bank control configuration using the function FSMC_PCCARD_Init() |
780 | (+) FSMC PCCARD bank common space timing configuration using the function |
829 | (+) FSMC PCCARD bank common space timing configuration using the function |
781 | FSMC_PCCARD_CommonSpace_Timing_Init() |
830 | FSMC_PCCARD_CommonSpace_Timing_Init() |
782 | (+) FSMC PCCARD bank attribute space timing configuration using the function |
831 | (+) FSMC PCCARD bank attribute space timing configuration using the function |
783 | FSMC_PCCARD_AttributeSpace_Timing_Init() |
832 | FSMC_PCCARD_AttributeSpace_Timing_Init() |
784 | (+) FSMC PCCARD bank IO space timing configuration using the function |
833 | (+) FSMC PCCARD bank IO space timing configuration using the function |
785 | FSMC_PCCARD_IOSpace_Timing_Init() |
834 | FSMC_PCCARD_IOSpace_Timing_Init() |
786 | 835 | ||
787 | |
836 | |
788 | @endverbatim |
837 | @endverbatim |
789 | * @{ |
838 | * @{ |
790 | */ |
839 | */ |
791 | 840 | ||
792 | /** @defgroup FSMC_PCCARD_Exported_Functions_Group1 Initialization and de-initialization functions |
841 | /** @defgroup FSMC_PCCARD_Exported_Functions_Group1 Initialization and de-initialization functions |
793 | * @brief Initialization and Configuration functions |
842 | * @brief Initialization and Configuration functions |
794 | * |
843 | * |
795 | @verbatim |
844 | @verbatim |
796 | ============================================================================== |
845 | ============================================================================== |
797 | ##### Initialization and de_initialization functions ##### |
846 | ##### Initialization and de_initialization functions ##### |
798 | ============================================================================== |
847 | ============================================================================== |
799 | [..] |
848 | [..] |
800 | This section provides functions allowing to: |
849 | This section provides functions allowing to: |
801 | (+) Initialize and configure the FSMC PCCARD interface |
850 | (+) Initialize and configure the FSMC PCCARD interface |
802 | (+) De-initialize the FSMC PCCARD interface |
851 | (+) De-initialize the FSMC PCCARD interface |
803 | (+) Configure the FSMC clock and associated GPIOs |
852 | (+) Configure the FSMC clock and associated GPIOs |
804 | |
853 | |
805 | @endverbatim |
854 | @endverbatim |
806 | * @{ |
855 | * @{ |
807 | */ |
856 | */ |
808 | 857 | ||
809 | /** |
858 | /** |
810 | * @brief Initializes the FSMC_PCCARD device according to the specified |
859 | * @brief Initializes the FSMC_PCCARD device according to the specified |
811 | * control parameters in the FSMC_PCCARD_HandleTypeDef |
860 | * control parameters in the FSMC_PCCARD_HandleTypeDef |
812 | * @param Device: Pointer to PCCARD device instance |
861 | * @param Device: Pointer to PCCARD device instance |
813 | * @param Init: Pointer to PCCARD Initialization structure |
862 | * @param Init: Pointer to PCCARD Initialization structure |
814 | * @retval HAL status |
863 | * @retval HAL status |
815 | */ |
864 | */ |
816 | HAL_StatusTypeDef FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init) |
865 | HAL_StatusTypeDef FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init) |
817 | { |
866 | { |
818 | /* Check the parameters */ |
867 | /* Check the parameters */ |
819 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
868 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
820 | assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature)); |
869 | assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature)); |
821 | assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime)); |
870 | assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime)); |
822 | assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime)); |
871 | assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime)); |
823 | 872 | ||
824 | /* Set FSMC_PCCARD device control parameters */ |
873 | /* Set FSMC_PCCARD device control parameters */ |
825 | MODIFY_REG(Device->PCR4, \ |
874 | MODIFY_REG(Device->PCR4, \ |
826 | (FSMC_PCRx_PTYP | FSMC_PCRx_PWAITEN | FSMC_PCRx_PWID | FSMC_PCRx_TCLR | FSMC_PCRx_TAR), \ |
875 | (FSMC_PCRx_PTYP | FSMC_PCRx_PWAITEN | FSMC_PCRx_PWID | |
- | 876 | FSMC_PCRx_TCLR | FSMC_PCRx_TAR), \ |
|
827 | (FSMC_PCR_MEMORY_TYPE_PCCARD | \ |
877 | (FSMC_PCR_MEMORY_TYPE_PCCARD | \ |
828 | Init->Waitfeature | \ |
878 | Init->Waitfeature | \ |
829 | FSMC_NAND_PCC_MEM_BUS_WIDTH_16 | \ |
879 | FSMC_NAND_PCC_MEM_BUS_WIDTH_16 | \ |
830 | (Init->TCLRSetupTime << POSITION_VAL(FSMC_PCRx_TCLR)) | \ |
880 | (Init->TCLRSetupTime << POSITION_VAL(FSMC_PCRx_TCLR)) | \ |
831 | (Init->TARSetupTime << POSITION_VAL(FSMC_PCRx_TAR)))); |
881 | (Init->TARSetupTime << POSITION_VAL(FSMC_PCRx_TAR)))); |
832 | 882 | ||
833 | return HAL_OK; |
883 | return HAL_OK; |
834 | 884 | ||
835 | } |
885 | } |
836 | 886 | ||
837 | /** |
887 | /** |
838 | * @brief Initializes the FSMC_PCCARD Common space Timing according to the specified |
888 | * @brief Initializes the FSMC_PCCARD Common space Timing according to the specified |
839 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
889 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
840 | * @param Device: Pointer to PCCARD device instance |
890 | * @param Device: Pointer to PCCARD device instance |
841 | * @param Timing: Pointer to PCCARD timing structure |
891 | * @param Timing: Pointer to PCCARD timing structure |
842 | * @retval HAL status |
892 | * @retval HAL status |
843 | */ |
893 | */ |
844 | HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing) |
894 | HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing) |
845 | { |
895 | { |
846 | /* Check the parameters */ |
896 | /* Check the parameters */ |
Line 850... | Line 900... | ||
850 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
900 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
851 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
901 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
852 | 902 | ||
853 | /* Set PCCARD timing parameters */ |
903 | /* Set PCCARD timing parameters */ |
854 | MODIFY_REG(Device->PMEM4, PMEM_CLEAR_MASK, \ |
904 | MODIFY_REG(Device->PMEM4, PMEM_CLEAR_MASK, \ |
855 | (Timing->SetupTime | \ |
905 | (Timing->SetupTime | \ |
856 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMWAITx)) | \ |
906 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMWAITx)) | \ |
857 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHOLDx)) | \ |
907 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHOLDx)) | \ |
858 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHIZx)))); |
908 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PMEMx_MEMHIZx)))); |
859 | 909 | ||
860 | return HAL_OK; |
910 | return HAL_OK; |
861 | } |
911 | } |
862 | 912 | ||
863 | /** |
913 | /** |
864 | * @brief Initializes the FSMC_PCCARD Attribute space Timing according to the specified |
914 | * @brief Initializes the FSMC_PCCARD Attribute space Timing according to the specified |
865 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
915 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
866 | * @param Device: Pointer to PCCARD device instance |
916 | * @param Device: Pointer to PCCARD device instance |
867 | * @param Timing: Pointer to PCCARD timing structure |
917 | * @param Timing: Pointer to PCCARD timing structure |
868 | * @retval HAL status |
918 | * @retval HAL status |
869 | */ |
919 | */ |
870 | HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing) |
920 | HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing) |
871 | { |
921 | { |
872 | /* Check the parameters */ |
922 | /* Check the parameters */ |
873 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
923 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
874 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
924 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
875 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
925 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
876 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
926 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
877 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
927 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
878 | 928 | ||
879 | /* Set PCCARD timing parameters */ |
929 | /* Set PCCARD timing parameters */ |
880 | MODIFY_REG(Device->PATT4, PATT_CLEAR_MASK, \ |
930 | MODIFY_REG(Device->PATT4, PATT_CLEAR_MASK, \ |
881 | (Timing->SetupTime | \ |
931 | (Timing->SetupTime | \ |
882 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PATTx_ATTWAITx)) | \ |
932 | ((Timing->WaitSetupTime) << POSITION_VAL(FSMC_PATTx_ATTWAITx)) | \ |
883 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHOLDx)) | \ |
933 | ((Timing->HoldSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHOLDx)) | \ |
884 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHIZx)))); |
934 | ((Timing->HiZSetupTime) << POSITION_VAL(FSMC_PATTx_ATTHIZx)))); |
885 | 935 | ||
886 | return HAL_OK; |
936 | return HAL_OK; |
887 | } |
937 | } |
888 | 938 | ||
889 | /** |
939 | /** |
890 | * @brief Initializes the FSMC_PCCARD IO space Timing according to the specified |
940 | * @brief Initializes the FSMC_PCCARD IO space Timing according to the specified |
891 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
941 | * parameters in the FSMC_NAND_PCC_TimingTypeDef |
892 | * @param Device: Pointer to PCCARD device instance |
942 | * @param Device: Pointer to PCCARD device instance |
893 | * @param Timing: Pointer to PCCARD timing structure |
943 | * @param Timing: Pointer to PCCARD timing structure |
894 | * @retval HAL status |
944 | * @retval HAL status |
895 | */ |
945 | */ |
896 | HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing) |
946 | HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing) |
897 | { |
947 | { |
898 | /* Check the parameters */ |
948 | /* Check the parameters */ |
899 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
949 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
900 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
950 | assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime)); |
901 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
951 | assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime)); |
902 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
952 | assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime)); |
903 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
953 | assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime)); |
904 | 954 | ||
905 | /* Set FSMC_PCCARD device timing parameters */ |
955 | /* Set FSMC_PCCARD device timing parameters */ |
906 | MODIFY_REG(Device->PIO4, PIO4_CLEAR_MASK, \ |
956 | MODIFY_REG(Device->PIO4, PIO4_CLEAR_MASK, \ |
907 | (Timing->SetupTime | \ |
957 | (Timing->SetupTime | \ |
908 | (Timing->WaitSetupTime << POSITION_VAL(FSMC_PIO4_IOWAIT4)) | \ |
958 | (Timing->WaitSetupTime << POSITION_VAL(FSMC_PIO4_IOWAIT4)) | \ |
909 | (Timing->HoldSetupTime << POSITION_VAL(FSMC_PIO4_IOHOLD4)) | \ |
959 | (Timing->HoldSetupTime << POSITION_VAL(FSMC_PIO4_IOHOLD4)) | \ |
910 | (Timing->HiZSetupTime << POSITION_VAL(FSMC_PIO4_IOHIZ4)))); |
960 | (Timing->HiZSetupTime << POSITION_VAL(FSMC_PIO4_IOHIZ4)))); |
911 | 961 | ||
912 | return HAL_OK; |
962 | return HAL_OK; |
913 | } |
963 | } |
914 | - | ||
- | 964 | ||
915 | /** |
965 | /** |
916 | * @brief DeInitializes the FSMC_PCCARD device |
966 | * @brief DeInitializes the FSMC_PCCARD device |
917 | * @param Device: Pointer to PCCARD device instance |
967 | * @param Device: Pointer to PCCARD device instance |
918 | * @retval HAL status |
968 | * @retval HAL status |
919 | */ |
969 | */ |
920 | HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device) |
970 | HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device) |
921 | { |
971 | { |
922 | /* Check the parameters */ |
972 | /* Check the parameters */ |
923 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
973 | assert_param(IS_FSMC_PCCARD_DEVICE(Device)); |
924 | 974 | ||
925 | /* Disable the FSMC_PCCARD device */ |
975 | /* Disable the FSMC_PCCARD device */ |
926 | __FSMC_PCCARD_DISABLE(Device); |
976 | __FSMC_PCCARD_DISABLE(Device); |
927 | 977 | ||
928 | /* De-initialize the FSMC_PCCARD device */ |
978 | /* De-initialize the FSMC_PCCARD device */ |
929 | WRITE_REG(Device->PCR4, 0x00000018); |
979 | WRITE_REG(Device->PCR4, 0x00000018); |
930 | WRITE_REG(Device->SR4, 0x00000040); |
980 | WRITE_REG(Device->SR4, 0x00000040); |
931 | WRITE_REG(Device->PMEM4, 0xFCFCFCFC); |
981 | WRITE_REG(Device->PMEM4, 0xFCFCFCFC); |
932 | WRITE_REG(Device->PATT4, 0xFCFCFCFC); |
982 | WRITE_REG(Device->PATT4, 0xFCFCFCFC); |
933 | WRITE_REG(Device->PIO4, 0xFCFCFCFC); |
983 | WRITE_REG(Device->PIO4, 0xFCFCFCFC); |
934 | 984 | ||
935 | return HAL_OK; |
985 | return HAL_OK; |
936 | } |
986 | } |
937 | 987 | ||
938 | /** |
988 | /** |
939 | * @} |
989 | * @} |
940 | */ |
990 | */ |
941 | 991 | ||
942 | /** |
992 | /** |
943 | * @} |
993 | * @} |
944 | */ |
994 | */ |
945 | - | ||
946 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
995 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */ |
947 | 996 | ||
948 | /** |
997 | /** |
949 | * @} |
998 | * @} |
950 | */ |
999 | */ |
951 | 1000 | ||
952 | /** |
1001 | /** |
953 | * @} |
1002 | * @} |
954 | */ |
1003 | */ |
955 | 1004 | ||
956 | #endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG || STM32F100xE */ |
1005 | #endif /* FSMC_BANK1 */ |
957 | 1006 | ||
958 | #endif /* HAL_SRAM_MODULE_ENABLED || HAL_NOR_MODULE_ENABLED || HAL_PCCARD_MODULE_ENABLED || HAL_NAND_MODULE_ENABLED */ |
1007 | #endif /* defined(HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) */ |
959 | 1008 | ||
960 | /** |
1009 | /** |
961 | * @} |
1010 | * @} |
962 | */ |
1011 | */ |
963 | 1012 |