stm32l4xx_ll_fmc.h 35 KB

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