stm32f10x_fsmc.c 35 KB

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