2 ******************************************************************************
3 * @file stm32f4xx_fsmc.c
4 * @author MCD Application Team
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the FSMC peripheral:
9 * - Interface with SRAM, PSRAM, NOR and OneNAND memories
10 * - Interface with NAND memories
11 * - Interface with 16-bit PC Card compatible memories
12 * - Interrupts and flags management
14 ******************************************************************************
18 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
19 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
20 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
21 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
22 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
23 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
25 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
26 ******************************************************************************
29 /* Includes ------------------------------------------------------------------*/
30 #include "stm32f4xx_fsmc.h"
31 #include "stm32f4xx_rcc.h"
33 /** @addtogroup STM32F4xx_StdPeriph_Driver
38 * @brief FSMC driver modules
42 /* Private typedef -----------------------------------------------------------*/
43 /* Private define ------------------------------------------------------------*/
45 /* --------------------- FSMC registers bit mask ---------------------------- */
47 #define BCR_MBKEN_SET ((uint32_t)0x00000001)
48 #define BCR_MBKEN_RESET ((uint32_t)0x000FFFFE)
49 #define BCR_FACCEN_SET ((uint32_t)0x00000040)
52 #define PCR_PBKEN_SET ((uint32_t)0x00000004)
53 #define PCR_PBKEN_RESET ((uint32_t)0x000FFFFB)
54 #define PCR_ECCEN_SET ((uint32_t)0x00000040)
55 #define PCR_ECCEN_RESET ((uint32_t)0x000FFFBF)
56 #define PCR_MEMORYTYPE_NAND ((uint32_t)0x00000008)
58 /* Private macro -------------------------------------------------------------*/
59 /* Private variables ---------------------------------------------------------*/
60 /* Private function prototypes -----------------------------------------------*/
61 /* Private functions ---------------------------------------------------------*/
63 /** @defgroup FSMC_Private_Functions
67 /** @defgroup FSMC_Group1 NOR/SRAM Controller functions
68 * @brief NOR/SRAM Controller functions
71 ===============================================================================
72 NOR/SRAM Controller functions
73 ===============================================================================
75 The following sequence should be followed to configure the FSMC to interface with
76 SRAM, PSRAM, NOR or OneNAND memory connected to the NOR/SRAM Bank:
78 1. Enable the clock for the FSMC and associated GPIOs using the following functions:
79 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
80 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
82 2. FSMC pins configuration
83 - Connect the involved FSMC pins to AF12 using the following function
84 GPIO_PinAFConfig(GPIOx, GPIO_PinSourcex, GPIO_AF_FSMC);
85 - Configure these FSMC pins in alternate function mode by calling the function
88 3. Declare a FSMC_NORSRAMInitTypeDef structure, for example:
89 FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
90 and fill the FSMC_NORSRAMInitStructure variable with the allowed values of
93 4. Initialize the NOR/SRAM Controller by calling the function
94 FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
96 5. Then enable the NOR/SRAM Bank, for example:
97 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE);
99 6. At this stage you can read/write from/to the memory connected to the NOR/SRAM Bank.
106 * @brief Deinitializes the FSMC NOR/SRAM Banks registers to their default
108 * @param FSMC_Bank: specifies the FSMC Bank to be used
109 * This parameter can be one of the following values:
110 * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1
111 * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2
112 * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3
113 * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4
116 void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank)
118 /* Check the parameter */
119 assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
121 /* FSMC_Bank1_NORSRAM1 */
122 if(FSMC_Bank == FSMC_Bank1_NORSRAM1)
124 FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030DB;
126 /* FSMC_Bank1_NORSRAM2, FSMC_Bank1_NORSRAM3 or FSMC_Bank1_NORSRAM4 */
129 FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030D2;
131 FSMC_Bank1->BTCR[FSMC_Bank + 1] = 0x0FFFFFFF;
132 FSMC_Bank1E->BWTR[FSMC_Bank] = 0x0FFFFFFF;
136 * @brief Initializes the FSMC NOR/SRAM Banks according to the specified
137 * parameters in the FSMC_NORSRAMInitStruct.
138 * @param FSMC_NORSRAMInitStruct : pointer to a FSMC_NORSRAMInitTypeDef structure
139 * that contains the configuration information for the FSMC NOR/SRAM
143 void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct)
145 /* Check the parameters */
146 assert_param(IS_FSMC_NORSRAM_BANK(FSMC_NORSRAMInitStruct->FSMC_Bank));
147 assert_param(IS_FSMC_MUX(FSMC_NORSRAMInitStruct->FSMC_DataAddressMux));
148 assert_param(IS_FSMC_MEMORY(FSMC_NORSRAMInitStruct->FSMC_MemoryType));
149 assert_param(IS_FSMC_MEMORY_WIDTH(FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth));
150 assert_param(IS_FSMC_BURSTMODE(FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode));
151 assert_param(IS_FSMC_ASYNWAIT(FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait));
152 assert_param(IS_FSMC_WAIT_POLARITY(FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity));
153 assert_param(IS_FSMC_WRAP_MODE(FSMC_NORSRAMInitStruct->FSMC_WrapMode));
154 assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive));
155 assert_param(IS_FSMC_WRITE_OPERATION(FSMC_NORSRAMInitStruct->FSMC_WriteOperation));
156 assert_param(IS_FSMC_WAITE_SIGNAL(FSMC_NORSRAMInitStruct->FSMC_WaitSignal));
157 assert_param(IS_FSMC_EXTENDED_MODE(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode));
158 assert_param(IS_FSMC_WRITE_BURST(FSMC_NORSRAMInitStruct->FSMC_WriteBurst));
159 assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime));
160 assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime));
161 assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime));
162 assert_param(IS_FSMC_TURNAROUND_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration));
163 assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision));
164 assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency));
165 assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode));
167 /* Bank1 NOR/SRAM control register configuration */
168 FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] =
169 (uint32_t)FSMC_NORSRAMInitStruct->FSMC_DataAddressMux |
170 FSMC_NORSRAMInitStruct->FSMC_MemoryType |
171 FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth |
172 FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode |
173 FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait |
174 FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity |
175 FSMC_NORSRAMInitStruct->FSMC_WrapMode |
176 FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive |
177 FSMC_NORSRAMInitStruct->FSMC_WriteOperation |
178 FSMC_NORSRAMInitStruct->FSMC_WaitSignal |
179 FSMC_NORSRAMInitStruct->FSMC_ExtendedMode |
180 FSMC_NORSRAMInitStruct->FSMC_WriteBurst;
181 if(FSMC_NORSRAMInitStruct->FSMC_MemoryType == FSMC_MemoryType_NOR)
183 FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] |= (uint32_t)BCR_FACCEN_SET;
185 /* Bank1 NOR/SRAM timing register configuration */
186 FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank+1] =
187 (uint32_t)FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime |
188 (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime << 4) |
189 (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime << 8) |
190 (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration << 16) |
191 (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision << 20) |
192 (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency << 24) |
193 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode;
196 /* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */
197 if(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode == FSMC_ExtendedMode_Enable)
199 assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime));
200 assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime));
201 assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime));
202 assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision));
203 assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency));
204 assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode));
205 FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] =
206 (uint32_t)FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime |
207 (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime << 4 )|
208 (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime << 8) |
209 (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision << 20) |
210 (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency << 24) |
211 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode;
215 FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = 0x0FFFFFFF;
220 * @brief Fills each FSMC_NORSRAMInitStruct member with its default value.
221 * @param FSMC_NORSRAMInitStruct: pointer to a FSMC_NORSRAMInitTypeDef structure
222 * which will be initialized.
225 void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct)
227 /* Reset NOR/SRAM Init structure parameters values */
228 FSMC_NORSRAMInitStruct->FSMC_Bank = FSMC_Bank1_NORSRAM1;
229 FSMC_NORSRAMInitStruct->FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;
230 FSMC_NORSRAMInitStruct->FSMC_MemoryType = FSMC_MemoryType_SRAM;
231 FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
232 FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
233 FSMC_NORSRAMInitStruct->FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
234 FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
235 FSMC_NORSRAMInitStruct->FSMC_WrapMode = FSMC_WrapMode_Disable;
236 FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
237 FSMC_NORSRAMInitStruct->FSMC_WriteOperation = FSMC_WriteOperation_Enable;
238 FSMC_NORSRAMInitStruct->FSMC_WaitSignal = FSMC_WaitSignal_Enable;
239 FSMC_NORSRAMInitStruct->FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
240 FSMC_NORSRAMInitStruct->FSMC_WriteBurst = FSMC_WriteBurst_Disable;
241 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime = 0xF;
242 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime = 0xF;
243 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime = 0xFF;
244 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF;
245 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision = 0xF;
246 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency = 0xF;
247 FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A;
248 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime = 0xF;
249 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime = 0xF;
250 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime = 0xFF;
251 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF;
252 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision = 0xF;
253 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency = 0xF;
254 FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A;
258 * @brief Enables or disables the specified NOR/SRAM Memory Bank.
259 * @param FSMC_Bank: specifies the FSMC Bank to be used
260 * This parameter can be one of the following values:
261 * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1
262 * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2
263 * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3
264 * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4
265 * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE.
268 void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState)
270 assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
271 assert_param(IS_FUNCTIONAL_STATE(NewState));
273 if (NewState != DISABLE)
275 /* Enable the selected NOR/SRAM Bank by setting the PBKEN bit in the BCRx register */
276 FSMC_Bank1->BTCR[FSMC_Bank] |= BCR_MBKEN_SET;
280 /* Disable the selected NOR/SRAM Bank by clearing the PBKEN bit in the BCRx register */
281 FSMC_Bank1->BTCR[FSMC_Bank] &= BCR_MBKEN_RESET;
288 /** @defgroup FSMC_Group2 NAND Controller functions
289 * @brief NAND Controller functions
292 ===============================================================================
293 NAND Controller functions
294 ===============================================================================
296 The following sequence should be followed to configure the FSMC to interface with
297 8-bit or 16-bit NAND memory connected to the NAND Bank:
299 1. Enable the clock for the FSMC and associated GPIOs using the following functions:
300 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
301 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
303 2. FSMC pins configuration
304 - Connect the involved FSMC pins to AF12 using the following function
305 GPIO_PinAFConfig(GPIOx, GPIO_PinSourcex, GPIO_AF_FSMC);
306 - Configure these FSMC pins in alternate function mode by calling the function
309 3. Declare a FSMC_NANDInitTypeDef structure, for example:
310 FSMC_NANDInitTypeDef FSMC_NANDInitStructure;
311 and fill the FSMC_NANDInitStructure variable with the allowed values of
312 the structure member.
314 4. Initialize the NAND Controller by calling the function
315 FSMC_NANDInit(&FSMC_NANDInitStructure);
317 5. Then enable the NAND Bank, for example:
318 FSMC_NANDCmd(FSMC_Bank3_NAND, ENABLE);
320 6. At this stage you can read/write from/to the memory connected to the NAND Bank.
322 @note To enable the Error Correction Code (ECC), you have to use the function
323 FSMC_NANDECCCmd(FSMC_Bank3_NAND, ENABLE);
324 and to get the current ECC value you have to use the function
325 ECCval = FSMC_GetECC(FSMC_Bank3_NAND);
332 * @brief Deinitializes the FSMC NAND Banks registers to their default reset values.
333 * @param FSMC_Bank: specifies the FSMC Bank to be used
334 * This parameter can be one of the following values:
335 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
336 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
339 void FSMC_NANDDeInit(uint32_t FSMC_Bank)
341 /* Check the parameter */
342 assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
344 if(FSMC_Bank == FSMC_Bank2_NAND)
346 /* Set the FSMC_Bank2 registers to their reset values */
347 FSMC_Bank2->PCR2 = 0x00000018;
348 FSMC_Bank2->SR2 = 0x00000040;
349 FSMC_Bank2->PMEM2 = 0xFCFCFCFC;
350 FSMC_Bank2->PATT2 = 0xFCFCFCFC;
352 /* FSMC_Bank3_NAND */
355 /* Set the FSMC_Bank3 registers to their reset values */
356 FSMC_Bank3->PCR3 = 0x00000018;
357 FSMC_Bank3->SR3 = 0x00000040;
358 FSMC_Bank3->PMEM3 = 0xFCFCFCFC;
359 FSMC_Bank3->PATT3 = 0xFCFCFCFC;
364 * @brief Initializes the FSMC NAND Banks according to the specified parameters
365 * in the FSMC_NANDInitStruct.
366 * @param FSMC_NANDInitStruct : pointer to a FSMC_NANDInitTypeDef structure that
367 * contains the configuration information for the FSMC NAND specified Banks.
370 void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct)
372 uint32_t tmppcr = 0x00000000, tmppmem = 0x00000000, tmppatt = 0x00000000;
374 /* Check the parameters */
375 assert_param( IS_FSMC_NAND_BANK(FSMC_NANDInitStruct->FSMC_Bank));
376 assert_param( IS_FSMC_WAIT_FEATURE(FSMC_NANDInitStruct->FSMC_Waitfeature));
377 assert_param( IS_FSMC_MEMORY_WIDTH(FSMC_NANDInitStruct->FSMC_MemoryDataWidth));
378 assert_param( IS_FSMC_ECC_STATE(FSMC_NANDInitStruct->FSMC_ECC));
379 assert_param( IS_FSMC_ECCPAGE_SIZE(FSMC_NANDInitStruct->FSMC_ECCPageSize));
380 assert_param( IS_FSMC_TCLR_TIME(FSMC_NANDInitStruct->FSMC_TCLRSetupTime));
381 assert_param( IS_FSMC_TAR_TIME(FSMC_NANDInitStruct->FSMC_TARSetupTime));
382 assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime));
383 assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime));
384 assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime));
385 assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime));
386 assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime));
387 assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime));
388 assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime));
389 assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime));
391 /* Set the tmppcr value according to FSMC_NANDInitStruct parameters */
392 tmppcr = (uint32_t)FSMC_NANDInitStruct->FSMC_Waitfeature |
393 PCR_MEMORYTYPE_NAND |
394 FSMC_NANDInitStruct->FSMC_MemoryDataWidth |
395 FSMC_NANDInitStruct->FSMC_ECC |
396 FSMC_NANDInitStruct->FSMC_ECCPageSize |
397 (FSMC_NANDInitStruct->FSMC_TCLRSetupTime << 9 )|
398 (FSMC_NANDInitStruct->FSMC_TARSetupTime << 13);
400 /* Set tmppmem value according to FSMC_CommonSpaceTimingStructure parameters */
401 tmppmem = (uint32_t)FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime |
402 (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
403 (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
404 (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24);
406 /* Set tmppatt value according to FSMC_AttributeSpaceTimingStructure parameters */
407 tmppatt = (uint32_t)FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime |
408 (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
409 (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
410 (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24);
412 if(FSMC_NANDInitStruct->FSMC_Bank == FSMC_Bank2_NAND)
414 /* FSMC_Bank2_NAND registers configuration */
415 FSMC_Bank2->PCR2 = tmppcr;
416 FSMC_Bank2->PMEM2 = tmppmem;
417 FSMC_Bank2->PATT2 = tmppatt;
421 /* FSMC_Bank3_NAND registers configuration */
422 FSMC_Bank3->PCR3 = tmppcr;
423 FSMC_Bank3->PMEM3 = tmppmem;
424 FSMC_Bank3->PATT3 = tmppatt;
430 * @brief Fills each FSMC_NANDInitStruct member with its default value.
431 * @param FSMC_NANDInitStruct: pointer to a FSMC_NANDInitTypeDef structure which
432 * will be initialized.
435 void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct)
437 /* Reset NAND Init structure parameters values */
438 FSMC_NANDInitStruct->FSMC_Bank = FSMC_Bank2_NAND;
439 FSMC_NANDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable;
440 FSMC_NANDInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
441 FSMC_NANDInitStruct->FSMC_ECC = FSMC_ECC_Disable;
442 FSMC_NANDInitStruct->FSMC_ECCPageSize = FSMC_ECCPageSize_256Bytes;
443 FSMC_NANDInitStruct->FSMC_TCLRSetupTime = 0x0;
444 FSMC_NANDInitStruct->FSMC_TARSetupTime = 0x0;
445 FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC;
446 FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
447 FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
448 FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
449 FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC;
450 FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
451 FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
452 FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
456 * @brief Enables or disables the specified NAND Memory Bank.
457 * @param FSMC_Bank: specifies the FSMC Bank to be used
458 * This parameter can be one of the following values:
459 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
460 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
461 * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE.
464 void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState)
466 assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
467 assert_param(IS_FUNCTIONAL_STATE(NewState));
469 if (NewState != DISABLE)
471 /* Enable the selected NAND Bank by setting the PBKEN bit in the PCRx register */
472 if(FSMC_Bank == FSMC_Bank2_NAND)
474 FSMC_Bank2->PCR2 |= PCR_PBKEN_SET;
478 FSMC_Bank3->PCR3 |= PCR_PBKEN_SET;
483 /* Disable the selected NAND Bank by clearing the PBKEN bit in the PCRx register */
484 if(FSMC_Bank == FSMC_Bank2_NAND)
486 FSMC_Bank2->PCR2 &= PCR_PBKEN_RESET;
490 FSMC_Bank3->PCR3 &= PCR_PBKEN_RESET;
495 * @brief Enables or disables the FSMC NAND ECC feature.
496 * @param FSMC_Bank: specifies the FSMC Bank to be used
497 * This parameter can be one of the following values:
498 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
499 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
500 * @param NewState: new state of the FSMC NAND ECC feature.
501 * This parameter can be: ENABLE or DISABLE.
504 void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState)
506 assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
507 assert_param(IS_FUNCTIONAL_STATE(NewState));
509 if (NewState != DISABLE)
511 /* Enable the selected NAND Bank ECC function by setting the ECCEN bit in the PCRx register */
512 if(FSMC_Bank == FSMC_Bank2_NAND)
514 FSMC_Bank2->PCR2 |= PCR_ECCEN_SET;
518 FSMC_Bank3->PCR3 |= PCR_ECCEN_SET;
523 /* Disable the selected NAND Bank ECC function by clearing the ECCEN bit in the PCRx register */
524 if(FSMC_Bank == FSMC_Bank2_NAND)
526 FSMC_Bank2->PCR2 &= PCR_ECCEN_RESET;
530 FSMC_Bank3->PCR3 &= PCR_ECCEN_RESET;
536 * @brief Returns the error correction code register value.
537 * @param FSMC_Bank: specifies the FSMC Bank to be used
538 * This parameter can be one of the following values:
539 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
540 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
541 * @retval The Error Correction Code (ECC) value.
543 uint32_t FSMC_GetECC(uint32_t FSMC_Bank)
545 uint32_t eccval = 0x00000000;
547 if(FSMC_Bank == FSMC_Bank2_NAND)
549 /* Get the ECCR2 register value */
550 eccval = FSMC_Bank2->ECCR2;
554 /* Get the ECCR3 register value */
555 eccval = FSMC_Bank3->ECCR3;
557 /* Return the error correction code value */
564 /** @defgroup FSMC_Group3 PCCARD Controller functions
565 * @brief PCCARD Controller functions
568 ===============================================================================
569 PCCARD Controller functions
570 ===============================================================================
572 The following sequence should be followed to configure the FSMC to interface with
573 16-bit PC Card compatible memory connected to the PCCARD Bank:
575 1. Enable the clock for the FSMC and associated GPIOs using the following functions:
576 RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
577 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOx, ENABLE);
579 2. FSMC pins configuration
580 - Connect the involved FSMC pins to AF12 using the following function
581 GPIO_PinAFConfig(GPIOx, GPIO_PinSourcex, GPIO_AF_FSMC);
582 - Configure these FSMC pins in alternate function mode by calling the function
585 3. Declare a FSMC_PCCARDInitTypeDef structure, for example:
586 FSMC_PCCARDInitTypeDef FSMC_PCCARDInitStructure;
587 and fill the FSMC_PCCARDInitStructure variable with the allowed values of
588 the structure member.
590 4. Initialize the PCCARD Controller by calling the function
591 FSMC_PCCARDInit(&FSMC_PCCARDInitStructure);
593 5. Then enable the PCCARD Bank:
594 FSMC_PCCARDCmd(ENABLE);
596 6. At this stage you can read/write from/to the memory connected to the PCCARD Bank.
603 * @brief Deinitializes the FSMC PCCARD Bank registers to their default reset values.
607 void FSMC_PCCARDDeInit(void)
609 /* Set the FSMC_Bank4 registers to their reset values */
610 FSMC_Bank4->PCR4 = 0x00000018;
611 FSMC_Bank4->SR4 = 0x00000000;
612 FSMC_Bank4->PMEM4 = 0xFCFCFCFC;
613 FSMC_Bank4->PATT4 = 0xFCFCFCFC;
614 FSMC_Bank4->PIO4 = 0xFCFCFCFC;
618 * @brief Initializes the FSMC PCCARD Bank according to the specified parameters
619 * in the FSMC_PCCARDInitStruct.
620 * @param FSMC_PCCARDInitStruct : pointer to a FSMC_PCCARDInitTypeDef structure
621 * that contains the configuration information for the FSMC PCCARD Bank.
624 void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct)
626 /* Check the parameters */
627 assert_param(IS_FSMC_WAIT_FEATURE(FSMC_PCCARDInitStruct->FSMC_Waitfeature));
628 assert_param(IS_FSMC_TCLR_TIME(FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime));
629 assert_param(IS_FSMC_TAR_TIME(FSMC_PCCARDInitStruct->FSMC_TARSetupTime));
631 assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime));
632 assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime));
633 assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime));
634 assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime));
636 assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime));
637 assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime));
638 assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime));
639 assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime));
640 assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime));
641 assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime));
642 assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime));
643 assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime));
645 /* Set the PCR4 register value according to FSMC_PCCARDInitStruct parameters */
646 FSMC_Bank4->PCR4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_Waitfeature |
647 FSMC_MemoryDataWidth_16b |
648 (FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime << 9) |
649 (FSMC_PCCARDInitStruct->FSMC_TARSetupTime << 13);
651 /* Set PMEM4 register value according to FSMC_CommonSpaceTimingStructure parameters */
652 FSMC_Bank4->PMEM4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime |
653 (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
654 (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
655 (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24);
657 /* Set PATT4 register value according to FSMC_AttributeSpaceTimingStructure parameters */
658 FSMC_Bank4->PATT4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime |
659 (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
660 (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
661 (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24);
663 /* Set PIO4 register value according to FSMC_IOSpaceTimingStructure parameters */
664 FSMC_Bank4->PIO4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime |
665 (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
666 (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
667 (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime << 24);
671 * @brief Fills each FSMC_PCCARDInitStruct member with its default value.
672 * @param FSMC_PCCARDInitStruct: pointer to a FSMC_PCCARDInitTypeDef structure
673 * which will be initialized.
676 void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct)
678 /* Reset PCCARD Init structure parameters values */
679 FSMC_PCCARDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable;
680 FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime = 0x0;
681 FSMC_PCCARDInitStruct->FSMC_TARSetupTime = 0x0;
682 FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC;
683 FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
684 FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
685 FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
686 FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC;
687 FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
688 FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
689 FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
690 FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime = 0xFC;
691 FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
692 FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
693 FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
697 * @brief Enables or disables the PCCARD Memory Bank.
698 * @param NewState: new state of the PCCARD Memory Bank.
699 * This parameter can be: ENABLE or DISABLE.
702 void FSMC_PCCARDCmd(FunctionalState NewState)
704 assert_param(IS_FUNCTIONAL_STATE(NewState));
706 if (NewState != DISABLE)
708 /* Enable the PCCARD Bank by setting the PBKEN bit in the PCR4 register */
709 FSMC_Bank4->PCR4 |= PCR_PBKEN_SET;
713 /* Disable the PCCARD Bank by clearing the PBKEN bit in the PCR4 register */
714 FSMC_Bank4->PCR4 &= PCR_PBKEN_RESET;
721 /** @defgroup FSMC_Group4 Interrupts and flags management functions
722 * @brief Interrupts and flags management functions
725 ===============================================================================
726 Interrupts and flags management functions
727 ===============================================================================
734 * @brief Enables or disables the specified FSMC interrupts.
735 * @param FSMC_Bank: specifies the FSMC Bank to be used
736 * This parameter can be one of the following values:
737 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
738 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
739 * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
740 * @param FSMC_IT: specifies the FSMC interrupt sources to be enabled or disabled.
741 * This parameter can be any combination of the following values:
742 * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
743 * @arg FSMC_IT_Level: Level edge detection interrupt.
744 * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
745 * @param NewState: new state of the specified FSMC interrupts.
746 * This parameter can be: ENABLE or DISABLE.
749 void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState)
751 assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
752 assert_param(IS_FSMC_IT(FSMC_IT));
753 assert_param(IS_FUNCTIONAL_STATE(NewState));
755 if (NewState != DISABLE)
757 /* Enable the selected FSMC_Bank2 interrupts */
758 if(FSMC_Bank == FSMC_Bank2_NAND)
760 FSMC_Bank2->SR2 |= FSMC_IT;
762 /* Enable the selected FSMC_Bank3 interrupts */
763 else if (FSMC_Bank == FSMC_Bank3_NAND)
765 FSMC_Bank3->SR3 |= FSMC_IT;
767 /* Enable the selected FSMC_Bank4 interrupts */
770 FSMC_Bank4->SR4 |= FSMC_IT;
775 /* Disable the selected FSMC_Bank2 interrupts */
776 if(FSMC_Bank == FSMC_Bank2_NAND)
779 FSMC_Bank2->SR2 &= (uint32_t)~FSMC_IT;
781 /* Disable the selected FSMC_Bank3 interrupts */
782 else if (FSMC_Bank == FSMC_Bank3_NAND)
784 FSMC_Bank3->SR3 &= (uint32_t)~FSMC_IT;
786 /* Disable the selected FSMC_Bank4 interrupts */
789 FSMC_Bank4->SR4 &= (uint32_t)~FSMC_IT;
795 * @brief Checks whether the specified FSMC flag is set or not.
796 * @param FSMC_Bank: specifies the FSMC Bank to be used
797 * This parameter can be one of the following values:
798 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
799 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
800 * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
801 * @param FSMC_FLAG: specifies the flag to check.
802 * This parameter can be one of the following values:
803 * @arg FSMC_FLAG_RisingEdge: Rising edge detection Flag.
804 * @arg FSMC_FLAG_Level: Level detection Flag.
805 * @arg FSMC_FLAG_FallingEdge: Falling edge detection Flag.
806 * @arg FSMC_FLAG_FEMPT: Fifo empty Flag.
807 * @retval The new state of FSMC_FLAG (SET or RESET).
809 FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG)
811 FlagStatus bitstatus = RESET;
812 uint32_t tmpsr = 0x00000000;
814 /* Check the parameters */
815 assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
816 assert_param(IS_FSMC_GET_FLAG(FSMC_FLAG));
818 if(FSMC_Bank == FSMC_Bank2_NAND)
820 tmpsr = FSMC_Bank2->SR2;
822 else if(FSMC_Bank == FSMC_Bank3_NAND)
824 tmpsr = FSMC_Bank3->SR3;
826 /* FSMC_Bank4_PCCARD*/
829 tmpsr = FSMC_Bank4->SR4;
832 /* Get the flag status */
833 if ((tmpsr & FSMC_FLAG) != (uint16_t)RESET )
841 /* Return the flag status */
846 * @brief Clears the FSMC's pending flags.
847 * @param FSMC_Bank: specifies the FSMC Bank to be used
848 * This parameter can be one of the following values:
849 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
850 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
851 * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
852 * @param FSMC_FLAG: specifies the flag to clear.
853 * This parameter can be any combination of the following values:
854 * @arg FSMC_FLAG_RisingEdge: Rising edge detection Flag.
855 * @arg FSMC_FLAG_Level: Level detection Flag.
856 * @arg FSMC_FLAG_FallingEdge: Falling edge detection Flag.
859 void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG)
861 /* Check the parameters */
862 assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
863 assert_param(IS_FSMC_CLEAR_FLAG(FSMC_FLAG)) ;
865 if(FSMC_Bank == FSMC_Bank2_NAND)
867 FSMC_Bank2->SR2 &= ~FSMC_FLAG;
869 else if(FSMC_Bank == FSMC_Bank3_NAND)
871 FSMC_Bank3->SR3 &= ~FSMC_FLAG;
873 /* FSMC_Bank4_PCCARD*/
876 FSMC_Bank4->SR4 &= ~FSMC_FLAG;
881 * @brief Checks whether the specified FSMC interrupt has occurred or not.
882 * @param FSMC_Bank: specifies the FSMC Bank to be used
883 * This parameter can be one of the following values:
884 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
885 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
886 * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
887 * @param FSMC_IT: specifies the FSMC interrupt source to check.
888 * This parameter can be one of the following values:
889 * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
890 * @arg FSMC_IT_Level: Level edge detection interrupt.
891 * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
892 * @retval The new state of FSMC_IT (SET or RESET).
894 ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT)
896 ITStatus bitstatus = RESET;
897 uint32_t tmpsr = 0x0, itstatus = 0x0, itenable = 0x0;
899 /* Check the parameters */
900 assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
901 assert_param(IS_FSMC_GET_IT(FSMC_IT));
903 if(FSMC_Bank == FSMC_Bank2_NAND)
905 tmpsr = FSMC_Bank2->SR2;
907 else if(FSMC_Bank == FSMC_Bank3_NAND)
909 tmpsr = FSMC_Bank3->SR3;
911 /* FSMC_Bank4_PCCARD*/
914 tmpsr = FSMC_Bank4->SR4;
917 itstatus = tmpsr & FSMC_IT;
919 itenable = tmpsr & (FSMC_IT >> 3);
920 if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET))
932 * @brief Clears the FSMC's interrupt pending bits.
933 * @param FSMC_Bank: specifies the FSMC Bank to be used
934 * This parameter can be one of the following values:
935 * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
936 * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
937 * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
938 * @param FSMC_IT: specifies the interrupt pending bit to clear.
939 * This parameter can be any combination of the following values:
940 * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
941 * @arg FSMC_IT_Level: Level edge detection interrupt.
942 * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
945 void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT)
947 /* Check the parameters */
948 assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
949 assert_param(IS_FSMC_IT(FSMC_IT));
951 if(FSMC_Bank == FSMC_Bank2_NAND)
953 FSMC_Bank2->SR2 &= ~(FSMC_IT >> 3);
955 else if(FSMC_Bank == FSMC_Bank3_NAND)
957 FSMC_Bank3->SR3 &= ~(FSMC_IT >> 3);
959 /* FSMC_Bank4_PCCARD*/
962 FSMC_Bank4->SR4 &= ~(FSMC_IT >> 3);
982 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/