stm32g4xx_ll_fmc.h 35 KB

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