You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1149 lines
49 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_ll_fmc.h
  4. * @author MCD Application Team
  5. * @brief Header file of FMC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_LL_FMC_H
  21. #define STM32H7xx_LL_FMC_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup FMC_LL
  31. * @{
  32. */
  33. /** @addtogroup FMC_LL_Private_Macros
  34. * @{
  35. */
  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_BURSTMODE(__STATE__) (((__STATE__) == FMC_BURST_ACCESS_MODE_DISABLE) || \
  60. ((__STATE__) == FMC_BURST_ACCESS_MODE_ENABLE))
  61. #define IS_FMC_WAIT_POLARITY(__POLARITY__) (((__POLARITY__) == FMC_WAIT_SIGNAL_POLARITY_LOW) || \
  62. ((__POLARITY__) == FMC_WAIT_SIGNAL_POLARITY_HIGH))
  63. #define IS_FMC_WAIT_SIGNAL_ACTIVE(__ACTIVE__) (((__ACTIVE__) == FMC_WAIT_TIMING_BEFORE_WS) || \
  64. ((__ACTIVE__) == FMC_WAIT_TIMING_DURING_WS))
  65. #define IS_FMC_WRITE_OPERATION(__OPERATION__) (((__OPERATION__) == FMC_WRITE_OPERATION_DISABLE) || \
  66. ((__OPERATION__) == FMC_WRITE_OPERATION_ENABLE))
  67. #define IS_FMC_WAITE_SIGNAL(__SIGNAL__) (((__SIGNAL__) == FMC_WAIT_SIGNAL_DISABLE) || \
  68. ((__SIGNAL__) == FMC_WAIT_SIGNAL_ENABLE))
  69. #define IS_FMC_EXTENDED_MODE(__MODE__) (((__MODE__) == FMC_EXTENDED_MODE_DISABLE) || \
  70. ((__MODE__) == FMC_EXTENDED_MODE_ENABLE))
  71. #define IS_FMC_ASYNWAIT(__STATE__) (((__STATE__) == FMC_ASYNCHRONOUS_WAIT_DISABLE) || \
  72. ((__STATE__) == FMC_ASYNCHRONOUS_WAIT_ENABLE))
  73. #define IS_FMC_DATA_LATENCY(__LATENCY__) (((__LATENCY__) > 1U) && ((__LATENCY__) <= 17U))
  74. #define IS_FMC_WRITE_BURST(__BURST__) (((__BURST__) == FMC_WRITE_BURST_DISABLE) || \
  75. ((__BURST__) == FMC_WRITE_BURST_ENABLE))
  76. #define IS_FMC_CONTINOUS_CLOCK(__CCLOCK__) (((__CCLOCK__) == FMC_CONTINUOUS_CLOCK_SYNC_ONLY) || \
  77. ((__CCLOCK__) == FMC_CONTINUOUS_CLOCK_SYNC_ASYNC))
  78. #define IS_FMC_ADDRESS_SETUP_TIME(__TIME__) ((__TIME__) <= 15U)
  79. #define IS_FMC_ADDRESS_HOLD_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 15U))
  80. #define IS_FMC_DATASETUP_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 255U))
  81. #define IS_FMC_DATAHOLD_DURATION(__DATAHOLD__) ((__DATAHOLD__) <= 3U)
  82. #define IS_FMC_TURNAROUND_TIME(__TIME__) ((__TIME__) <= 15U)
  83. #define IS_FMC_CLK_DIV(__DIV__) (((__DIV__) > 1U) && ((__DIV__) <= 16U))
  84. #define IS_FMC_NORSRAM_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_NORSRAM_DEVICE)
  85. #define IS_FMC_NORSRAM_EXTENDED_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_NORSRAM_EXTENDED_DEVICE)
  86. #define IS_FMC_NAND_BANK(__BANK__) ((__BANK__) == FMC_NAND_BANK3)
  87. #define IS_FMC_WAIT_FEATURE(__FEATURE__) (((__FEATURE__) == FMC_NAND_WAIT_FEATURE_DISABLE) || \
  88. ((__FEATURE__) == FMC_NAND_WAIT_FEATURE_ENABLE))
  89. #define IS_FMC_NAND_MEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FMC_NAND_MEM_BUS_WIDTH_8) || \
  90. ((__WIDTH__) == FMC_NAND_MEM_BUS_WIDTH_16))
  91. #define IS_FMC_ECC_STATE(__STATE__) (((__STATE__) == FMC_NAND_ECC_DISABLE) || \
  92. ((__STATE__) == FMC_NAND_ECC_ENABLE))
  93. #define IS_FMC_ECCPAGE_SIZE(__SIZE__) (((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_256BYTE) || \
  94. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_512BYTE) || \
  95. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_1024BYTE) || \
  96. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_2048BYTE) || \
  97. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_4096BYTE) || \
  98. ((__SIZE__) == FMC_NAND_ECC_PAGE_SIZE_8192BYTE))
  99. #define IS_FMC_TCLR_TIME(__TIME__) ((__TIME__) <= 255U)
  100. #define IS_FMC_TAR_TIME(__TIME__) ((__TIME__) <= 255U)
  101. #define IS_FMC_SETUP_TIME(__TIME__) ((__TIME__) <= 254U)
  102. #define IS_FMC_WAIT_TIME(__TIME__) ((__TIME__) <= 254U)
  103. #define IS_FMC_HOLD_TIME(__TIME__) ((__TIME__) <= 254U)
  104. #define IS_FMC_HIZ_TIME(__TIME__) ((__TIME__) <= 254U)
  105. #define IS_FMC_NAND_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_NAND_DEVICE)
  106. #define IS_FMC_SDMEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FMC_SDRAM_MEM_BUS_WIDTH_8) || \
  107. ((__WIDTH__) == FMC_SDRAM_MEM_BUS_WIDTH_16) || \
  108. ((__WIDTH__) == FMC_SDRAM_MEM_BUS_WIDTH_32))
  109. #define IS_FMC_WRITE_PROTECTION(__WRITE__) (((__WRITE__) == FMC_SDRAM_WRITE_PROTECTION_DISABLE) || \
  110. ((__WRITE__) == FMC_SDRAM_WRITE_PROTECTION_ENABLE))
  111. #define IS_FMC_SDCLOCK_PERIOD(__PERIOD__) (((__PERIOD__) == FMC_SDRAM_CLOCK_DISABLE) || \
  112. ((__PERIOD__) == FMC_SDRAM_CLOCK_PERIOD_2) || \
  113. ((__PERIOD__) == FMC_SDRAM_CLOCK_PERIOD_3))
  114. #define IS_FMC_READ_BURST(__RBURST__) (((__RBURST__) == FMC_SDRAM_RBURST_DISABLE) || \
  115. ((__RBURST__) == FMC_SDRAM_RBURST_ENABLE))
  116. #define IS_FMC_READPIPE_DELAY(__DELAY__) (((__DELAY__) == FMC_SDRAM_RPIPE_DELAY_0) || \
  117. ((__DELAY__) == FMC_SDRAM_RPIPE_DELAY_1) || \
  118. ((__DELAY__) == FMC_SDRAM_RPIPE_DELAY_2))
  119. #define IS_FMC_COMMAND_MODE(__COMMAND__) (((__COMMAND__) == FMC_SDRAM_CMD_NORMAL_MODE) || \
  120. ((__COMMAND__) == FMC_SDRAM_CMD_CLK_ENABLE) || \
  121. ((__COMMAND__) == FMC_SDRAM_CMD_PALL) || \
  122. ((__COMMAND__) == FMC_SDRAM_CMD_AUTOREFRESH_MODE) || \
  123. ((__COMMAND__) == FMC_SDRAM_CMD_LOAD_MODE) || \
  124. ((__COMMAND__) == FMC_SDRAM_CMD_SELFREFRESH_MODE) || \
  125. ((__COMMAND__) == FMC_SDRAM_CMD_POWERDOWN_MODE))
  126. #define IS_FMC_COMMAND_TARGET(__TARGET__) (((__TARGET__) == FMC_SDRAM_CMD_TARGET_BANK1) || \
  127. ((__TARGET__) == FMC_SDRAM_CMD_TARGET_BANK2) || \
  128. ((__TARGET__) == FMC_SDRAM_CMD_TARGET_BANK1_2))
  129. #define IS_FMC_LOADTOACTIVE_DELAY(__DELAY__) (((__DELAY__) > 0U) && ((__DELAY__) <= 16U))
  130. #define IS_FMC_EXITSELFREFRESH_DELAY(__DELAY__) (((__DELAY__) > 0U) && ((__DELAY__) <= 16U))
  131. #define IS_FMC_SELFREFRESH_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 16U))
  132. #define IS_FMC_ROWCYCLE_DELAY(__DELAY__) (((__DELAY__) > 0U) && ((__DELAY__) <= 16U))
  133. #define IS_FMC_WRITE_RECOVERY_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 16U))
  134. #define IS_FMC_RP_DELAY(__DELAY__) (((__DELAY__) > 0U) && ((__DELAY__) <= 16U))
  135. #define IS_FMC_RCD_DELAY(__DELAY__) (((__DELAY__) > 0U) && ((__DELAY__) <= 16U))
  136. #define IS_FMC_AUTOREFRESH_NUMBER(__NUMBER__) (((__NUMBER__) > 0U) && ((__NUMBER__) <= 15U))
  137. #define IS_FMC_MODE_REGISTER(__CONTENT__) ((__CONTENT__) <= 8191U)
  138. #define IS_FMC_REFRESH_RATE(__RATE__) ((__RATE__) <= 8191U)
  139. #define IS_FMC_SDRAM_DEVICE(__INSTANCE__) ((__INSTANCE__) == FMC_SDRAM_DEVICE)
  140. #define IS_FMC_SDRAM_BANK(__BANK__) (((__BANK__) == FMC_SDRAM_BANK1) || \
  141. ((__BANK__) == FMC_SDRAM_BANK2))
  142. #define IS_FMC_COLUMNBITS_NUMBER(__COLUMN__) (((__COLUMN__) == FMC_SDRAM_COLUMN_BITS_NUM_8) || \
  143. ((__COLUMN__) == FMC_SDRAM_COLUMN_BITS_NUM_9) || \
  144. ((__COLUMN__) == FMC_SDRAM_COLUMN_BITS_NUM_10) || \
  145. ((__COLUMN__) == FMC_SDRAM_COLUMN_BITS_NUM_11))
  146. #define IS_FMC_ROWBITS_NUMBER(__ROW__) (((__ROW__) == FMC_SDRAM_ROW_BITS_NUM_11) || \
  147. ((__ROW__) == FMC_SDRAM_ROW_BITS_NUM_12) || \
  148. ((__ROW__) == FMC_SDRAM_ROW_BITS_NUM_13))
  149. #define IS_FMC_INTERNALBANK_NUMBER(__NUMBER__) (((__NUMBER__) == FMC_SDRAM_INTERN_BANKS_NUM_2) || \
  150. ((__NUMBER__) == FMC_SDRAM_INTERN_BANKS_NUM_4))
  151. #define IS_FMC_CAS_LATENCY(__LATENCY__) (((__LATENCY__) == FMC_SDRAM_CAS_LATENCY_1) || \
  152. ((__LATENCY__) == FMC_SDRAM_CAS_LATENCY_2) || \
  153. ((__LATENCY__) == FMC_SDRAM_CAS_LATENCY_3))
  154. /**
  155. * @}
  156. */
  157. /* Exported typedef ----------------------------------------------------------*/
  158. /** @defgroup FMC_LL_Exported_typedef FMC Low Layer Exported Types
  159. * @{
  160. */
  161. #define FMC_NORSRAM_TypeDef FMC_Bank1_TypeDef
  162. #define FMC_NORSRAM_EXTENDED_TypeDef FMC_Bank1E_TypeDef
  163. #define FMC_NAND_TypeDef FMC_Bank3_TypeDef
  164. #define FMC_SDRAM_TypeDef FMC_Bank5_6_TypeDef
  165. #define FMC_NORSRAM_DEVICE FMC_Bank1_R
  166. #define FMC_NORSRAM_EXTENDED_DEVICE FMC_Bank1E_R
  167. #define FMC_NAND_DEVICE FMC_Bank3_R
  168. #define FMC_SDRAM_DEVICE FMC_Bank5_6_R
  169. /**
  170. * @brief FMC NORSRAM Configuration Structure definition
  171. */
  172. typedef struct
  173. {
  174. uint32_t NSBank; /*!< Specifies the NORSRAM memory device that will be used.
  175. This parameter can be a value of @ref FMC_NORSRAM_Bank */
  176. uint32_t DataAddressMux; /*!< Specifies whether the address and data values are
  177. multiplexed on the data bus or not.
  178. This parameter can be a value of @ref FMC_Data_Address_Bus_Multiplexing */
  179. uint32_t MemoryType; /*!< Specifies the type of external memory attached to
  180. the corresponding memory device.
  181. This parameter can be a value of @ref FMC_Memory_Type */
  182. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  183. This parameter can be a value of @ref FMC_NORSRAM_Data_Width */
  184. uint32_t BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory,
  185. valid only with synchronous burst Flash memories.
  186. This parameter can be a value of @ref FMC_Burst_Access_Mode */
  187. uint32_t WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing
  188. the Flash memory in burst mode.
  189. This parameter can be a value of @ref FMC_Wait_Signal_Polarity */
  190. uint32_t WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one
  191. clock cycle before the wait state or during the wait state,
  192. valid only when accessing memories in burst mode.
  193. This parameter can be a value of @ref FMC_Wait_Timing */
  194. uint32_t WriteOperation; /*!< Enables or disables the write operation in the selected device by the FMC.
  195. This parameter can be a value of @ref FMC_Write_Operation */
  196. uint32_t WaitSignal; /*!< Enables or disables the wait state insertion via wait
  197. signal, valid for Flash memory access in burst mode.
  198. This parameter can be a value of @ref FMC_Wait_Signal */
  199. uint32_t ExtendedMode; /*!< Enables or disables the extended mode.
  200. This parameter can be a value of @ref FMC_Extended_Mode */
  201. uint32_t AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers,
  202. valid only with asynchronous Flash memories.
  203. This parameter can be a value of @ref FMC_AsynchronousWait */
  204. uint32_t WriteBurst; /*!< Enables or disables the write burst operation.
  205. This parameter can be a value of @ref FMC_Write_Burst */
  206. uint32_t ContinuousClock; /*!< Enables or disables the FMC clock output to external memory devices.
  207. This parameter is only enabled through the FMC_BCR1 register, and don't care
  208. through FMC_BCR2..4 registers.
  209. This parameter can be a value of @ref FMC_Continous_Clock */
  210. uint32_t WriteFifo; /*!< Enables or disables the write FIFO used by the FMC controller.
  211. This parameter is only enabled through the FMC_BCR1 register, and don't care
  212. through FMC_BCR2..4 registers.
  213. This parameter can be a value of @ref FMC_Write_FIFO */
  214. uint32_t PageSize; /*!< Specifies the memory page size.
  215. This parameter can be a value of @ref FMC_Page_Size */
  216. }FMC_NORSRAM_InitTypeDef;
  217. /**
  218. * @brief FMC NORSRAM Timing parameters structure definition
  219. */
  220. typedef struct
  221. {
  222. uint32_t AddressSetupTime; /*!< Defines the number of HCLK cycles to configure
  223. the duration of the address setup time.
  224. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  225. @note This parameter is not used with synchronous NOR Flash memories. */
  226. uint32_t AddressHoldTime; /*!< Defines the number of HCLK cycles to configure
  227. the duration of the address hold time.
  228. This parameter can be a value between Min_Data = 1 and Max_Data = 15.
  229. @note This parameter is not used with synchronous NOR Flash memories. */
  230. uint32_t DataSetupTime; /*!< Defines the number of HCLK cycles to configure
  231. the duration of the data setup time.
  232. This parameter can be a value between Min_Data = 1 and Max_Data = 255.
  233. @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed
  234. NOR Flash memories. */
  235. uint32_t BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure
  236. the duration of the bus turnaround.
  237. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  238. @note This parameter is only used for multiplexed NOR Flash memories. */
  239. uint32_t CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of
  240. HCLK cycles. This parameter can be a value between Min_Data = 2 and Max_Data = 16.
  241. @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM
  242. accesses. */
  243. uint32_t DataLatency; /*!< Defines the number of memory clock cycles to issue
  244. to the memory before getting the first data.
  245. The parameter value depends on the memory type as shown below:
  246. - It must be set to 0 in case of a CRAM
  247. - It is don't care in asynchronous NOR, SRAM or ROM accesses
  248. - It may assume a value between Min_Data = 2 and Max_Data = 17 in NOR Flash memories
  249. with synchronous burst mode enable */
  250. uint32_t AccessMode; /*!< Specifies the asynchronous access mode.
  251. This parameter can be a value of @ref FMC_Access_Mode */
  252. }FMC_NORSRAM_TimingTypeDef;
  253. /**
  254. * @brief FMC NAND Configuration Structure definition
  255. */
  256. typedef struct
  257. {
  258. uint32_t NandBank; /*!< Specifies the NAND memory device that will be used.
  259. This parameter can be a value of @ref FMC_NAND_Bank */
  260. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory device.
  261. This parameter can be any value of @ref FMC_Wait_feature */
  262. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  263. This parameter can be any value of @ref FMC_NAND_Data_Width */
  264. uint32_t EccComputation; /*!< Enables or disables the ECC computation.
  265. This parameter can be any value of @ref FMC_ECC */
  266. uint32_t ECCPageSize; /*!< Defines the page size for the extended ECC.
  267. This parameter can be any value of @ref FMC_ECC_Page_Size */
  268. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  269. delay between CLE low and RE low.
  270. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  271. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  272. delay between ALE low and RE low.
  273. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  274. }FMC_NAND_InitTypeDef;
  275. /**
  276. * @brief FMC NAND Timing parameters structure definition
  277. */
  278. typedef struct
  279. {
  280. uint32_t SetupTime; /*!< Defines the number of HCLK cycles to setup address before
  281. the command assertion for NAND-Flash read or write access
  282. to common/Attribute or I/O memory space (depending on
  283. the memory space timing to be configured).
  284. This parameter can be a value between Min_Data = 0 and Max_Data = 254 */
  285. uint32_t WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the
  286. command for NAND-Flash read or write access to
  287. common/Attribute or I/O memory space (depending on the
  288. memory space timing to be configured).
  289. This parameter can be a number between Min_Data = 0 and Max_Data = 254 */
  290. uint32_t HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address
  291. (and data for write access) after the command de-assertion
  292. for NAND-Flash read or write access to common/Attribute
  293. or I/O memory space (depending on the memory space timing
  294. to be configured).
  295. This parameter can be a number between Min_Data = 0 and Max_Data = 254 */
  296. uint32_t HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the
  297. data bus is kept in HiZ after the start of a NAND-Flash
  298. write access to common/Attribute or I/O memory space (depending
  299. on the memory space timing to be configured).
  300. This parameter can be a number between Min_Data = 0 and Max_Data = 254 */
  301. }FMC_NAND_PCC_TimingTypeDef;
  302. /**
  303. * @brief FMC SDRAM Configuration Structure definition
  304. */
  305. typedef struct
  306. {
  307. uint32_t SDBank; /*!< Specifies the SDRAM memory device that will be used.
  308. This parameter can be a value of @ref FMC_SDRAM_Bank */
  309. uint32_t ColumnBitsNumber; /*!< Defines the number of bits of column address.
  310. This parameter can be a value of @ref FMC_SDRAM_Column_Bits_number. */
  311. uint32_t RowBitsNumber; /*!< Defines the number of bits of column address.
  312. This parameter can be a value of @ref FMC_SDRAM_Row_Bits_number. */
  313. uint32_t MemoryDataWidth; /*!< Defines the memory device width.
  314. This parameter can be a value of @ref FMC_SDRAM_Memory_Bus_Width. */
  315. uint32_t InternalBankNumber; /*!< Defines the number of the device's internal banks.
  316. This parameter can be of @ref FMC_SDRAM_Internal_Banks_Number. */
  317. uint32_t CASLatency; /*!< Defines the SDRAM CAS latency in number of memory clock cycles.
  318. This parameter can be a value of @ref FMC_SDRAM_CAS_Latency. */
  319. uint32_t WriteProtection; /*!< Enables the SDRAM device to be accessed in write mode.
  320. This parameter can be a value of @ref FMC_SDRAM_Write_Protection. */
  321. uint32_t SDClockPeriod; /*!< Define the SDRAM Clock Period for both SDRAM devices and they allow
  322. to disable the clock before changing frequency.
  323. This parameter can be a value of @ref FMC_SDRAM_Clock_Period. */
  324. uint32_t ReadBurst; /*!< This bit enable the SDRAM controller to anticipate the next read
  325. commands during the CAS latency and stores data in the Read FIFO.
  326. This parameter can be a value of @ref FMC_SDRAM_Read_Burst. */
  327. uint32_t ReadPipeDelay; /*!< Define the delay in system clock cycles on read data path.
  328. This parameter can be a value of @ref FMC_SDRAM_Read_Pipe_Delay. */
  329. }FMC_SDRAM_InitTypeDef;
  330. /**
  331. * @brief FMC SDRAM Timing parameters structure definition
  332. */
  333. typedef struct
  334. {
  335. uint32_t LoadToActiveDelay; /*!< Defines the delay between a Load Mode Register command and
  336. an active or Refresh command in number of memory clock cycles.
  337. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  338. uint32_t ExitSelfRefreshDelay; /*!< Defines the delay from releasing the self refresh command to
  339. issuing the Activate command in number of memory clock cycles.
  340. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  341. uint32_t SelfRefreshTime; /*!< Defines the minimum Self Refresh period in number of memory clock
  342. cycles.
  343. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  344. uint32_t RowCycleDelay; /*!< Defines the delay between the Refresh command and the Activate command
  345. and the delay between two consecutive Refresh commands in number of
  346. memory clock cycles.
  347. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  348. uint32_t WriteRecoveryTime; /*!< Defines the Write recovery Time in number of memory clock cycles.
  349. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  350. uint32_t RPDelay; /*!< Defines the delay between a Precharge Command and an other command
  351. in number of memory clock cycles.
  352. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  353. uint32_t RCDDelay; /*!< Defines the delay between the Activate Command and a Read/Write
  354. command in number of memory clock cycles.
  355. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  356. }FMC_SDRAM_TimingTypeDef;
  357. /**
  358. * @brief SDRAM command parameters structure definition
  359. */
  360. typedef struct
  361. {
  362. uint32_t CommandMode; /*!< Defines the command issued to the SDRAM device.
  363. This parameter can be a value of @ref FMC_SDRAM_Command_Mode. */
  364. uint32_t CommandTarget; /*!< Defines which device (1 or 2) the command will be issued to.
  365. This parameter can be a value of @ref FMC_SDRAM_Command_Target. */
  366. uint32_t AutoRefreshNumber; /*!< Defines the number of consecutive auto refresh command issued
  367. in auto refresh mode.
  368. This parameter can be a value between Min_Data = 1 and Max_Data = 15 */
  369. uint32_t ModeRegisterDefinition; /*!< Defines the SDRAM Mode register content */
  370. }FMC_SDRAM_CommandTypeDef;
  371. /**
  372. * @}
  373. */
  374. /* Exported constants --------------------------------------------------------*/
  375. /** @addtogroup FMC_LL_Exported_Constants FMC Low Layer Exported Constants
  376. * @{
  377. */
  378. /** @defgroup FMC_LL_NOR_SRAM_Controller FMC NOR/SRAM Controller
  379. * @{
  380. */
  381. /** @defgroup FMC_NORSRAM_Bank FMC NOR/SRAM Bank
  382. * @{
  383. */
  384. #define FMC_NORSRAM_BANK1 ((uint32_t)0x00000000U)
  385. #define FMC_NORSRAM_BANK2 ((uint32_t)0x00000002U)
  386. #define FMC_NORSRAM_BANK3 ((uint32_t)0x00000004U)
  387. #define FMC_NORSRAM_BANK4 ((uint32_t)0x00000006U)
  388. /**
  389. * @}
  390. */
  391. /** @defgroup FMC_Data_Address_Bus_Multiplexing FMC Data Address Bus Multiplexing
  392. * @{
  393. */
  394. #define FMC_DATA_ADDRESS_MUX_DISABLE ((uint32_t)0x00000000U)
  395. #define FMC_DATA_ADDRESS_MUX_ENABLE ((uint32_t)0x00000002U)
  396. /**
  397. * @}
  398. */
  399. /** @defgroup FMC_Memory_Type FMC Memory Type
  400. * @{
  401. */
  402. #define FMC_MEMORY_TYPE_SRAM ((uint32_t)0x00000000U)
  403. #define FMC_MEMORY_TYPE_PSRAM ((uint32_t)0x00000004U)
  404. #define FMC_MEMORY_TYPE_NOR ((uint32_t)0x00000008U)
  405. /**
  406. * @}
  407. */
  408. /** @defgroup FMC_NORSRAM_Data_Width FMC NORSRAM Data Width
  409. * @{
  410. */
  411. #define FMC_NORSRAM_MEM_BUS_WIDTH_8 ((uint32_t)0x00000000U)
  412. #define FMC_NORSRAM_MEM_BUS_WIDTH_16 ((uint32_t)0x00000010U)
  413. #define FMC_NORSRAM_MEM_BUS_WIDTH_32 ((uint32_t)0x00000020U)
  414. /**
  415. * @}
  416. */
  417. /** @defgroup FMC_NORSRAM_Flash_Access FMC NOR/SRAM Flash Access
  418. * @{
  419. */
  420. #define FMC_NORSRAM_FLASH_ACCESS_ENABLE ((uint32_t)0x00000040U)
  421. #define FMC_NORSRAM_FLASH_ACCESS_DISABLE ((uint32_t)0x00000000U)
  422. /**
  423. * @}
  424. */
  425. /** @defgroup FMC_Burst_Access_Mode FMC Burst Access Mode
  426. * @{
  427. */
  428. #define FMC_BURST_ACCESS_MODE_DISABLE ((uint32_t)0x00000000U)
  429. #define FMC_BURST_ACCESS_MODE_ENABLE ((uint32_t)0x00000100U)
  430. /**
  431. * @}
  432. */
  433. /** @defgroup FMC_Wait_Signal_Polarity FMC Wait Signal Polarity
  434. * @{
  435. */
  436. #define FMC_WAIT_SIGNAL_POLARITY_LOW ((uint32_t)0x00000000U)
  437. #define FMC_WAIT_SIGNAL_POLARITY_HIGH ((uint32_t)0x00000200U)
  438. /**
  439. * @}
  440. */
  441. /** @defgroup FMC_Wait_Timing FMC Wait Timing
  442. * @{
  443. */
  444. #define FMC_WAIT_TIMING_BEFORE_WS ((uint32_t)0x00000000U)
  445. #define FMC_WAIT_TIMING_DURING_WS ((uint32_t)0x00000800U)
  446. /**
  447. * @}
  448. */
  449. /** @defgroup FMC_Write_Operation FMC Write Operation
  450. * @{
  451. */
  452. #define FMC_WRITE_OPERATION_DISABLE ((uint32_t)0x00000000U)
  453. #define FMC_WRITE_OPERATION_ENABLE ((uint32_t)0x00001000U)
  454. /**
  455. * @}
  456. */
  457. /** @defgroup FMC_Wait_Signal FMC Wait Signal
  458. * @{
  459. */
  460. #define FMC_WAIT_SIGNAL_DISABLE ((uint32_t)0x00000000U)
  461. #define FMC_WAIT_SIGNAL_ENABLE ((uint32_t)0x00002000U)
  462. /**
  463. * @}
  464. */
  465. /** @defgroup FMC_Extended_Mode FMC Extended Mode
  466. * @{
  467. */
  468. #define FMC_EXTENDED_MODE_DISABLE ((uint32_t)0x00000000U)
  469. #define FMC_EXTENDED_MODE_ENABLE ((uint32_t)0x00004000U)
  470. /**
  471. * @}
  472. */
  473. /** @defgroup FMC_AsynchronousWait FMC Asynchronous Wait
  474. * @{
  475. */
  476. #define FMC_ASYNCHRONOUS_WAIT_DISABLE ((uint32_t)0x00000000U)
  477. #define FMC_ASYNCHRONOUS_WAIT_ENABLE ((uint32_t)0x00008000U)
  478. /**
  479. * @}
  480. */
  481. /** @defgroup FMC_Page_Size FMC Page Size
  482. * @{
  483. */
  484. #define FMC_PAGE_SIZE_NONE ((uint32_t)0x00000000U)
  485. #define FMC_PAGE_SIZE_128 ((uint32_t)FMC_BCRx_CPSIZE_0)
  486. #define FMC_PAGE_SIZE_256 ((uint32_t)FMC_BCRx_CPSIZE_1)
  487. #define FMC_PAGE_SIZE_512 ((uint32_t)(FMC_BCRx_CPSIZE_0 | FMC_BCRx_CPSIZE_1))
  488. #define FMC_PAGE_SIZE_1024 ((uint32_t)FMC_BCRx_CPSIZE_2)
  489. /**
  490. * @}
  491. */
  492. /** @defgroup FMC_Write_Burst FMC Write Burst
  493. * @{
  494. */
  495. #define FMC_WRITE_BURST_DISABLE ((uint32_t)0x00000000U)
  496. #define FMC_WRITE_BURST_ENABLE ((uint32_t)0x00080000U)
  497. /**
  498. * @}
  499. */
  500. /** @defgroup FMC_Continous_Clock FMC Continuous Clock
  501. * @{
  502. */
  503. #define FMC_CONTINUOUS_CLOCK_SYNC_ONLY ((uint32_t)0x00000000U)
  504. #define FMC_CONTINUOUS_CLOCK_SYNC_ASYNC ((uint32_t)0x00100000U)
  505. /**
  506. * @}
  507. */
  508. /** @defgroup FMC_Write_FIFO FMC Write FIFO
  509. * @{
  510. */
  511. #define FMC_WRITE_FIFO_DISABLE ((uint32_t)FMC_BCR1_WFDIS)
  512. #define FMC_WRITE_FIFO_ENABLE ((uint32_t)0x00000000U)
  513. /**
  514. * @}
  515. */
  516. /** @defgroup FMC_Access_Mode FMC Access Mode
  517. * @{
  518. */
  519. #define FMC_ACCESS_MODE_A ((uint32_t)0x00000000U)
  520. #define FMC_ACCESS_MODE_B ((uint32_t)0x10000000U)
  521. #define FMC_ACCESS_MODE_C ((uint32_t)0x20000000U)
  522. #define FMC_ACCESS_MODE_D ((uint32_t)0x30000000U)
  523. /**
  524. * @}
  525. */
  526. /**
  527. * @}
  528. */
  529. /** @defgroup FMC_LL_NAND_Controller FMC NAND Controller
  530. * @{
  531. */
  532. /** @defgroup FMC_NAND_Bank FMC NAND Bank
  533. * @{
  534. */
  535. #define FMC_NAND_BANK3 ((uint32_t)0x00000100U)
  536. /**
  537. * @}
  538. */
  539. /** @defgroup FMC_Wait_feature FMC Wait feature
  540. * @{
  541. */
  542. #define FMC_NAND_WAIT_FEATURE_DISABLE ((uint32_t)0x00000000U)
  543. #define FMC_NAND_WAIT_FEATURE_ENABLE ((uint32_t)0x00000002U)
  544. /**
  545. * @}
  546. */
  547. /** @defgroup FMC_PCR_Memory_Type FMC PCR Memory Type
  548. * @{
  549. */
  550. #define FMC_PCR_MEMORY_TYPE_NAND ((uint32_t)0x00000008U)
  551. /**
  552. * @}
  553. */
  554. /** @defgroup FMC_NAND_Data_Width FMC NAND Data Width
  555. * @{
  556. */
  557. #define FMC_NAND_MEM_BUS_WIDTH_8 ((uint32_t)0x00000000U)
  558. #define FMC_NAND_MEM_BUS_WIDTH_16 ((uint32_t)0x00000010U)
  559. /**
  560. * @}
  561. */
  562. /** @defgroup FMC_ECC FMC ECC
  563. * @{
  564. */
  565. #define FMC_NAND_ECC_DISABLE ((uint32_t)0x00000000U)
  566. #define FMC_NAND_ECC_ENABLE ((uint32_t)0x00000040U)
  567. /**
  568. * @}
  569. */
  570. /** @defgroup FMC_ECC_Page_Size FMC ECC Page Size
  571. * @{
  572. */
  573. #define FMC_NAND_ECC_PAGE_SIZE_256BYTE ((uint32_t)0x00000000U)
  574. #define FMC_NAND_ECC_PAGE_SIZE_512BYTE ((uint32_t)0x00020000U)
  575. #define FMC_NAND_ECC_PAGE_SIZE_1024BYTE ((uint32_t)0x00040000U)
  576. #define FMC_NAND_ECC_PAGE_SIZE_2048BYTE ((uint32_t)0x00060000U)
  577. #define FMC_NAND_ECC_PAGE_SIZE_4096BYTE ((uint32_t)0x00080000U)
  578. #define FMC_NAND_ECC_PAGE_SIZE_8192BYTE ((uint32_t)0x000A0000U)
  579. /**
  580. * @}
  581. */
  582. /**
  583. * @}
  584. */
  585. /** @defgroup FMC_LL_SDRAM_Controller FMC SDRAM Controller
  586. * @{
  587. */
  588. /** @defgroup FMC_SDRAM_Bank FMC SDRAM Bank
  589. * @{
  590. */
  591. #define FMC_SDRAM_BANK1 ((uint32_t)0x00000000U)
  592. #define FMC_SDRAM_BANK2 ((uint32_t)0x00000001U)
  593. /**
  594. * @}
  595. */
  596. /** @defgroup FMC_SDRAM_Column_Bits_number FMC SDRAM Column Bits number
  597. * @{
  598. */
  599. #define FMC_SDRAM_COLUMN_BITS_NUM_8 ((uint32_t)0x00000000U)
  600. #define FMC_SDRAM_COLUMN_BITS_NUM_9 ((uint32_t)0x00000001U)
  601. #define FMC_SDRAM_COLUMN_BITS_NUM_10 ((uint32_t)0x00000002U)
  602. #define FMC_SDRAM_COLUMN_BITS_NUM_11 ((uint32_t)0x00000003U)
  603. /**
  604. * @}
  605. */
  606. /** @defgroup FMC_SDRAM_Row_Bits_number FMC SDRAM Row Bits number
  607. * @{
  608. */
  609. #define FMC_SDRAM_ROW_BITS_NUM_11 ((uint32_t)0x00000000U)
  610. #define FMC_SDRAM_ROW_BITS_NUM_12 ((uint32_t)0x00000004U)
  611. #define FMC_SDRAM_ROW_BITS_NUM_13 ((uint32_t)0x00000008U)
  612. /**
  613. * @}
  614. */
  615. /** @defgroup FMC_SDRAM_Memory_Bus_Width FMC SDRAM Memory Bus Width
  616. * @{
  617. */
  618. #define FMC_SDRAM_MEM_BUS_WIDTH_8 ((uint32_t)0x00000000U)
  619. #define FMC_SDRAM_MEM_BUS_WIDTH_16 ((uint32_t)0x00000010U)
  620. #define FMC_SDRAM_MEM_BUS_WIDTH_32 ((uint32_t)0x00000020U)
  621. /**
  622. * @}
  623. */
  624. /** @defgroup FMC_SDRAM_Internal_Banks_Number FMC SDRAM Internal Banks Number
  625. * @{
  626. */
  627. #define FMC_SDRAM_INTERN_BANKS_NUM_2 ((uint32_t)0x00000000U)
  628. #define FMC_SDRAM_INTERN_BANKS_NUM_4 ((uint32_t)0x00000040U)
  629. /**
  630. * @}
  631. */
  632. /** @defgroup FMC_SDRAM_CAS_Latency FMC SDRAM CAS Latency
  633. * @{
  634. */
  635. #define FMC_SDRAM_CAS_LATENCY_1 ((uint32_t)0x00000080U)
  636. #define FMC_SDRAM_CAS_LATENCY_2 ((uint32_t)0x00000100U)
  637. #define FMC_SDRAM_CAS_LATENCY_3 ((uint32_t)0x00000180U)
  638. /**
  639. * @}
  640. */
  641. /** @defgroup FMC_SDRAM_Write_Protection FMC SDRAM Write Protection
  642. * @{
  643. */
  644. #define FMC_SDRAM_WRITE_PROTECTION_DISABLE ((uint32_t)0x00000000U)
  645. #define FMC_SDRAM_WRITE_PROTECTION_ENABLE ((uint32_t)0x00000200U)
  646. /**
  647. * @}
  648. */
  649. /** @defgroup FMC_SDRAM_Clock_Period FMC SDRAM Clock Period
  650. * @{
  651. */
  652. #define FMC_SDRAM_CLOCK_DISABLE ((uint32_t)0x00000000U)
  653. #define FMC_SDRAM_CLOCK_PERIOD_2 ((uint32_t)0x00000800U)
  654. #define FMC_SDRAM_CLOCK_PERIOD_3 ((uint32_t)0x00000C00U)
  655. /**
  656. * @}
  657. */
  658. /** @defgroup FMC_SDRAM_Read_Burst FMC SDRAM Read Burst
  659. * @{
  660. */
  661. #define FMC_SDRAM_RBURST_DISABLE ((uint32_t)0x00000000U)
  662. #define FMC_SDRAM_RBURST_ENABLE ((uint32_t)0x00001000U)
  663. /**
  664. * @}
  665. */
  666. /** @defgroup FMC_SDRAM_Read_Pipe_Delay FMC SDRAM Read Pipe Delay
  667. * @{
  668. */
  669. #define FMC_SDRAM_RPIPE_DELAY_0 ((uint32_t)0x00000000U)
  670. #define FMC_SDRAM_RPIPE_DELAY_1 ((uint32_t)0x00002000U)
  671. #define FMC_SDRAM_RPIPE_DELAY_2 ((uint32_t)0x00004000U)
  672. /**
  673. * @}
  674. */
  675. /** @defgroup FMC_SDRAM_Command_Mode FMC SDRAM Command Mode
  676. * @{
  677. */
  678. #define FMC_SDRAM_CMD_NORMAL_MODE ((uint32_t)0x00000000U)
  679. #define FMC_SDRAM_CMD_CLK_ENABLE ((uint32_t)0x00000001U)
  680. #define FMC_SDRAM_CMD_PALL ((uint32_t)0x00000002U)
  681. #define FMC_SDRAM_CMD_AUTOREFRESH_MODE ((uint32_t)0x00000003U)
  682. #define FMC_SDRAM_CMD_LOAD_MODE ((uint32_t)0x00000004U)
  683. #define FMC_SDRAM_CMD_SELFREFRESH_MODE ((uint32_t)0x00000005U)
  684. #define FMC_SDRAM_CMD_POWERDOWN_MODE ((uint32_t)0x00000006U)
  685. /**
  686. * @}
  687. */
  688. /** @defgroup FMC_SDRAM_Command_Target FMC SDRAM Command Target
  689. * @{
  690. */
  691. #define FMC_SDRAM_CMD_TARGET_BANK2 FMC_SDCMR_CTB2
  692. #define FMC_SDRAM_CMD_TARGET_BANK1 FMC_SDCMR_CTB1
  693. #define FMC_SDRAM_CMD_TARGET_BANK1_2 ((uint32_t)0x00000018U)
  694. /**
  695. * @}
  696. */
  697. /** @defgroup FMC_SDRAM_Mode_Status FMC SDRAM Mode Status
  698. * @{
  699. */
  700. #define FMC_SDRAM_NORMAL_MODE ((uint32_t)0x00000000U)
  701. #define FMC_SDRAM_SELF_REFRESH_MODE FMC_SDSR_MODES1_0
  702. #define FMC_SDRAM_POWER_DOWN_MODE FMC_SDSR_MODES1_1
  703. /**
  704. * @}
  705. */
  706. /**
  707. * @}
  708. */
  709. /** @defgroup FMC_LL_Interrupt_definition FMC Low Layer Interrupt definition
  710. * @{
  711. */
  712. #define FMC_IT_RISING_EDGE ((uint32_t)0x00000008U)
  713. #define FMC_IT_LEVEL ((uint32_t)0x00000010U)
  714. #define FMC_IT_FALLING_EDGE ((uint32_t)0x00000020U)
  715. #define FMC_IT_REFRESH_ERROR ((uint32_t)0x00004000U)
  716. /**
  717. * @}
  718. */
  719. /** @defgroup FMC_LL_Flag_definition FMC Low Layer Flag definition
  720. * @{
  721. */
  722. #define FMC_FLAG_RISING_EDGE ((uint32_t)0x00000001U)
  723. #define FMC_FLAG_LEVEL ((uint32_t)0x00000002U)
  724. #define FMC_FLAG_FALLING_EDGE ((uint32_t)0x00000004U)
  725. #define FMC_FLAG_FEMPT ((uint32_t)0x00000040U)
  726. #define FMC_SDRAM_FLAG_REFRESH_IT FMC_SDSR_RE
  727. #define FMC_SDRAM_FLAG_BUSY FMC_SDSR_BUSY
  728. #define FMC_SDRAM_FLAG_REFRESH_ERROR FMC_SDRTR_CRE
  729. /**
  730. * @}
  731. */
  732. /**
  733. * @}
  734. */
  735. /**
  736. * @}
  737. */
  738. /* Private macro -------------------------------------------------------------*/
  739. /** @defgroup FMC_LL_Private_Macros FMC_LL Private Macros
  740. * @{
  741. */
  742. /**
  743. * @brief Enable the FMC Peripheral.
  744. * @retval None
  745. */
  746. #define __FMC_ENABLE() (FMC_Bank1_R->BTCR[0] |= FMC_BCR1_FMCEN)
  747. /**
  748. * @brief Disable the FMC Peripheral.
  749. * @retval None
  750. */
  751. #define __FMC_DISABLE() (FMC_Bank1_R->BTCR[0] &= ~FMC_BCR1_FMCEN)
  752. /** @defgroup FMC_LL_NOR_Macros FMC NOR/SRAM Macros
  753. * @brief macros to handle NOR device enable/disable and read/write operations
  754. * @{
  755. */
  756. /**
  757. * @brief Enable the NORSRAM device access.
  758. * @param __INSTANCE__ FMC_NORSRAM Instance
  759. * @param __BANK__ FMC_NORSRAM Bank
  760. * @retval None
  761. */
  762. #define __FMC_NORSRAM_ENABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] |= FMC_BCRx_MBKEN)
  763. /**
  764. * @brief Disable the NORSRAM device access.
  765. * @param __INSTANCE__ FMC_NORSRAM Instance
  766. * @param __BANK__ FMC_NORSRAM Bank
  767. * @retval None
  768. */
  769. #define __FMC_NORSRAM_DISABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] &= ~FMC_BCRx_MBKEN)
  770. /**
  771. * @}
  772. */
  773. /** @defgroup FMC_LL_NAND_Macros FMC NAND Macros
  774. * @brief macros to handle NAND device enable/disable
  775. * @{
  776. */
  777. /**
  778. * @brief Enable the NAND device access.
  779. * @param __INSTANCE__ FMC_NAND Instance
  780. * @retval None
  781. */
  782. #define __FMC_NAND_ENABLE(__INSTANCE__) ((__INSTANCE__)->PCR |= FMC_PCR_PBKEN)
  783. /**
  784. * @brief Disable the NAND device access.
  785. * @param __INSTANCE__ FMC_NAND Instance
  786. * @param __BANK__ FMC_NAND Bank
  787. * @retval None
  788. */
  789. #define __FMC_NAND_DISABLE(__INSTANCE__, __BANK__) CLEAR_BIT((__INSTANCE__)->PCR, FMC_PCR_PBKEN)
  790. /**
  791. * @}
  792. */
  793. /** @defgroup FMC_LL_NAND_Interrupt FMC NAND Interrupt
  794. * @brief macros to handle NAND interrupts
  795. * @{
  796. */
  797. /**
  798. * @brief Enable the NAND device interrupt.
  799. * @param __INSTANCE__ FMC_NAND instance
  800. * @param __INTERRUPT__ FMC_NAND interrupt
  801. * This parameter can be any combination of the following values:
  802. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  803. * @arg FMC_IT_LEVEL: Interrupt level.
  804. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  805. * @retval None
  806. */
  807. #define __FMC_NAND_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR |= (__INTERRUPT__))
  808. /**
  809. * @brief Disable the NAND device interrupt.
  810. * @param __INSTANCE__ FMC_NAND Instance
  811. * @param __INTERRUPT__ FMC_NAND interrupt
  812. * This parameter can be any combination of the following values:
  813. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  814. * @arg FMC_IT_LEVEL: Interrupt level.
  815. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  816. * @retval None
  817. */
  818. #define __FMC_NAND_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR &= ~(__INTERRUPT__))
  819. /**
  820. * @brief Get flag status of the NAND device.
  821. * @param __INSTANCE__ FMC_NAND Instance
  822. * @param __BANK__ FMC_NAND Bank
  823. * @param __FLAG__ FMC_NAND flag
  824. * This parameter can be any combination of the following values:
  825. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  826. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  827. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  828. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  829. * @retval The state of FLAG (SET or RESET).
  830. */
  831. #define __FMC_NAND_GET_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__INSTANCE__)->SR &(__FLAG__)) == (__FLAG__))
  832. /**
  833. * @brief Clear flag status of the NAND device.
  834. * @param __INSTANCE__ FMC_NAND Instance
  835. * @param __FLAG__ FMC_NAND flag
  836. * This parameter can be any combination of the following values:
  837. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  838. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  839. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  840. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  841. * @retval None
  842. */
  843. #define __FMC_NAND_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->SR &= ~(__FLAG__))
  844. /**
  845. * @}
  846. */
  847. /** @defgroup FMC_LL_SDRAM_Interrupt FMC SDRAM Interrupt
  848. * @brief macros to handle SDRAM interrupts
  849. * @{
  850. */
  851. /**
  852. * @brief Enable the SDRAM device interrupt.
  853. * @param __INSTANCE__ FMC_SDRAM instance
  854. * @param __INTERRUPT__ FMC_SDRAM interrupt
  855. * This parameter can be any combination of the following values:
  856. * @arg FMC_IT_REFRESH_ERROR: Interrupt refresh error
  857. * @retval None
  858. */
  859. #define __FMC_SDRAM_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SDRTR |= (__INTERRUPT__))
  860. /**
  861. * @brief Disable the SDRAM device interrupt.
  862. * @param __INSTANCE__ FMC_SDRAM instance
  863. * @param __INTERRUPT__ FMC_SDRAM interrupt
  864. * This parameter can be any combination of the following values:
  865. * @arg FMC_IT_REFRESH_ERROR: Interrupt refresh error
  866. * @retval None
  867. */
  868. #define __FMC_SDRAM_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SDRTR &= ~(__INTERRUPT__))
  869. /**
  870. * @brief Get flag status of the SDRAM device.
  871. * @param __INSTANCE__ FMC_SDRAM instance
  872. * @param __FLAG__ FMC_SDRAM flag
  873. * This parameter can be any combination of the following values:
  874. * @arg FMC_SDRAM_FLAG_REFRESH_IT: Interrupt refresh error.
  875. * @arg FMC_SDRAM_FLAG_BUSY: SDRAM busy flag.
  876. * @arg FMC_SDRAM_FLAG_REFRESH_ERROR: Refresh error flag.
  877. * @retval The state of FLAG (SET or RESET).
  878. */
  879. #define __FMC_SDRAM_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->SDSR &(__FLAG__)) == (__FLAG__))
  880. /**
  881. * @brief Clear flag status of the SDRAM device.
  882. * @param __INSTANCE__ FMC_SDRAM instance
  883. * @param __FLAG__ FMC_SDRAM flag
  884. * This parameter can be any combination of the following values:
  885. * @arg FMC_SDRAM_FLAG_REFRESH_ERROR
  886. * @retval None
  887. */
  888. #define __FMC_SDRAM_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->SDRTR |= (__FLAG__))
  889. /**
  890. * @}
  891. */
  892. /**
  893. * @}
  894. */
  895. /**
  896. * @}
  897. */
  898. /* Private functions ---------------------------------------------------------*/
  899. /** @defgroup FMC_LL_Private_Functions FMC LL Private Functions
  900. * @{
  901. */
  902. /** @defgroup FMC_LL_NORSRAM NOR SRAM
  903. * @{
  904. */
  905. /** @defgroup FMC_LL_NORSRAM_Private_Functions_Group1 NOR SRAM Initialization/de-initialization functions
  906. * @{
  907. */
  908. HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_InitTypeDef *Init);
  909. HAL_StatusTypeDef FMC_NORSRAM_Timing_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank);
  910. HAL_StatusTypeDef FMC_NORSRAM_Extended_Timing_Init(FMC_NORSRAM_EXTENDED_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode);
  911. HAL_StatusTypeDef FMC_NORSRAM_DeInit(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank);
  912. /**
  913. * @}
  914. */
  915. /** @defgroup FMC_LL_NORSRAM_Private_Functions_Group2 NOR SRAM Control functions
  916. * @{
  917. */
  918. HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Enable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  919. HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  920. /**
  921. * @}
  922. */
  923. /**
  924. * @}
  925. */
  926. /** @defgroup FMC_LL_NAND NAND
  927. * @{
  928. */
  929. /** @defgroup FMC_LL_NAND_Private_Functions_Group1 NAND Initialization/de-initialization functions
  930. * @{
  931. */
  932. HAL_StatusTypeDef FMC_NAND_Init(FMC_NAND_TypeDef *Device, FMC_NAND_InitTypeDef *Init);
  933. HAL_StatusTypeDef FMC_NAND_CommonSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  934. HAL_StatusTypeDef FMC_NAND_AttributeSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  935. HAL_StatusTypeDef FMC_NAND_DeInit(FMC_NAND_TypeDef *Device, uint32_t Bank);
  936. /**
  937. * @}
  938. */
  939. /** @defgroup FMC_LL_NAND_Private_Functions_Group2 NAND Control functions
  940. * @{
  941. */
  942. HAL_StatusTypeDef FMC_NAND_ECC_Enable(FMC_NAND_TypeDef *Device, uint32_t Bank);
  943. HAL_StatusTypeDef FMC_NAND_ECC_Disable(FMC_NAND_TypeDef *Device, uint32_t Bank);
  944. HAL_StatusTypeDef FMC_NAND_GetECC(FMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout);
  945. /**
  946. * @}
  947. */
  948. /**
  949. * @}
  950. */
  951. /** @defgroup FMC_LL_SDRAM SDRAM
  952. * @{
  953. */
  954. /** @defgroup FMC_LL_SDRAM_Private_Functions_Group1 SDRAM Initialization/de-initialization functions
  955. * @{
  956. */
  957. HAL_StatusTypeDef FMC_SDRAM_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_InitTypeDef *Init);
  958. HAL_StatusTypeDef FMC_SDRAM_Timing_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_TimingTypeDef *Timing, uint32_t Bank);
  959. HAL_StatusTypeDef FMC_SDRAM_DeInit(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  960. /**
  961. * @}
  962. */
  963. /** @defgroup FMC_LL_SDRAM_Private_Functions_Group2 SDRAM Control functions
  964. * @{
  965. */
  966. HAL_StatusTypeDef FMC_SDRAM_WriteProtection_Enable(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  967. HAL_StatusTypeDef FMC_SDRAM_WriteProtection_Disable(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  968. HAL_StatusTypeDef FMC_SDRAM_SendCommand(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_CommandTypeDef *Command, uint32_t Timeout);
  969. HAL_StatusTypeDef FMC_SDRAM_ProgramRefreshRate(FMC_SDRAM_TypeDef *Device, uint32_t RefreshRate);
  970. HAL_StatusTypeDef FMC_SDRAM_SetAutoRefreshNumber(FMC_SDRAM_TypeDef *Device, uint32_t AutoRefreshNumber);
  971. uint32_t FMC_SDRAM_GetModeStatus(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  972. /**
  973. * @}
  974. */
  975. /**
  976. * @}
  977. */
  978. /**
  979. * @}
  980. */
  981. /**
  982. * @}
  983. */
  984. /**
  985. * @}
  986. */
  987. #ifdef __cplusplus
  988. }
  989. #endif
  990. #endif /* STM32H7xx_LL_FMC_H */
  991. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/