stm32f10x_fsmc.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859
  1. /**
  2. ******************************************************************************
  3. * @file stm32f10x_fsmc.c
  4. * @author MCD Application Team
  5. * @version V3.3.0
  6. * @date 04/16/2010
  7. * @brief This file provides all the FSMC firmware functions.
  8. ******************************************************************************
  9. * @copy
  10. *
  11. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  12. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  13. * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  14. * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  15. * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  16. * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  17. *
  18. * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
  19. */
  20. /* Includes ------------------------------------------------------------------*/
  21. #include "stm32f10x_fsmc.h"
  22. #include "stm32f10x_rcc.h"
  23. /** @addtogroup STM32F10x_StdPeriph_Driver
  24. * @{
  25. */
  26. /** @defgroup FSMC
  27. * @brief FSMC driver modules
  28. * @{
  29. */
  30. /** @defgroup FSMC_Private_TypesDefinitions
  31. * @{
  32. */
  33. /**
  34. * @}
  35. */
  36. /** @defgroup FSMC_Private_Defines
  37. * @{
  38. */
  39. /* --------------------- FSMC registers bit mask ---------------------------- */
  40. /* FSMC BCRx Mask */
  41. #define BCR_MBKEN_Set ((uint32_t)0x00000001)
  42. #define BCR_MBKEN_Reset ((uint32_t)0x000FFFFE)
  43. #define BCR_FACCEN_Set ((uint32_t)0x00000040)
  44. /* FSMC PCRx Mask */
  45. #define PCR_PBKEN_Set ((uint32_t)0x00000004)
  46. #define PCR_PBKEN_Reset ((uint32_t)0x000FFFFB)
  47. #define PCR_ECCEN_Set ((uint32_t)0x00000040)
  48. #define PCR_ECCEN_Reset ((uint32_t)0x000FFFBF)
  49. #define PCR_MemoryType_NAND ((uint32_t)0x00000008)
  50. /**
  51. * @}
  52. */
  53. /** @defgroup FSMC_Private_Macros
  54. * @{
  55. */
  56. /**
  57. * @}
  58. */
  59. /** @defgroup FSMC_Private_Variables
  60. * @{
  61. */
  62. /**
  63. * @}
  64. */
  65. /** @defgroup FSMC_Private_FunctionPrototypes
  66. * @{
  67. */
  68. /**
  69. * @}
  70. */
  71. /** @defgroup FSMC_Private_Functions
  72. * @{
  73. */
  74. /**
  75. * @brief Deinitializes the FSMC NOR/SRAM Banks registers to their default
  76. * reset values.
  77. * @param FSMC_Bank: specifies the FSMC Bank to be used
  78. * This parameter can be one of the following values:
  79. * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1
  80. * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2
  81. * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3
  82. * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4
  83. * @retval None
  84. */
  85. void FSMC_NORSRAMDeInit(uint32_t FSMC_Bank)
  86. {
  87. /* Check the parameter */
  88. assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
  89. /* FSMC_Bank1_NORSRAM1 */
  90. if(FSMC_Bank == FSMC_Bank1_NORSRAM1)
  91. {
  92. FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030DB;
  93. }
  94. /* FSMC_Bank1_NORSRAM2, FSMC_Bank1_NORSRAM3 or FSMC_Bank1_NORSRAM4 */
  95. else
  96. {
  97. FSMC_Bank1->BTCR[FSMC_Bank] = 0x000030D2;
  98. }
  99. FSMC_Bank1->BTCR[FSMC_Bank + 1] = 0x0FFFFFFF;
  100. FSMC_Bank1E->BWTR[FSMC_Bank] = 0x0FFFFFFF;
  101. }
  102. /**
  103. * @brief Deinitializes the FSMC NAND Banks registers to their default reset values.
  104. * @param FSMC_Bank: specifies the FSMC Bank to be used
  105. * This parameter can be one of the following values:
  106. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  107. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  108. * @retval None
  109. */
  110. void FSMC_NANDDeInit(uint32_t FSMC_Bank)
  111. {
  112. /* Check the parameter */
  113. assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
  114. if(FSMC_Bank == FSMC_Bank2_NAND)
  115. {
  116. /* Set the FSMC_Bank2 registers to their reset values */
  117. FSMC_Bank2->PCR2 = 0x00000018;
  118. FSMC_Bank2->SR2 = 0x00000040;
  119. FSMC_Bank2->PMEM2 = 0xFCFCFCFC;
  120. FSMC_Bank2->PATT2 = 0xFCFCFCFC;
  121. }
  122. /* FSMC_Bank3_NAND */
  123. else
  124. {
  125. /* Set the FSMC_Bank3 registers to their reset values */
  126. FSMC_Bank3->PCR3 = 0x00000018;
  127. FSMC_Bank3->SR3 = 0x00000040;
  128. FSMC_Bank3->PMEM3 = 0xFCFCFCFC;
  129. FSMC_Bank3->PATT3 = 0xFCFCFCFC;
  130. }
  131. }
  132. /**
  133. * @brief Deinitializes the FSMC PCCARD Bank registers to their default reset values.
  134. * @param None
  135. * @retval None
  136. */
  137. void FSMC_PCCARDDeInit(void)
  138. {
  139. /* Set the FSMC_Bank4 registers to their reset values */
  140. FSMC_Bank4->PCR4 = 0x00000018;
  141. FSMC_Bank4->SR4 = 0x00000000;
  142. FSMC_Bank4->PMEM4 = 0xFCFCFCFC;
  143. FSMC_Bank4->PATT4 = 0xFCFCFCFC;
  144. FSMC_Bank4->PIO4 = 0xFCFCFCFC;
  145. }
  146. /**
  147. * @brief Initializes the FSMC NOR/SRAM Banks according to the specified
  148. * parameters in the FSMC_NORSRAMInitStruct.
  149. * @param FSMC_NORSRAMInitStruct : pointer to a FSMC_NORSRAMInitTypeDef
  150. * structure that contains the configuration information for
  151. * the FSMC NOR/SRAM specified Banks.
  152. * @retval None
  153. */
  154. void FSMC_NORSRAMInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct)
  155. {
  156. /* Check the parameters */
  157. assert_param(IS_FSMC_NORSRAM_BANK(FSMC_NORSRAMInitStruct->FSMC_Bank));
  158. assert_param(IS_FSMC_MUX(FSMC_NORSRAMInitStruct->FSMC_DataAddressMux));
  159. assert_param(IS_FSMC_MEMORY(FSMC_NORSRAMInitStruct->FSMC_MemoryType));
  160. assert_param(IS_FSMC_MEMORY_WIDTH(FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth));
  161. assert_param(IS_FSMC_BURSTMODE(FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode));
  162. assert_param(IS_FSMC_WAIT_POLARITY(FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity));
  163. assert_param(IS_FSMC_WRAP_MODE(FSMC_NORSRAMInitStruct->FSMC_WrapMode));
  164. assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive));
  165. assert_param(IS_FSMC_WRITE_OPERATION(FSMC_NORSRAMInitStruct->FSMC_WriteOperation));
  166. assert_param(IS_FSMC_WAITE_SIGNAL(FSMC_NORSRAMInitStruct->FSMC_WaitSignal));
  167. assert_param(IS_FSMC_EXTENDED_MODE(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode));
  168. assert_param(IS_FSMC_WRITE_BURST(FSMC_NORSRAMInitStruct->FSMC_WriteBurst));
  169. assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime));
  170. assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime));
  171. assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime));
  172. assert_param(IS_FSMC_TURNAROUND_TIME(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration));
  173. assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision));
  174. assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency));
  175. assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode));
  176. /* Bank1 NOR/SRAM control register configuration */
  177. FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] =
  178. (uint32_t)FSMC_NORSRAMInitStruct->FSMC_DataAddressMux |
  179. FSMC_NORSRAMInitStruct->FSMC_MemoryType |
  180. FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth |
  181. FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode |
  182. FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity |
  183. FSMC_NORSRAMInitStruct->FSMC_WrapMode |
  184. FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive |
  185. FSMC_NORSRAMInitStruct->FSMC_WriteOperation |
  186. FSMC_NORSRAMInitStruct->FSMC_WaitSignal |
  187. FSMC_NORSRAMInitStruct->FSMC_ExtendedMode |
  188. FSMC_NORSRAMInitStruct->FSMC_WriteBurst;
  189. if(FSMC_NORSRAMInitStruct->FSMC_MemoryType == FSMC_MemoryType_NOR)
  190. {
  191. FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank] |= (uint32_t)BCR_FACCEN_Set;
  192. }
  193. /* Bank1 NOR/SRAM timing register configuration */
  194. FSMC_Bank1->BTCR[FSMC_NORSRAMInitStruct->FSMC_Bank+1] =
  195. (uint32_t)FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime |
  196. (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime << 4) |
  197. (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime << 8) |
  198. (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration << 16) |
  199. (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision << 20) |
  200. (FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency << 24) |
  201. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode;
  202. /* Bank1 NOR/SRAM timing register for write configuration, if extended mode is used */
  203. if(FSMC_NORSRAMInitStruct->FSMC_ExtendedMode == FSMC_ExtendedMode_Enable)
  204. {
  205. assert_param(IS_FSMC_ADDRESS_SETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime));
  206. assert_param(IS_FSMC_ADDRESS_HOLD_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime));
  207. assert_param(IS_FSMC_DATASETUP_TIME(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime));
  208. assert_param(IS_FSMC_CLK_DIV(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision));
  209. assert_param(IS_FSMC_DATA_LATENCY(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency));
  210. assert_param(IS_FSMC_ACCESS_MODE(FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode));
  211. FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] =
  212. (uint32_t)FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime |
  213. (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime << 4 )|
  214. (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime << 8) |
  215. (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision << 20) |
  216. (FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency << 24) |
  217. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode;
  218. }
  219. else
  220. {
  221. FSMC_Bank1E->BWTR[FSMC_NORSRAMInitStruct->FSMC_Bank] = 0x0FFFFFFF;
  222. }
  223. }
  224. /**
  225. * @brief Initializes the FSMC NAND Banks according to the specified
  226. * parameters in the FSMC_NANDInitStruct.
  227. * @param FSMC_NANDInitStruct : pointer to a FSMC_NANDInitTypeDef
  228. * structure that contains the configuration information for the FSMC NAND specified Banks.
  229. * @retval None
  230. */
  231. void FSMC_NANDInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct)
  232. {
  233. uint32_t tmppcr = 0x00000000, tmppmem = 0x00000000, tmppatt = 0x00000000;
  234. /* Check the parameters */
  235. assert_param( IS_FSMC_NAND_BANK(FSMC_NANDInitStruct->FSMC_Bank));
  236. assert_param( IS_FSMC_WAIT_FEATURE(FSMC_NANDInitStruct->FSMC_Waitfeature));
  237. assert_param( IS_FSMC_MEMORY_WIDTH(FSMC_NANDInitStruct->FSMC_MemoryDataWidth));
  238. assert_param( IS_FSMC_ECC_STATE(FSMC_NANDInitStruct->FSMC_ECC));
  239. assert_param( IS_FSMC_ECCPAGE_SIZE(FSMC_NANDInitStruct->FSMC_ECCPageSize));
  240. assert_param( IS_FSMC_TCLR_TIME(FSMC_NANDInitStruct->FSMC_TCLRSetupTime));
  241. assert_param( IS_FSMC_TAR_TIME(FSMC_NANDInitStruct->FSMC_TARSetupTime));
  242. assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime));
  243. assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime));
  244. assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime));
  245. assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime));
  246. assert_param(IS_FSMC_SETUP_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime));
  247. assert_param(IS_FSMC_WAIT_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime));
  248. assert_param(IS_FSMC_HOLD_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime));
  249. assert_param(IS_FSMC_HIZ_TIME(FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime));
  250. /* Set the tmppcr value according to FSMC_NANDInitStruct parameters */
  251. tmppcr = (uint32_t)FSMC_NANDInitStruct->FSMC_Waitfeature |
  252. PCR_MemoryType_NAND |
  253. FSMC_NANDInitStruct->FSMC_MemoryDataWidth |
  254. FSMC_NANDInitStruct->FSMC_ECC |
  255. FSMC_NANDInitStruct->FSMC_ECCPageSize |
  256. (FSMC_NANDInitStruct->FSMC_TCLRSetupTime << 9 )|
  257. (FSMC_NANDInitStruct->FSMC_TARSetupTime << 13);
  258. /* Set tmppmem value according to FSMC_CommonSpaceTimingStructure parameters */
  259. tmppmem = (uint32_t)FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime |
  260. (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
  261. (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
  262. (FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24);
  263. /* Set tmppatt value according to FSMC_AttributeSpaceTimingStructure parameters */
  264. tmppatt = (uint32_t)FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime |
  265. (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
  266. (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
  267. (FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24);
  268. if(FSMC_NANDInitStruct->FSMC_Bank == FSMC_Bank2_NAND)
  269. {
  270. /* FSMC_Bank2_NAND registers configuration */
  271. FSMC_Bank2->PCR2 = tmppcr;
  272. FSMC_Bank2->PMEM2 = tmppmem;
  273. FSMC_Bank2->PATT2 = tmppatt;
  274. }
  275. else
  276. {
  277. /* FSMC_Bank3_NAND registers configuration */
  278. FSMC_Bank3->PCR3 = tmppcr;
  279. FSMC_Bank3->PMEM3 = tmppmem;
  280. FSMC_Bank3->PATT3 = tmppatt;
  281. }
  282. }
  283. /**
  284. * @brief Initializes the FSMC PCCARD Bank according to the specified
  285. * parameters in the FSMC_PCCARDInitStruct.
  286. * @param FSMC_PCCARDInitStruct : pointer to a FSMC_PCCARDInitTypeDef
  287. * structure that contains the configuration information for the FSMC PCCARD Bank.
  288. * @retval None
  289. */
  290. void FSMC_PCCARDInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct)
  291. {
  292. /* Check the parameters */
  293. assert_param(IS_FSMC_WAIT_FEATURE(FSMC_PCCARDInitStruct->FSMC_Waitfeature));
  294. assert_param(IS_FSMC_TCLR_TIME(FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime));
  295. assert_param(IS_FSMC_TAR_TIME(FSMC_PCCARDInitStruct->FSMC_TARSetupTime));
  296. assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime));
  297. assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime));
  298. assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime));
  299. assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime));
  300. assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime));
  301. assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime));
  302. assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime));
  303. assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime));
  304. assert_param(IS_FSMC_SETUP_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime));
  305. assert_param(IS_FSMC_WAIT_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime));
  306. assert_param(IS_FSMC_HOLD_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime));
  307. assert_param(IS_FSMC_HIZ_TIME(FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime));
  308. /* Set the PCR4 register value according to FSMC_PCCARDInitStruct parameters */
  309. FSMC_Bank4->PCR4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_Waitfeature |
  310. FSMC_MemoryDataWidth_16b |
  311. (FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime << 9) |
  312. (FSMC_PCCARDInitStruct->FSMC_TARSetupTime << 13);
  313. /* Set PMEM4 register value according to FSMC_CommonSpaceTimingStructure parameters */
  314. FSMC_Bank4->PMEM4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime |
  315. (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
  316. (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
  317. (FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime << 24);
  318. /* Set PATT4 register value according to FSMC_AttributeSpaceTimingStructure parameters */
  319. FSMC_Bank4->PATT4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime |
  320. (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
  321. (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
  322. (FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime << 24);
  323. /* Set PIO4 register value according to FSMC_IOSpaceTimingStructure parameters */
  324. FSMC_Bank4->PIO4 = (uint32_t)FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime |
  325. (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime << 8) |
  326. (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime << 16)|
  327. (FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime << 24);
  328. }
  329. /**
  330. * @brief Fills each FSMC_NORSRAMInitStruct member with its default value.
  331. * @param FSMC_NORSRAMInitStruct: pointer to a FSMC_NORSRAMInitTypeDef
  332. * structure which will be initialized.
  333. * @retval None
  334. */
  335. void FSMC_NORSRAMStructInit(FSMC_NORSRAMInitTypeDef* FSMC_NORSRAMInitStruct)
  336. {
  337. /* Reset NOR/SRAM Init structure parameters values */
  338. FSMC_NORSRAMInitStruct->FSMC_Bank = FSMC_Bank1_NORSRAM1;
  339. FSMC_NORSRAMInitStruct->FSMC_DataAddressMux = FSMC_DataAddressMux_Enable;
  340. FSMC_NORSRAMInitStruct->FSMC_MemoryType = FSMC_MemoryType_SRAM;
  341. FSMC_NORSRAMInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
  342. FSMC_NORSRAMInitStruct->FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
  343. FSMC_NORSRAMInitStruct->FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  344. FSMC_NORSRAMInitStruct->FSMC_WrapMode = FSMC_WrapMode_Disable;
  345. FSMC_NORSRAMInitStruct->FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
  346. FSMC_NORSRAMInitStruct->FSMC_WriteOperation = FSMC_WriteOperation_Enable;
  347. FSMC_NORSRAMInitStruct->FSMC_WaitSignal = FSMC_WaitSignal_Enable;
  348. FSMC_NORSRAMInitStruct->FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
  349. FSMC_NORSRAMInitStruct->FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  350. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressSetupTime = 0xF;
  351. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AddressHoldTime = 0xF;
  352. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataSetupTime = 0xFF;
  353. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF;
  354. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_CLKDivision = 0xF;
  355. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_DataLatency = 0xF;
  356. FSMC_NORSRAMInitStruct->FSMC_ReadWriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A;
  357. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressSetupTime = 0xF;
  358. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AddressHoldTime = 0xF;
  359. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataSetupTime = 0xFF;
  360. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_BusTurnAroundDuration = 0xF;
  361. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_CLKDivision = 0xF;
  362. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_DataLatency = 0xF;
  363. FSMC_NORSRAMInitStruct->FSMC_WriteTimingStruct->FSMC_AccessMode = FSMC_AccessMode_A;
  364. }
  365. /**
  366. * @brief Fills each FSMC_NANDInitStruct member with its default value.
  367. * @param FSMC_NANDInitStruct: pointer to a FSMC_NANDInitTypeDef
  368. * structure which will be initialized.
  369. * @retval None
  370. */
  371. void FSMC_NANDStructInit(FSMC_NANDInitTypeDef* FSMC_NANDInitStruct)
  372. {
  373. /* Reset NAND Init structure parameters values */
  374. FSMC_NANDInitStruct->FSMC_Bank = FSMC_Bank2_NAND;
  375. FSMC_NANDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable;
  376. FSMC_NANDInitStruct->FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
  377. FSMC_NANDInitStruct->FSMC_ECC = FSMC_ECC_Disable;
  378. FSMC_NANDInitStruct->FSMC_ECCPageSize = FSMC_ECCPageSize_256Bytes;
  379. FSMC_NANDInitStruct->FSMC_TCLRSetupTime = 0x0;
  380. FSMC_NANDInitStruct->FSMC_TARSetupTime = 0x0;
  381. FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC;
  382. FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
  383. FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
  384. FSMC_NANDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
  385. FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC;
  386. FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
  387. FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
  388. FSMC_NANDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
  389. }
  390. /**
  391. * @brief Fills each FSMC_PCCARDInitStruct member with its default value.
  392. * @param FSMC_PCCARDInitStruct: pointer to a FSMC_PCCARDInitTypeDef
  393. * structure which will be initialized.
  394. * @retval None
  395. */
  396. void FSMC_PCCARDStructInit(FSMC_PCCARDInitTypeDef* FSMC_PCCARDInitStruct)
  397. {
  398. /* Reset PCCARD Init structure parameters values */
  399. FSMC_PCCARDInitStruct->FSMC_Waitfeature = FSMC_Waitfeature_Disable;
  400. FSMC_PCCARDInitStruct->FSMC_TCLRSetupTime = 0x0;
  401. FSMC_PCCARDInitStruct->FSMC_TARSetupTime = 0x0;
  402. FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_SetupTime = 0xFC;
  403. FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
  404. FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
  405. FSMC_PCCARDInitStruct->FSMC_CommonSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
  406. FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_SetupTime = 0xFC;
  407. FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
  408. FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
  409. FSMC_PCCARDInitStruct->FSMC_AttributeSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
  410. FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_SetupTime = 0xFC;
  411. FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_WaitSetupTime = 0xFC;
  412. FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HoldSetupTime = 0xFC;
  413. FSMC_PCCARDInitStruct->FSMC_IOSpaceTimingStruct->FSMC_HiZSetupTime = 0xFC;
  414. }
  415. /**
  416. * @brief Enables or disables the specified NOR/SRAM Memory Bank.
  417. * @param FSMC_Bank: specifies the FSMC Bank to be used
  418. * This parameter can be one of the following values:
  419. * @arg FSMC_Bank1_NORSRAM1: FSMC Bank1 NOR/SRAM1
  420. * @arg FSMC_Bank1_NORSRAM2: FSMC Bank1 NOR/SRAM2
  421. * @arg FSMC_Bank1_NORSRAM3: FSMC Bank1 NOR/SRAM3
  422. * @arg FSMC_Bank1_NORSRAM4: FSMC Bank1 NOR/SRAM4
  423. * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE.
  424. * @retval None
  425. */
  426. void FSMC_NORSRAMCmd(uint32_t FSMC_Bank, FunctionalState NewState)
  427. {
  428. assert_param(IS_FSMC_NORSRAM_BANK(FSMC_Bank));
  429. assert_param(IS_FUNCTIONAL_STATE(NewState));
  430. if (NewState != DISABLE)
  431. {
  432. /* Enable the selected NOR/SRAM Bank by setting the PBKEN bit in the BCRx register */
  433. FSMC_Bank1->BTCR[FSMC_Bank] |= BCR_MBKEN_Set;
  434. }
  435. else
  436. {
  437. /* Disable the selected NOR/SRAM Bank by clearing the PBKEN bit in the BCRx register */
  438. FSMC_Bank1->BTCR[FSMC_Bank] &= BCR_MBKEN_Reset;
  439. }
  440. }
  441. /**
  442. * @brief Enables or disables the specified NAND Memory Bank.
  443. * @param FSMC_Bank: specifies the FSMC Bank to be used
  444. * This parameter can be one of the following values:
  445. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  446. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  447. * @param NewState: new state of the FSMC_Bank. This parameter can be: ENABLE or DISABLE.
  448. * @retval None
  449. */
  450. void FSMC_NANDCmd(uint32_t FSMC_Bank, FunctionalState NewState)
  451. {
  452. assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
  453. assert_param(IS_FUNCTIONAL_STATE(NewState));
  454. if (NewState != DISABLE)
  455. {
  456. /* Enable the selected NAND Bank by setting the PBKEN bit in the PCRx register */
  457. if(FSMC_Bank == FSMC_Bank2_NAND)
  458. {
  459. FSMC_Bank2->PCR2 |= PCR_PBKEN_Set;
  460. }
  461. else
  462. {
  463. FSMC_Bank3->PCR3 |= PCR_PBKEN_Set;
  464. }
  465. }
  466. else
  467. {
  468. /* Disable the selected NAND Bank by clearing the PBKEN bit in the PCRx register */
  469. if(FSMC_Bank == FSMC_Bank2_NAND)
  470. {
  471. FSMC_Bank2->PCR2 &= PCR_PBKEN_Reset;
  472. }
  473. else
  474. {
  475. FSMC_Bank3->PCR3 &= PCR_PBKEN_Reset;
  476. }
  477. }
  478. }
  479. /**
  480. * @brief Enables or disables the PCCARD Memory Bank.
  481. * @param NewState: new state of the PCCARD Memory Bank.
  482. * This parameter can be: ENABLE or DISABLE.
  483. * @retval None
  484. */
  485. void FSMC_PCCARDCmd(FunctionalState NewState)
  486. {
  487. assert_param(IS_FUNCTIONAL_STATE(NewState));
  488. if (NewState != DISABLE)
  489. {
  490. /* Enable the PCCARD Bank by setting the PBKEN bit in the PCR4 register */
  491. FSMC_Bank4->PCR4 |= PCR_PBKEN_Set;
  492. }
  493. else
  494. {
  495. /* Disable the PCCARD Bank by clearing the PBKEN bit in the PCR4 register */
  496. FSMC_Bank4->PCR4 &= PCR_PBKEN_Reset;
  497. }
  498. }
  499. /**
  500. * @brief Enables or disables the FSMC NAND ECC feature.
  501. * @param FSMC_Bank: specifies the FSMC Bank to be used
  502. * This parameter can be one of the following values:
  503. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  504. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  505. * @param NewState: new state of the FSMC NAND ECC feature.
  506. * This parameter can be: ENABLE or DISABLE.
  507. * @retval None
  508. */
  509. void FSMC_NANDECCCmd(uint32_t FSMC_Bank, FunctionalState NewState)
  510. {
  511. assert_param(IS_FSMC_NAND_BANK(FSMC_Bank));
  512. assert_param(IS_FUNCTIONAL_STATE(NewState));
  513. if (NewState != DISABLE)
  514. {
  515. /* Enable the selected NAND Bank ECC function by setting the ECCEN bit in the PCRx register */
  516. if(FSMC_Bank == FSMC_Bank2_NAND)
  517. {
  518. FSMC_Bank2->PCR2 |= PCR_ECCEN_Set;
  519. }
  520. else
  521. {
  522. FSMC_Bank3->PCR3 |= PCR_ECCEN_Set;
  523. }
  524. }
  525. else
  526. {
  527. /* Disable the selected NAND Bank ECC function by clearing the ECCEN bit in the PCRx register */
  528. if(FSMC_Bank == FSMC_Bank2_NAND)
  529. {
  530. FSMC_Bank2->PCR2 &= PCR_ECCEN_Reset;
  531. }
  532. else
  533. {
  534. FSMC_Bank3->PCR3 &= PCR_ECCEN_Reset;
  535. }
  536. }
  537. }
  538. /**
  539. * @brief Returns the error correction code register value.
  540. * @param FSMC_Bank: specifies the FSMC Bank to be used
  541. * This parameter can be one of the following values:
  542. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  543. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  544. * @retval The Error Correction Code (ECC) value.
  545. */
  546. uint32_t FSMC_GetECC(uint32_t FSMC_Bank)
  547. {
  548. uint32_t eccval = 0x00000000;
  549. if(FSMC_Bank == FSMC_Bank2_NAND)
  550. {
  551. /* Get the ECCR2 register value */
  552. eccval = FSMC_Bank2->ECCR2;
  553. }
  554. else
  555. {
  556. /* Get the ECCR3 register value */
  557. eccval = FSMC_Bank3->ECCR3;
  558. }
  559. /* Return the error correction code value */
  560. return(eccval);
  561. }
  562. /**
  563. * @brief Enables or disables the specified FSMC interrupts.
  564. * @param FSMC_Bank: specifies the FSMC Bank to be used
  565. * This parameter can be one of the following values:
  566. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  567. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  568. * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
  569. * @param FSMC_IT: specifies the FSMC interrupt sources to be enabled or disabled.
  570. * This parameter can be any combination of the following values:
  571. * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
  572. * @arg FSMC_IT_Level: Level edge detection interrupt.
  573. * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
  574. * @param NewState: new state of the specified FSMC interrupts.
  575. * This parameter can be: ENABLE or DISABLE.
  576. * @retval None
  577. */
  578. void FSMC_ITConfig(uint32_t FSMC_Bank, uint32_t FSMC_IT, FunctionalState NewState)
  579. {
  580. assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
  581. assert_param(IS_FSMC_IT(FSMC_IT));
  582. assert_param(IS_FUNCTIONAL_STATE(NewState));
  583. if (NewState != DISABLE)
  584. {
  585. /* Enable the selected FSMC_Bank2 interrupts */
  586. if(FSMC_Bank == FSMC_Bank2_NAND)
  587. {
  588. FSMC_Bank2->SR2 |= FSMC_IT;
  589. }
  590. /* Enable the selected FSMC_Bank3 interrupts */
  591. else if (FSMC_Bank == FSMC_Bank3_NAND)
  592. {
  593. FSMC_Bank3->SR3 |= FSMC_IT;
  594. }
  595. /* Enable the selected FSMC_Bank4 interrupts */
  596. else
  597. {
  598. FSMC_Bank4->SR4 |= FSMC_IT;
  599. }
  600. }
  601. else
  602. {
  603. /* Disable the selected FSMC_Bank2 interrupts */
  604. if(FSMC_Bank == FSMC_Bank2_NAND)
  605. {
  606. FSMC_Bank2->SR2 &= (uint32_t)~FSMC_IT;
  607. }
  608. /* Disable the selected FSMC_Bank3 interrupts */
  609. else if (FSMC_Bank == FSMC_Bank3_NAND)
  610. {
  611. FSMC_Bank3->SR3 &= (uint32_t)~FSMC_IT;
  612. }
  613. /* Disable the selected FSMC_Bank4 interrupts */
  614. else
  615. {
  616. FSMC_Bank4->SR4 &= (uint32_t)~FSMC_IT;
  617. }
  618. }
  619. }
  620. /**
  621. * @brief Checks whether the specified FSMC flag is set or not.
  622. * @param FSMC_Bank: specifies the FSMC Bank to be used
  623. * This parameter can be one of the following values:
  624. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  625. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  626. * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
  627. * @param FSMC_FLAG: specifies the flag to check.
  628. * This parameter can be one of the following values:
  629. * @arg FSMC_FLAG_RisingEdge: Rising egde detection Flag.
  630. * @arg FSMC_FLAG_Level: Level detection Flag.
  631. * @arg FSMC_FLAG_FallingEdge: Falling egde detection Flag.
  632. * @arg FSMC_FLAG_FEMPT: Fifo empty Flag.
  633. * @retval The new state of FSMC_FLAG (SET or RESET).
  634. */
  635. FlagStatus FSMC_GetFlagStatus(uint32_t FSMC_Bank, uint32_t FSMC_FLAG)
  636. {
  637. FlagStatus bitstatus = RESET;
  638. uint32_t tmpsr = 0x00000000;
  639. /* Check the parameters */
  640. assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
  641. assert_param(IS_FSMC_GET_FLAG(FSMC_FLAG));
  642. if(FSMC_Bank == FSMC_Bank2_NAND)
  643. {
  644. tmpsr = FSMC_Bank2->SR2;
  645. }
  646. else if(FSMC_Bank == FSMC_Bank3_NAND)
  647. {
  648. tmpsr = FSMC_Bank3->SR3;
  649. }
  650. /* FSMC_Bank4_PCCARD*/
  651. else
  652. {
  653. tmpsr = FSMC_Bank4->SR4;
  654. }
  655. /* Get the flag status */
  656. if ((tmpsr & FSMC_FLAG) != (uint16_t)RESET )
  657. {
  658. bitstatus = SET;
  659. }
  660. else
  661. {
  662. bitstatus = RESET;
  663. }
  664. /* Return the flag status */
  665. return bitstatus;
  666. }
  667. /**
  668. * @brief Clears the FSMC’s pending flags.
  669. * @param FSMC_Bank: specifies the FSMC Bank to be used
  670. * This parameter can be one of the following values:
  671. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  672. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  673. * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
  674. * @param FSMC_FLAG: specifies the flag to clear.
  675. * This parameter can be any combination of the following values:
  676. * @arg FSMC_FLAG_RisingEdge: Rising egde detection Flag.
  677. * @arg FSMC_FLAG_Level: Level detection Flag.
  678. * @arg FSMC_FLAG_FallingEdge: Falling egde detection Flag.
  679. * @retval None
  680. */
  681. void FSMC_ClearFlag(uint32_t FSMC_Bank, uint32_t FSMC_FLAG)
  682. {
  683. /* Check the parameters */
  684. assert_param(IS_FSMC_GETFLAG_BANK(FSMC_Bank));
  685. assert_param(IS_FSMC_CLEAR_FLAG(FSMC_FLAG)) ;
  686. if(FSMC_Bank == FSMC_Bank2_NAND)
  687. {
  688. FSMC_Bank2->SR2 &= ~FSMC_FLAG;
  689. }
  690. else if(FSMC_Bank == FSMC_Bank3_NAND)
  691. {
  692. FSMC_Bank3->SR3 &= ~FSMC_FLAG;
  693. }
  694. /* FSMC_Bank4_PCCARD*/
  695. else
  696. {
  697. FSMC_Bank4->SR4 &= ~FSMC_FLAG;
  698. }
  699. }
  700. /**
  701. * @brief Checks whether the specified FSMC interrupt has occurred or not.
  702. * @param FSMC_Bank: specifies the FSMC Bank to be used
  703. * This parameter can be one of the following values:
  704. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  705. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  706. * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
  707. * @param FSMC_IT: specifies the FSMC interrupt source to check.
  708. * This parameter can be one of the following values:
  709. * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
  710. * @arg FSMC_IT_Level: Level edge detection interrupt.
  711. * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
  712. * @retval The new state of FSMC_IT (SET or RESET).
  713. */
  714. ITStatus FSMC_GetITStatus(uint32_t FSMC_Bank, uint32_t FSMC_IT)
  715. {
  716. ITStatus bitstatus = RESET;
  717. uint32_t tmpsr = 0x0, itstatus = 0x0, itenable = 0x0;
  718. /* Check the parameters */
  719. assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
  720. assert_param(IS_FSMC_GET_IT(FSMC_IT));
  721. if(FSMC_Bank == FSMC_Bank2_NAND)
  722. {
  723. tmpsr = FSMC_Bank2->SR2;
  724. }
  725. else if(FSMC_Bank == FSMC_Bank3_NAND)
  726. {
  727. tmpsr = FSMC_Bank3->SR3;
  728. }
  729. /* FSMC_Bank4_PCCARD*/
  730. else
  731. {
  732. tmpsr = FSMC_Bank4->SR4;
  733. }
  734. itstatus = tmpsr & FSMC_IT;
  735. itenable = tmpsr & (FSMC_IT >> 3);
  736. if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET))
  737. {
  738. bitstatus = SET;
  739. }
  740. else
  741. {
  742. bitstatus = RESET;
  743. }
  744. return bitstatus;
  745. }
  746. /**
  747. * @brief Clears the FSMC’s interrupt pending bits.
  748. * @param FSMC_Bank: specifies the FSMC Bank to be used
  749. * This parameter can be one of the following values:
  750. * @arg FSMC_Bank2_NAND: FSMC Bank2 NAND
  751. * @arg FSMC_Bank3_NAND: FSMC Bank3 NAND
  752. * @arg FSMC_Bank4_PCCARD: FSMC Bank4 PCCARD
  753. * @param FSMC_IT: specifies the interrupt pending bit to clear.
  754. * This parameter can be any combination of the following values:
  755. * @arg FSMC_IT_RisingEdge: Rising edge detection interrupt.
  756. * @arg FSMC_IT_Level: Level edge detection interrupt.
  757. * @arg FSMC_IT_FallingEdge: Falling edge detection interrupt.
  758. * @retval None
  759. */
  760. void FSMC_ClearITPendingBit(uint32_t FSMC_Bank, uint32_t FSMC_IT)
  761. {
  762. /* Check the parameters */
  763. assert_param(IS_FSMC_IT_BANK(FSMC_Bank));
  764. assert_param(IS_FSMC_IT(FSMC_IT));
  765. if(FSMC_Bank == FSMC_Bank2_NAND)
  766. {
  767. FSMC_Bank2->SR2 &= ~(FSMC_IT >> 3);
  768. }
  769. else if(FSMC_Bank == FSMC_Bank3_NAND)
  770. {
  771. FSMC_Bank3->SR3 &= ~(FSMC_IT >> 3);
  772. }
  773. /* FSMC_Bank4_PCCARD*/
  774. else
  775. {
  776. FSMC_Bank4->SR4 &= ~(FSMC_IT >> 3);
  777. }
  778. }
  779. /**
  780. * @}
  781. */
  782. /**
  783. * @}
  784. */
  785. /**
  786. * @}
  787. */
  788. /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/