stm32f3xx_ll_fmc.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_ll_fmc.h
  4. * @author MCD Application Team
  5. * @brief Header file of FMC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F3xx_LL_FMC_H
  20. #define STM32F3xx_LL_FMC_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx_hal_def.h"
  26. /** @addtogroup STM32F3xx_HAL_Driver
  27. * @{
  28. */
  29. /** @addtogroup FMC_LL
  30. * @{
  31. */
  32. /** @addtogroup FMC_LL_Private_Macros
  33. * @{
  34. */
  35. #if defined(FMC_BANK1)
  36. #define IS_FMC_NORSRAM_BANK(__BANK__) (((__BANK__) == FMC_NORSRAM_BANK1) || \
  37. ((__BANK__) == FMC_NORSRAM_BANK2) || \
  38. ((__BANK__) == FMC_NORSRAM_BANK3) || \
  39. ((__BANK__) == FMC_NORSRAM_BANK4))
  40. #define IS_FMC_MUX(__MUX__) (((__MUX__) == FMC_DATA_ADDRESS_MUX_DISABLE) || \
  41. ((__MUX__) == FMC_DATA_ADDRESS_MUX_ENABLE))
  42. #define IS_FMC_MEMORY(__MEMORY__) (((__MEMORY__) == FMC_MEMORY_TYPE_SRAM) || \
  43. ((__MEMORY__) == FMC_MEMORY_TYPE_PSRAM)|| \
  44. ((__MEMORY__) == FMC_MEMORY_TYPE_NOR))
  45. #define IS_FMC_NORSRAM_MEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FMC_NORSRAM_MEM_BUS_WIDTH_8) || \
  46. ((__WIDTH__) == FMC_NORSRAM_MEM_BUS_WIDTH_16) || \
  47. ((__WIDTH__) == FMC_NORSRAM_MEM_BUS_WIDTH_32))
  48. #define IS_FMC_ACCESS_MODE(__MODE__) (((__MODE__) == FMC_ACCESS_MODE_A) || \
  49. ((__MODE__) == FMC_ACCESS_MODE_B) || \
  50. ((__MODE__) == FMC_ACCESS_MODE_C) || \
  51. ((__MODE__) == FMC_ACCESS_MODE_D))
  52. #define IS_FMC_BURSTMODE(__STATE__) (((__STATE__) == FMC_BURST_ACCESS_MODE_DISABLE) || \
  53. ((__STATE__) == FMC_BURST_ACCESS_MODE_ENABLE))
  54. #define IS_FMC_WAIT_POLARITY(__POLARITY__) (((__POLARITY__) == FMC_WAIT_SIGNAL_POLARITY_LOW) || \
  55. ((__POLARITY__) == FMC_WAIT_SIGNAL_POLARITY_HIGH))
  56. #define IS_FMC_WRAP_MODE(__MODE__) (((__MODE__) == FMC_WRAP_MODE_DISABLE) || \
  57. ((__MODE__) == FMC_WRAP_MODE_ENABLE))
  58. #define IS_FMC_WAIT_SIGNAL_ACTIVE(__ACTIVE__) (((__ACTIVE__) == FMC_WAIT_TIMING_BEFORE_WS) || \
  59. ((__ACTIVE__) == FMC_WAIT_TIMING_DURING_WS))
  60. #define IS_FMC_WRITE_OPERATION(__OPERATION__) (((__OPERATION__) == FMC_WRITE_OPERATION_DISABLE) || \
  61. ((__OPERATION__) == FMC_WRITE_OPERATION_ENABLE))
  62. #define IS_FMC_WAITE_SIGNAL(__SIGNAL__) (((__SIGNAL__) == FMC_WAIT_SIGNAL_DISABLE) || \
  63. ((__SIGNAL__) == FMC_WAIT_SIGNAL_ENABLE))
  64. #define IS_FMC_EXTENDED_MODE(__MODE__) (((__MODE__) == FMC_EXTENDED_MODE_DISABLE) || \
  65. ((__MODE__) == FMC_EXTENDED_MODE_ENABLE))
  66. #define IS_FMC_ASYNWAIT(__STATE__) (((__STATE__) == FMC_ASYNCHRONOUS_WAIT_DISABLE) || \
  67. ((__STATE__) == FMC_ASYNCHRONOUS_WAIT_ENABLE))
  68. #define IS_FMC_DATA_LATENCY(__LATENCY__) (((__LATENCY__) > 1U) && ((__LATENCY__) <= 17U))
  69. #define IS_FMC_WRITE_BURST(__BURST__) (((__BURST__) == FMC_WRITE_BURST_DISABLE) || \
  70. ((__BURST__) == FMC_WRITE_BURST_ENABLE))
  71. #define IS_FMC_CONTINOUS_CLOCK(__CCLOCK__) (((__CCLOCK__) == FMC_CONTINUOUS_CLOCK_SYNC_ONLY) || \
  72. ((__CCLOCK__) == FMC_CONTINUOUS_CLOCK_SYNC_ASYNC))
  73. #define IS_FMC_ADDRESS_SETUP_TIME(__TIME__) ((__TIME__) <= 15U)
  74. #define IS_FMC_ADDRESS_HOLD_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 15U))
  75. #define IS_FMC_DATASETUP_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 255U))
  76. #define IS_FMC_DATAHOLD_DURATION(__DATAHOLD__) ((__DATAHOLD__) <= 3U)
  77. #define IS_FMC_TURNAROUND_TIME(__TIME__) ((__TIME__) <= 15U)
  78. #define IS_FMC_CLK_DIV(__DIV__) (((__DIV__) > 1U) && ((__DIV__) <= 16U))
  79. #define IS_FMC_NORSRAM_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_NORSRAM_DEVICE)
  80. #define IS_FMC_NORSRAM_EXTENDED_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_NORSRAM_EXTENDED_DEVICE)
  81. #endif /* FMC_BANK1 */
  82. #if defined(FMC_BANK3)
  83. #define IS_FMC_NAND_BANK(__BANK__) ((__BANK__) == FMC_NAND_BANK3)
  84. #define IS_FMC_WAIT_FEATURE(__FEATURE__) (((__FEATURE__) == FMC_NAND_PCC_WAIT_FEATURE_DISABLE) || \
  85. ((__FEATURE__) == FMC_NAND_PCC_WAIT_FEATURE_ENABLE))
  86. #define IS_FMC_NAND_MEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FMC_NAND_PCC_MEM_BUS_WIDTH_8) || \
  87. ((__WIDTH__) == FMC_NAND_PCC_MEM_BUS_WIDTH_16))
  88. #define IS_FMC_ECC_STATE(__STATE__) (((__STATE__) == FMC_NAND_ECC_DISABLE) || \
  89. ((__STATE__) == FMC_NAND_ECC_ENABLE))
  90. #define IS_FMC_ECCPAGE_SIZE(__SIZE__) (((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_256BYTE) || \
  91. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_512BYTE) || \
  92. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_1024BYTE) || \
  93. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_2048BYTE) || \
  94. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_4096BYTE) || \
  95. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_8192BYTE))
  96. #define IS_FMC_TCLR_TIME(__TIME__) ((__TIME__) <= 255U)
  97. #define IS_FMC_TAR_TIME(__TIME__) ((__TIME__) <= 255U)
  98. #define IS_FMC_SETUP_TIME(__TIME__) ((__TIME__) <= 254U)
  99. #define IS_FMC_WAIT_TIME(__TIME__) ((__TIME__) <= 254U)
  100. #define IS_FMC_HOLD_TIME(__TIME__) ((__TIME__) <= 254U)
  101. #define IS_FMC_HIZ_TIME(__TIME__) ((__TIME__) <= 254U)
  102. #define IS_FMC_NAND_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_NAND_DEVICE)
  103. #endif /* FMC_BANK3 */
  104. #if defined(FMC_BANK4)
  105. #define IS_FMC_PCCARD_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_PCCARD_DEVICE)
  106. #endif /* FMC_BANK4 */
  107. /**
  108. * @}
  109. */
  110. /* Exported typedef ----------------------------------------------------------*/
  111. /** @defgroup FMC_LL_Exported_typedef FMC Low Layer Exported Types
  112. * @{
  113. */
  114. #if defined(FMC_BANK1)
  115. #define FMC_NORSRAM_TypeDef FMC_Bank1_TypeDef
  116. #define FMC_NORSRAM_EXTENDED_TypeDef FMC_Bank1E_TypeDef
  117. #endif /* FMC_BANK1 */
  118. #if defined(FMC_BANK3)
  119. #define FMC_NAND_TypeDef FMC_Bank2_3_TypeDef
  120. #endif /* FMC_BANK3 */
  121. #if defined(FMC_BANK4)
  122. #define FMC_PCCARD_TypeDef FMC_Bank4_TypeDef
  123. #endif /* FMC_BANK4 */
  124. #if defined(FMC_BANK1)
  125. #define FMC_NORSRAM_DEVICE FMC_Bank1
  126. #define FMC_NORSRAM_EXTENDED_DEVICE FMC_Bank1E
  127. #endif /* FMC_BANK1 */
  128. #if defined(FMC_BANK3)
  129. #define FMC_NAND_DEVICE FMC_Bank2_3
  130. #endif /* FMC_BANK3 */
  131. #if defined(FMC_BANK4)
  132. #define FMC_PCCARD_DEVICE FMC_Bank4
  133. #endif /* FMC_BANK4 */
  134. #if defined(FMC_BANK1)
  135. /**
  136. * @brief FMC NORSRAM Configuration Structure definition
  137. */
  138. typedef struct
  139. {
  140. uint32_t NSBank; /*!< Specifies the NORSRAM memory device that will be used.
  141. This parameter can be a value of @ref FMC_NORSRAM_Bank */
  142. uint32_t DataAddressMux; /*!< Specifies whether the address and data values are
  143. multiplexed on the data bus or not.
  144. This parameter can be a value of @ref FMC_Data_Address_Bus_Multiplexing */
  145. uint32_t MemoryType; /*!< Specifies the type of external memory attached to
  146. the corresponding memory device.
  147. This parameter can be a value of @ref FMC_Memory_Type */
  148. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  149. This parameter can be a value of @ref FMC_NORSRAM_Data_Width */
  150. uint32_t BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory,
  151. valid only with synchronous burst Flash memories.
  152. This parameter can be a value of @ref FMC_Burst_Access_Mode */
  153. uint32_t WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing
  154. the Flash memory in burst mode.
  155. This parameter can be a value of @ref FMC_Wait_Signal_Polarity */
  156. uint32_t WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash
  157. memory, valid only when accessing Flash memories in burst mode.
  158. This parameter can be a value of @ref FMC_Wrap_Mode */
  159. uint32_t WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one
  160. clock cycle before the wait state or during the wait state,
  161. valid only when accessing memories in burst mode.
  162. This parameter can be a value of @ref FMC_Wait_Timing */
  163. uint32_t WriteOperation; /*!< Enables or disables the write operation in the selected device by the FMC.
  164. This parameter can be a value of @ref FMC_Write_Operation */
  165. uint32_t WaitSignal; /*!< Enables or disables the wait state insertion via wait
  166. signal, valid for Flash memory access in burst mode.
  167. This parameter can be a value of @ref FMC_Wait_Signal */
  168. uint32_t ExtendedMode; /*!< Enables or disables the extended mode.
  169. This parameter can be a value of @ref FMC_Extended_Mode */
  170. uint32_t AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers,
  171. valid only with asynchronous Flash memories.
  172. This parameter can be a value of @ref FMC_AsynchronousWait */
  173. uint32_t WriteBurst; /*!< Enables or disables the write burst operation.
  174. This parameter can be a value of @ref FMC_Write_Burst */
  175. uint32_t ContinuousClock; /*!< Enables or disables the FMC clock output to external memory devices.
  176. This parameter is only enabled through the FMC_BCR1 register,
  177. and don't care through FMC_BCR2..4 registers.
  178. This parameter can be a value of @ref FMC_Continous_Clock */
  179. } FMC_NORSRAM_InitTypeDef;
  180. /**
  181. * @brief FMC NORSRAM Timing parameters structure definition
  182. */
  183. typedef struct
  184. {
  185. uint32_t AddressSetupTime; /*!< Defines the number of HCLK cycles to configure
  186. the duration of the address setup time.
  187. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  188. @note This parameter is not used with synchronous NOR Flash memories. */
  189. uint32_t AddressHoldTime; /*!< Defines the number of HCLK cycles to configure
  190. the duration of the address hold time.
  191. This parameter can be a value between Min_Data = 1 and Max_Data = 15.
  192. @note This parameter is not used with synchronous NOR Flash memories. */
  193. uint32_t DataSetupTime; /*!< Defines the number of HCLK cycles to configure
  194. the duration of the data setup time.
  195. This parameter can be a value between Min_Data = 1 and Max_Data = 255.
  196. @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed
  197. NOR Flash memories. */
  198. uint32_t BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure
  199. the duration of the bus turnaround.
  200. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  201. @note This parameter is only used for multiplexed NOR Flash memories. */
  202. uint32_t CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of
  203. HCLK cycles. This parameter can be a value between Min_Data = 2 and
  204. Max_Data = 16.
  205. @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM
  206. accesses. */
  207. uint32_t DataLatency; /*!< Defines the number of memory clock cycles to issue
  208. to the memory before getting the first data.
  209. The parameter value depends on the memory type as shown below:
  210. - It must be set to 0 in case of a CRAM
  211. - It is don't care in asynchronous NOR, SRAM or ROM accesses
  212. - It may assume a value between Min_Data = 2 and Max_Data = 17
  213. in NOR Flash memories with synchronous burst mode enable */
  214. uint32_t AccessMode; /*!< Specifies the asynchronous access mode.
  215. This parameter can be a value of @ref FMC_Access_Mode */
  216. } FMC_NORSRAM_TimingTypeDef;
  217. #endif /* FMC_BANK1 */
  218. #if defined(FMC_BANK3)
  219. /**
  220. * @brief FMC NAND Configuration Structure definition
  221. */
  222. typedef struct
  223. {
  224. uint32_t NandBank; /*!< Specifies the NAND memory device that will be used.
  225. This parameter can be a value of @ref FMC_NAND_Bank */
  226. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory device.
  227. This parameter can be any value of @ref FMC_Wait_feature */
  228. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  229. This parameter can be any value of @ref FMC_NAND_Data_Width */
  230. uint32_t EccComputation; /*!< Enables or disables the ECC computation.
  231. This parameter can be any value of @ref FMC_ECC */
  232. uint32_t ECCPageSize; /*!< Defines the page size for the extended ECC.
  233. This parameter can be any value of @ref FMC_ECC_Page_Size */
  234. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  235. delay between CLE low and RE low.
  236. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  237. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  238. delay between ALE low and RE low.
  239. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  240. } FMC_NAND_InitTypeDef;
  241. #endif /* FMC_BANK3 */
  242. #if defined(FMC_BANK3) || defined(FMC_BANK4)
  243. /**
  244. * @brief FMC NAND Timing parameters structure definition
  245. */
  246. typedef struct
  247. {
  248. uint32_t SetupTime; /*!< Defines the number of HCLK cycles to setup address before
  249. the command assertion for NAND-Flash read or write access
  250. to common/Attribute or I/O memory space (depending on
  251. the memory space timing to be configured).
  252. This parameter can be a value between Min_Data = 0 and Max_Data = 254 */
  253. uint32_t WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the
  254. command for NAND-Flash read or write access to
  255. common/Attribute or I/O memory space (depending on the
  256. memory space timing to be configured).
  257. This parameter can be a number between Min_Data = 0 and Max_Data = 254 */
  258. uint32_t HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address
  259. (and data for write access) after the command de-assertion
  260. for NAND-Flash read or write access to common/Attribute
  261. or I/O memory space (depending on the memory space timing
  262. to be configured).
  263. This parameter can be a number between Min_Data = 0 and Max_Data = 254 */
  264. uint32_t HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the
  265. data bus is kept in HiZ after the start of a NAND-Flash
  266. write access to common/Attribute or I/O memory space (depending
  267. on the memory space timing to be configured).
  268. This parameter can be a number between Min_Data = 0 and Max_Data = 254 */
  269. } FMC_NAND_PCC_TimingTypeDef;
  270. #endif /* FMC_BANK3 */
  271. #if defined(FMC_BANK4)
  272. /**
  273. * @brief FMC PCCARD Configuration Structure definition
  274. */
  275. typedef struct
  276. {
  277. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the PCCARD Memory device.
  278. This parameter can be any value of @ref FMC_Wait_feature */
  279. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  280. delay between CLE low and RE low.
  281. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  282. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  283. delay between ALE low and RE low.
  284. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  285. }FMC_PCCARD_InitTypeDef;
  286. #endif /* FMC_BANK4 */
  287. /**
  288. * @}
  289. */
  290. /* Exported constants --------------------------------------------------------*/
  291. /** @addtogroup FMC_LL_Exported_Constants FMC Low Layer Exported Constants
  292. * @{
  293. */
  294. #if defined(FMC_BANK1)
  295. /** @defgroup FMC_LL_NOR_SRAM_Controller FMC NOR/SRAM Controller
  296. * @{
  297. */
  298. /** @defgroup FMC_NORSRAM_Bank FMC NOR/SRAM Bank
  299. * @{
  300. */
  301. #define FMC_NORSRAM_BANK1 (0x00000000U)
  302. #define FMC_NORSRAM_BANK2 (0x00000002U)
  303. #define FMC_NORSRAM_BANK3 (0x00000004U)
  304. #define FMC_NORSRAM_BANK4 (0x00000006U)
  305. /**
  306. * @}
  307. */
  308. /** @defgroup FMC_Data_Address_Bus_Multiplexing FMC Data Address Bus Multiplexing
  309. * @{
  310. */
  311. #define FMC_DATA_ADDRESS_MUX_DISABLE (0x00000000U)
  312. #define FMC_DATA_ADDRESS_MUX_ENABLE (0x00000002U)
  313. /**
  314. * @}
  315. */
  316. /** @defgroup FMC_Memory_Type FMC Memory Type
  317. * @{
  318. */
  319. #define FMC_MEMORY_TYPE_SRAM (0x00000000U)
  320. #define FMC_MEMORY_TYPE_PSRAM (0x00000004U)
  321. #define FMC_MEMORY_TYPE_NOR (0x00000008U)
  322. /**
  323. * @}
  324. */
  325. /** @defgroup FMC_NORSRAM_Data_Width FMC NORSRAM Data Width
  326. * @{
  327. */
  328. #define FMC_NORSRAM_MEM_BUS_WIDTH_8 (0x00000000U)
  329. #define FMC_NORSRAM_MEM_BUS_WIDTH_16 (0x00000010U)
  330. #define FMC_NORSRAM_MEM_BUS_WIDTH_32 (0x00000020U)
  331. /**
  332. * @}
  333. */
  334. /** @defgroup FMC_NORSRAM_Flash_Access FMC NOR/SRAM Flash Access
  335. * @{
  336. */
  337. #define FMC_NORSRAM_FLASH_ACCESS_ENABLE (0x00000040U)
  338. #define FMC_NORSRAM_FLASH_ACCESS_DISABLE (0x00000000U)
  339. /**
  340. * @}
  341. */
  342. /** @defgroup FMC_Burst_Access_Mode FMC Burst Access Mode
  343. * @{
  344. */
  345. #define FMC_BURST_ACCESS_MODE_DISABLE (0x00000000U)
  346. #define FMC_BURST_ACCESS_MODE_ENABLE (0x00000100U)
  347. /**
  348. * @}
  349. */
  350. /** @defgroup FMC_Wait_Signal_Polarity FMC Wait Signal Polarity
  351. * @{
  352. */
  353. #define FMC_WAIT_SIGNAL_POLARITY_LOW (0x00000000U)
  354. #define FMC_WAIT_SIGNAL_POLARITY_HIGH (0x00000200U)
  355. /**
  356. * @}
  357. */
  358. /** @defgroup FMC_Wrap_Mode FMC Wrap Mode
  359. * @{
  360. */
  361. #define FMC_WRAP_MODE_DISABLE (0x00000000U)
  362. #define FMC_WRAP_MODE_ENABLE (0x00000400U)
  363. /**
  364. * @}
  365. */
  366. /** @defgroup FMC_Wait_Timing FMC Wait Timing
  367. * @{
  368. */
  369. #define FMC_WAIT_TIMING_BEFORE_WS (0x00000000U)
  370. #define FMC_WAIT_TIMING_DURING_WS (0x00000800U)
  371. /**
  372. * @}
  373. */
  374. /** @defgroup FMC_Write_Operation FMC Write Operation
  375. * @{
  376. */
  377. #define FMC_WRITE_OPERATION_DISABLE (0x00000000U)
  378. #define FMC_WRITE_OPERATION_ENABLE (0x00001000U)
  379. /**
  380. * @}
  381. */
  382. /** @defgroup FMC_Wait_Signal FMC Wait Signal
  383. * @{
  384. */
  385. #define FMC_WAIT_SIGNAL_DISABLE (0x00000000U)
  386. #define FMC_WAIT_SIGNAL_ENABLE (0x00002000U)
  387. /**
  388. * @}
  389. */
  390. /** @defgroup FMC_Extended_Mode FMC Extended Mode
  391. * @{
  392. */
  393. #define FMC_EXTENDED_MODE_DISABLE (0x00000000U)
  394. #define FMC_EXTENDED_MODE_ENABLE (0x00004000U)
  395. /**
  396. * @}
  397. */
  398. /** @defgroup FMC_AsynchronousWait FMC Asynchronous Wait
  399. * @{
  400. */
  401. #define FMC_ASYNCHRONOUS_WAIT_DISABLE (0x00000000U)
  402. #define FMC_ASYNCHRONOUS_WAIT_ENABLE (0x00008000U)
  403. /**
  404. * @}
  405. */
  406. /** @defgroup FMC_Write_Burst FMC Write Burst
  407. * @{
  408. */
  409. #define FMC_WRITE_BURST_DISABLE (0x00000000U)
  410. #define FMC_WRITE_BURST_ENABLE (0x00080000U)
  411. /**
  412. * @}
  413. */
  414. /** @defgroup FMC_Continous_Clock FMC Continuous Clock
  415. * @{
  416. */
  417. #define FMC_CONTINUOUS_CLOCK_SYNC_ONLY (0x00000000U)
  418. #define FMC_CONTINUOUS_CLOCK_SYNC_ASYNC (0x00100000U)
  419. /**
  420. * @}
  421. */
  422. /** @defgroup FMC_Access_Mode FMC Access Mode
  423. * @{
  424. */
  425. #define FMC_ACCESS_MODE_A (0x00000000U)
  426. #define FMC_ACCESS_MODE_B (0x10000000U)
  427. #define FMC_ACCESS_MODE_C (0x20000000U)
  428. #define FMC_ACCESS_MODE_D (0x30000000U)
  429. /**
  430. * @}
  431. */
  432. /**
  433. * @}
  434. */
  435. #endif /* FMC_BANK1 */
  436. #if defined(FMC_BANK3) || defined(FMC_BANK4)
  437. /** @defgroup FMC_LL_NAND_Controller FMC NAND Controller
  438. * @{
  439. */
  440. /** @defgroup FMC_NAND_Bank FMC NAND Bank
  441. * @{
  442. */
  443. #define FMC_NAND_BANK2 (0x00000010U)
  444. #define FMC_NAND_BANK3 (0x00000100U)
  445. /**
  446. * @}
  447. */
  448. /** @defgroup FMC_Wait_feature FMC Wait feature
  449. * @{
  450. */
  451. #define FMC_NAND_PCC_WAIT_FEATURE_DISABLE (0x00000000U)
  452. #define FMC_NAND_PCC_WAIT_FEATURE_ENABLE (0x00000002U)
  453. /**
  454. * @}
  455. */
  456. /** @defgroup FMC_PCR_Memory_Type FMC PCR Memory Type
  457. * @{
  458. */
  459. #if defined(FMC_BANK4)
  460. #define FMC_PCR_MEMORY_TYPE_PCCARD (0x00000000U)
  461. #endif /* FMC_BANK4 */
  462. #define FMC_PCR_MEMORY_TYPE_NAND (0x00000008U)
  463. /**
  464. * @}
  465. */
  466. /** @defgroup FMC_NAND_Data_Width FMC NAND Data Width
  467. * @{
  468. */
  469. #define FMC_NAND_PCC_MEM_BUS_WIDTH_8 (0x00000000U)
  470. #define FMC_NAND_PCC_MEM_BUS_WIDTH_16 (0x00000010U)
  471. /**
  472. * @}
  473. */
  474. /** @defgroup FMC_ECC FMC ECC
  475. * @{
  476. */
  477. #define FMC_NAND_ECC_DISABLE (0x00000000U)
  478. #define FMC_NAND_ECC_ENABLE (0x00000040U)
  479. /**
  480. * @}
  481. */
  482. /** @defgroup FMC_ECC_Page_Size FMC ECC Page Size
  483. * @{
  484. */
  485. #define FMC_NAND_ECC_PAGE_SIZE_256BYTE (0x00000000U)
  486. #define FMC_NAND_ECC_PAGE_SIZE_512BYTE (0x00020000U)
  487. #define FMC_NAND_ECC_PAGE_SIZE_1024BYTE (0x00040000U)
  488. #define FMC_NAND_ECC_PAGE_SIZE_2048BYTE (0x00060000U)
  489. #define FMC_NAND_ECC_PAGE_SIZE_4096BYTE (0x00080000U)
  490. #define FMC_NAND_ECC_PAGE_SIZE_8192BYTE (0x000A0000U)
  491. /**
  492. * @}
  493. */
  494. /**
  495. * @}
  496. */
  497. #endif /* FMC_BANK3 || FMC_BANK4 */
  498. /** @defgroup FMC_LL_Interrupt_definition FMC Low Layer Interrupt definition
  499. * @{
  500. */
  501. #if defined(FMC_BANK3) || defined(FMC_BANK4)
  502. #define FMC_IT_RISING_EDGE (0x00000008U)
  503. #define FMC_IT_LEVEL (0x00000010U)
  504. #define FMC_IT_FALLING_EDGE (0x00000020U)
  505. #endif /* FMC_BANK3 || FMC_BANK4 */
  506. /**
  507. * @}
  508. */
  509. /** @defgroup FMC_LL_Flag_definition FMC Low Layer Flag definition
  510. * @{
  511. */
  512. #if defined(FMC_BANK3) || defined(FMC_BANK4)
  513. #define FMC_FLAG_RISING_EDGE (0x00000001U)
  514. #define FMC_FLAG_LEVEL (0x00000002U)
  515. #define FMC_FLAG_FALLING_EDGE (0x00000004U)
  516. #define FMC_FLAG_FEMPT (0x00000040U)
  517. #endif /* FMC_BANK3 || FMC_BANK4 */
  518. /**
  519. * @}
  520. */
  521. /**
  522. * @}
  523. */
  524. /**
  525. * @}
  526. */
  527. /* Private macro -------------------------------------------------------------*/
  528. /** @defgroup FMC_LL_Private_Macros FMC_LL Private Macros
  529. * @{
  530. */
  531. #if defined(FMC_BANK1)
  532. /** @defgroup FMC_LL_NOR_Macros FMC NOR/SRAM Macros
  533. * @brief macros to handle NOR device enable/disable and read/write operations
  534. * @{
  535. */
  536. /**
  537. * @brief Enable the NORSRAM device access.
  538. * @param __INSTANCE__ FMC_NORSRAM Instance
  539. * @param __BANK__ FMC_NORSRAM Bank
  540. * @retval None
  541. */
  542. #define __FMC_NORSRAM_ENABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)]\
  543. |= FMC_BCRx_MBKEN)
  544. /**
  545. * @brief Disable the NORSRAM device access.
  546. * @param __INSTANCE__ FMC_NORSRAM Instance
  547. * @param __BANK__ FMC_NORSRAM Bank
  548. * @retval None
  549. */
  550. #define __FMC_NORSRAM_DISABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)]\
  551. &= ~FMC_BCRx_MBKEN)
  552. /**
  553. * @}
  554. */
  555. #endif /* FMC_BANK1 */
  556. #if defined(FMC_BANK3)
  557. /** @defgroup FMC_LL_NAND_Macros FMC NAND Macros
  558. * @brief macros to handle NAND device enable/disable
  559. * @{
  560. */
  561. /**
  562. * @brief Enable the NAND device access.
  563. * @param __INSTANCE__ FMC_NAND Instance
  564. * @param __BANK__ FMC_NAND Bank
  565. * @retval None
  566. */
  567. #define __FMC_NAND_ENABLE(__INSTANCE__, __BANK__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 |= FMC_PCRx_PBKEN): \
  568. ((__INSTANCE__)->PCR3 |= FMC_PCRx_PBKEN))
  569. /**
  570. * @brief Disable the NAND device access.
  571. * @param __INSTANCE__ FMC_NAND Instance
  572. * @param __BANK__ FMC_NAND Bank
  573. * @retval None
  574. */
  575. #define __FMC_NAND_DISABLE(__INSTANCE__, __BANK__) (((__BANK__) == FMC_NAND_BANK2)? CLEAR_BIT((__INSTANCE__)->PCR2, FMC_PCRx_PBKEN): \
  576. CLEAR_BIT((__INSTANCE__)->PCR3, FMC_PCRx_PBKEN))
  577. /**
  578. * @}
  579. */
  580. #endif /* FMC_BANK3 */
  581. #if defined(FMC_BANK4)
  582. /** @defgroup FMC_LL_PCCARD_Macros FMC PCCARD Macros
  583. * @brief macros to handle PCCARD read/write operations
  584. * @{
  585. */
  586. /**
  587. * @brief Enable the PCCARD device access.
  588. * @param __INSTANCE__ FMC_PCCARD Instance
  589. * @retval None
  590. */
  591. #define __FMC_PCCARD_ENABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 |= FMC_PCR4_PBKEN)
  592. /**
  593. * @brief Disable the PCCARD device access.
  594. * @param __INSTANCE__ FMC_PCCARD Instance
  595. * @retval None
  596. */
  597. #define __FMC_PCCARD_DISABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 &= ~FMC_PCR4_PBKEN)
  598. /**
  599. * @}
  600. */
  601. #endif
  602. #if defined(FMC_BANK3)
  603. /** @defgroup FMC_LL_NAND_Interrupt FMC NAND Interrupt
  604. * @brief macros to handle NAND interrupts
  605. * @{
  606. */
  607. /**
  608. * @brief Enable the NAND device interrupt.
  609. * @param __INSTANCE__ FMC_NAND instance
  610. * @param __BANK__ FMC_NAND Bank
  611. * @param __INTERRUPT__ FMC_NAND interrupt
  612. * This parameter can be any combination of the following values:
  613. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  614. * @arg FMC_IT_LEVEL: Interrupt level.
  615. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  616. * @retval None
  617. */
  618. #define __FMC_NAND_ENABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->SR2 |= (__INTERRUPT__)): \
  619. ((__INSTANCE__)->SR3 |= (__INTERRUPT__)))
  620. /**
  621. * @brief Disable the NAND device interrupt.
  622. * @param __INSTANCE__ FMC_NAND Instance
  623. * @param __BANK__ FMC_NAND Bank
  624. * @param __INTERRUPT__ FMC_NAND interrupt
  625. * This parameter can be any combination of the following values:
  626. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  627. * @arg FMC_IT_LEVEL: Interrupt level.
  628. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  629. * @retval None
  630. */
  631. #define __FMC_NAND_DISABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__INTERRUPT__)): \
  632. ((__INSTANCE__)->SR3 &= ~(__INTERRUPT__)))
  633. /**
  634. * @brief Get flag status of the NAND device.
  635. * @param __INSTANCE__ FMC_NAND Instance
  636. * @param __BANK__ FMC_NAND Bank
  637. * @param __FLAG__ FMC_NAND flag
  638. * This parameter can be any combination of the following values:
  639. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  640. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  641. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  642. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  643. * @retval The state of FLAG (SET or RESET).
  644. */
  645. #define __FMC_NAND_GET_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__BANK__) == FMC_NAND_BANK2)? (((__INSTANCE__)->SR2 &(__FLAG__)) == (__FLAG__)): \
  646. (((__INSTANCE__)->SR3 &(__FLAG__)) == (__FLAG__)))
  647. /**
  648. * @brief Clear flag status of the NAND device.
  649. * @param __INSTANCE__ FMC_NAND Instance
  650. * @param __BANK__ FMC_NAND Bank
  651. * @param __FLAG__ FMC_NAND flag
  652. * This parameter can be any combination of the following values:
  653. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  654. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  655. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  656. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  657. * @retval None
  658. */
  659. #define __FMC_NAND_CLEAR_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__FLAG__)): \
  660. ((__INSTANCE__)->SR3 &= ~(__FLAG__)))
  661. /**
  662. * @}
  663. */
  664. #endif /* FMC_BANK3 */
  665. #if defined(FMC_BANK4)
  666. /** @defgroup FMC_LL_PCCARD_Interrupt FMC PCCARD Interrupt
  667. * @brief macros to handle PCCARD interrupts
  668. * @{
  669. */
  670. /**
  671. * @brief Enable the PCCARD device interrupt.
  672. * @param __INSTANCE__ FMC_PCCARD instance
  673. * @param __INTERRUPT__ FMC_PCCARD interrupt
  674. * This parameter can be any combination of the following values:
  675. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  676. * @arg FMC_IT_LEVEL: Interrupt level.
  677. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  678. * @retval None
  679. */
  680. #define __FMC_PCCARD_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR4 |= (__INTERRUPT__))
  681. /**
  682. * @brief Disable the PCCARD device interrupt.
  683. * @param __INSTANCE__ FMC_PCCARD instance
  684. * @param __INTERRUPT__ FMC_PCCARD interrupt
  685. * This parameter can be any combination of the following values:
  686. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  687. * @arg FMC_IT_LEVEL: Interrupt level.
  688. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  689. * @retval None
  690. */
  691. #define __FMC_PCCARD_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR4 &= ~(__INTERRUPT__))
  692. /**
  693. * @brief Get flag status of the PCCARD device.
  694. * @param __INSTANCE__ FMC_PCCARD instance
  695. * @param __FLAG__ FMC_PCCARD flag
  696. * This parameter can be any combination of the following values:
  697. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  698. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  699. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  700. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  701. * @retval The state of FLAG (SET or RESET).
  702. */
  703. #define __FMC_PCCARD_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->SR4 &(__FLAG__)) == (__FLAG__))
  704. /**
  705. * @brief Clear flag status of the PCCARD device.
  706. * @param __INSTANCE__ FMC_PCCARD instance
  707. * @param __FLAG__ FMC_PCCARD flag
  708. * This parameter can be any combination of the following values:
  709. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  710. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  711. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  712. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  713. * @retval None
  714. */
  715. #define __FMC_PCCARD_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->SR4 &= ~(__FLAG__))
  716. /**
  717. * @}
  718. */
  719. #endif
  720. /**
  721. * @}
  722. */
  723. /**
  724. * @}
  725. */
  726. /* Private functions ---------------------------------------------------------*/
  727. /** @defgroup FMC_LL_Private_Functions FMC LL Private Functions
  728. * @{
  729. */
  730. #if defined(FMC_BANK1)
  731. /** @defgroup FMC_LL_NORSRAM NOR SRAM
  732. * @{
  733. */
  734. /** @defgroup FMC_LL_NORSRAM_Private_Functions_Group1 NOR SRAM Initialization/de-initialization functions
  735. * @{
  736. */
  737. HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device,
  738. FMC_NORSRAM_InitTypeDef *Init);
  739. HAL_StatusTypeDef FMC_NORSRAM_Timing_Init(FMC_NORSRAM_TypeDef *Device,
  740. FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank);
  741. HAL_StatusTypeDef FMC_NORSRAM_Extended_Timing_Init(FMC_NORSRAM_EXTENDED_TypeDef *Device,
  742. FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank,
  743. uint32_t ExtendedMode);
  744. HAL_StatusTypeDef FMC_NORSRAM_DeInit(FMC_NORSRAM_TypeDef *Device,
  745. FMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank);
  746. /**
  747. * @}
  748. */
  749. /** @defgroup FMC_LL_NORSRAM_Private_Functions_Group2 NOR SRAM Control functions
  750. * @{
  751. */
  752. HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Enable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  753. HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  754. /**
  755. * @}
  756. */
  757. /**
  758. * @}
  759. */
  760. #endif /* FMC_BANK1 */
  761. #if defined(FMC_BANK3)
  762. /** @defgroup FMC_LL_NAND NAND
  763. * @{
  764. */
  765. /** @defgroup FMC_LL_NAND_Private_Functions_Group1 NAND Initialization/de-initialization functions
  766. * @{
  767. */
  768. HAL_StatusTypeDef FMC_NAND_Init(FMC_NAND_TypeDef *Device, FMC_NAND_InitTypeDef *Init);
  769. HAL_StatusTypeDef FMC_NAND_CommonSpace_Timing_Init(FMC_NAND_TypeDef *Device,
  770. FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  771. HAL_StatusTypeDef FMC_NAND_AttributeSpace_Timing_Init(FMC_NAND_TypeDef *Device,
  772. FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  773. HAL_StatusTypeDef FMC_NAND_DeInit(FMC_NAND_TypeDef *Device, uint32_t Bank);
  774. /**
  775. * @}
  776. */
  777. /** @defgroup FMC_LL_NAND_Private_Functions_Group2 NAND Control functions
  778. * @{
  779. */
  780. HAL_StatusTypeDef FMC_NAND_ECC_Enable(FMC_NAND_TypeDef *Device, uint32_t Bank);
  781. HAL_StatusTypeDef FMC_NAND_ECC_Disable(FMC_NAND_TypeDef *Device, uint32_t Bank);
  782. HAL_StatusTypeDef FMC_NAND_GetECC(FMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank,
  783. uint32_t Timeout);
  784. /**
  785. * @}
  786. */
  787. /**
  788. * @}
  789. */
  790. #endif /* FMC_BANK3 */
  791. #if defined(FMC_BANK4)
  792. /** @defgroup FMC_LL_PCCARD PCCARD
  793. * @{
  794. */
  795. /** @defgroup FMC_LL_PCCARD_Private_Functions_Group1 PCCARD Initialization/de-initialization functions
  796. * @{
  797. */
  798. HAL_StatusTypeDef FMC_PCCARD_Init(FMC_PCCARD_TypeDef *Device, FMC_PCCARD_InitTypeDef *Init);
  799. HAL_StatusTypeDef FMC_PCCARD_CommonSpace_Timing_Init(FMC_PCCARD_TypeDef *Device,
  800. FMC_NAND_PCC_TimingTypeDef *Timing);
  801. HAL_StatusTypeDef FMC_PCCARD_AttributeSpace_Timing_Init(FMC_PCCARD_TypeDef *Device,
  802. FMC_NAND_PCC_TimingTypeDef *Timing);
  803. HAL_StatusTypeDef FMC_PCCARD_IOSpace_Timing_Init(FMC_PCCARD_TypeDef *Device,
  804. FMC_NAND_PCC_TimingTypeDef *Timing);
  805. HAL_StatusTypeDef FMC_PCCARD_DeInit(FMC_PCCARD_TypeDef *Device);
  806. /**
  807. * @}
  808. */
  809. /**
  810. * @}
  811. */
  812. #endif /* FMC_BANK4 */
  813. /**
  814. * @}
  815. */
  816. /**
  817. * @}
  818. */
  819. /**
  820. * @}
  821. */
  822. #ifdef __cplusplus
  823. }
  824. #endif
  825. #endif /* STM32F3xx_LL_FMC_H */