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.
 
 
 

1380 lines
55 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_fmc.h
  4. * @author MCD Application Team
  5. * @version V1.1.0
  6. * @date 19-June-2014
  7. * @brief Header file of FMC HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32F4xx_LL_FMC_H
  39. #define __STM32F4xx_LL_FMC_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "stm32f4xx_hal_def.h"
  46. /** @addtogroup STM32F4xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup FMC
  50. * @{
  51. */
  52. /* Exported typedef ----------------------------------------------------------*/
  53. #define FMC_NORSRAM_TypeDef FMC_Bank1_TypeDef
  54. #define FMC_NORSRAM_EXTENDED_TypeDef FMC_Bank1E_TypeDef
  55. #define FMC_NAND_TypeDef FMC_Bank2_3_TypeDef
  56. #define FMC_PCCARD_TypeDef FMC_Bank4_TypeDef
  57. #define FMC_SDRAM_TypeDef FMC_Bank5_6_TypeDef
  58. #define FMC_NORSRAM_DEVICE FMC_Bank1
  59. #define FMC_NORSRAM_EXTENDED_DEVICE FMC_Bank1E
  60. #define FMC_NAND_DEVICE FMC_Bank2_3
  61. #define FMC_PCCARD_DEVICE FMC_Bank4
  62. #define FMC_SDRAM_DEVICE FMC_Bank5_6
  63. /**
  64. * @brief FMC_NORSRAM Configuration Structure definition
  65. */
  66. typedef struct
  67. {
  68. uint32_t NSBank; /*!< Specifies the NORSRAM memory device that will be used.
  69. This parameter can be a value of @ref FMC_NORSRAM_Bank */
  70. uint32_t DataAddressMux; /*!< Specifies whether the address and data values are
  71. multiplexed on the data bus or not.
  72. This parameter can be a value of @ref FMC_Data_Address_Bus_Multiplexing */
  73. uint32_t MemoryType; /*!< Specifies the type of external memory attached to
  74. the corresponding memory device.
  75. This parameter can be a value of @ref FMC_Memory_Type */
  76. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  77. This parameter can be a value of @ref FMC_NORSRAM_Data_Width */
  78. uint32_t BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory,
  79. valid only with synchronous burst Flash memories.
  80. This parameter can be a value of @ref FMC_Burst_Access_Mode */
  81. uint32_t WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing
  82. the Flash memory in burst mode.
  83. This parameter can be a value of @ref FMC_Wait_Signal_Polarity */
  84. uint32_t WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash
  85. memory, valid only when accessing Flash memories in burst mode.
  86. This parameter can be a value of @ref FMC_Wrap_Mode */
  87. uint32_t WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one
  88. clock cycle before the wait state or during the wait state,
  89. valid only when accessing memories in burst mode.
  90. This parameter can be a value of @ref FMC_Wait_Timing */
  91. uint32_t WriteOperation; /*!< Enables or disables the write operation in the selected device by the FMC.
  92. This parameter can be a value of @ref FMC_Write_Operation */
  93. uint32_t WaitSignal; /*!< Enables or disables the wait state insertion via wait
  94. signal, valid for Flash memory access in burst mode.
  95. This parameter can be a value of @ref FMC_Wait_Signal */
  96. uint32_t ExtendedMode; /*!< Enables or disables the extended mode.
  97. This parameter can be a value of @ref FMC_Extended_Mode */
  98. uint32_t AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers,
  99. valid only with asynchronous Flash memories.
  100. This parameter can be a value of @ref FMC_AsynchronousWait */
  101. uint32_t WriteBurst; /*!< Enables or disables the write burst operation.
  102. This parameter can be a value of @ref FMC_Write_Burst */
  103. uint32_t ContinuousClock; /*!< Enables or disables the FMC clock output to external memory devices.
  104. This parameter is only enabled through the FMC_BCR1 register, and don't care
  105. through FMC_BCR2..4 registers.
  106. This parameter can be a value of @ref FMC_Continous_Clock */
  107. }FMC_NORSRAM_InitTypeDef;
  108. /**
  109. * @brief FMC_NORSRAM Timing parameters structure definition
  110. */
  111. typedef struct
  112. {
  113. uint32_t AddressSetupTime; /*!< Defines the number of HCLK cycles to configure
  114. the duration of the address setup time.
  115. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  116. @note This parameter is not used with synchronous NOR Flash memories. */
  117. uint32_t AddressHoldTime; /*!< Defines the number of HCLK cycles to configure
  118. the duration of the address hold time.
  119. This parameter can be a value between Min_Data = 1 and Max_Data = 15.
  120. @note This parameter is not used with synchronous NOR Flash memories. */
  121. uint32_t DataSetupTime; /*!< Defines the number of HCLK cycles to configure
  122. the duration of the data setup time.
  123. This parameter can be a value between Min_Data = 1 and Max_Data = 255.
  124. @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed
  125. NOR Flash memories. */
  126. uint32_t BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure
  127. the duration of the bus turnaround.
  128. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  129. @note This parameter is only used for multiplexed NOR Flash memories. */
  130. uint32_t CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of
  131. HCLK cycles. This parameter can be a value between Min_Data = 2 and Max_Data = 16.
  132. @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM
  133. accesses. */
  134. uint32_t DataLatency; /*!< Defines the number of memory clock cycles to issue
  135. to the memory before getting the first data.
  136. The parameter value depends on the memory type as shown below:
  137. - It must be set to 0 in case of a CRAM
  138. - It is don't care in asynchronous NOR, SRAM or ROM accesses
  139. - It may assume a value between Min_Data = 2 and Max_Data = 17 in NOR Flash memories
  140. with synchronous burst mode enable */
  141. uint32_t AccessMode; /*!< Specifies the asynchronous access mode.
  142. This parameter can be a value of @ref FMC_Access_Mode */
  143. }FMC_NORSRAM_TimingTypeDef;
  144. /**
  145. * @brief FMC_NAND Configuration Structure definition
  146. */
  147. typedef struct
  148. {
  149. uint32_t NandBank; /*!< Specifies the NAND memory device that will be used.
  150. This parameter can be a value of @ref FMC_NAND_Bank */
  151. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory device.
  152. This parameter can be any value of @ref FMC_Wait_feature */
  153. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  154. This parameter can be any value of @ref FMC_NAND_Data_Width */
  155. uint32_t EccComputation; /*!< Enables or disables the ECC computation.
  156. This parameter can be any value of @ref FMC_ECC */
  157. uint32_t ECCPageSize; /*!< Defines the page size for the extended ECC.
  158. This parameter can be any value of @ref FMC_ECC_Page_Size */
  159. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  160. delay between CLE low and RE low.
  161. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  162. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  163. delay between ALE low and RE low.
  164. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  165. }FMC_NAND_InitTypeDef;
  166. /**
  167. * @brief FMC_NAND_PCCARD Timing parameters structure definition
  168. */
  169. typedef struct
  170. {
  171. uint32_t SetupTime; /*!< Defines the number of HCLK cycles to setup address before
  172. the command assertion for NAND-Flash read or write access
  173. to common/Attribute or I/O memory space (depending on
  174. the memory space timing to be configured).
  175. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  176. uint32_t WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the
  177. command for NAND-Flash read or write access to
  178. common/Attribute or I/O memory space (depending on the
  179. memory space timing to be configured).
  180. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  181. uint32_t HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address
  182. (and data for write access) after the command de-assertion
  183. for NAND-Flash read or write access to common/Attribute
  184. or I/O memory space (depending on the memory space timing
  185. to be configured).
  186. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  187. uint32_t HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the
  188. data bus is kept in HiZ after the start of a NAND-Flash
  189. write access to common/Attribute or I/O memory space (depending
  190. on the memory space timing to be configured).
  191. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  192. }FMC_NAND_PCC_TimingTypeDef;
  193. /**
  194. * @brief FMC_NAND Configuration Structure definition
  195. */
  196. typedef struct
  197. {
  198. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the PCCARD Memory device.
  199. This parameter can be any value of @ref FMC_Wait_feature */
  200. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  201. delay between CLE low and RE low.
  202. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  203. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  204. delay between ALE low and RE low.
  205. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  206. }FMC_PCCARD_InitTypeDef;
  207. /**
  208. * @brief FMC_SDRAM Configuration Structure definition
  209. */
  210. typedef struct
  211. {
  212. uint32_t SDBank; /*!< Specifies the SDRAM memory device that will be used.
  213. This parameter can be a value of @ref FMC_SDRAM_Bank */
  214. uint32_t ColumnBitsNumber; /*!< Defines the number of bits of column address.
  215. This parameter can be a value of @ref FMC_SDRAM_Column_Bits_number. */
  216. uint32_t RowBitsNumber; /*!< Defines the number of bits of column address.
  217. This parameter can be a value of @ref FMC_SDRAM_Row_Bits_number. */
  218. uint32_t MemoryDataWidth; /*!< Defines the memory device width.
  219. This parameter can be a value of @ref FMC_SDRAM_Memory_Bus_Width. */
  220. uint32_t InternalBankNumber; /*!< Defines the number of the device's internal banks.
  221. This parameter can be of @ref FMC_SDRAM_Internal_Banks_Number. */
  222. uint32_t CASLatency; /*!< Defines the SDRAM CAS latency in number of memory clock cycles.
  223. This parameter can be a value of @ref FMC_SDRAM_CAS_Latency. */
  224. uint32_t WriteProtection; /*!< Enables the SDRAM device to be accessed in write mode.
  225. This parameter can be a value of @ref FMC_SDRAM_Write_Protection. */
  226. uint32_t SDClockPeriod; /*!< Define the SDRAM Clock Period for both SDRAM devices and they allow
  227. to disable the clock before changing frequency.
  228. This parameter can be a value of @ref FMC_SDRAM_Clock_Period. */
  229. uint32_t ReadBurst; /*!< This bit enable the SDRAM controller to anticipate the next read
  230. commands during the CAS latency and stores data in the Read FIFO.
  231. This parameter can be a value of @ref FMC_SDRAM_Read_Burst. */
  232. uint32_t ReadPipeDelay; /*!< Define the delay in system clock cycles on read data path.
  233. This parameter can be a value of @ref FMC_SDRAM_Read_Pipe_Delay. */
  234. }FMC_SDRAM_InitTypeDef;
  235. /**
  236. * @brief FMC_SDRAM Timing parameters structure definition
  237. */
  238. typedef struct
  239. {
  240. uint32_t LoadToActiveDelay; /*!< Defines the delay between a Load Mode Register command and
  241. an active or Refresh command in number of memory clock cycles.
  242. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  243. uint32_t ExitSelfRefreshDelay; /*!< Defines the delay from releasing the self refresh command to
  244. issuing the Activate command in number of memory clock cycles.
  245. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  246. uint32_t SelfRefreshTime; /*!< Defines the minimum Self Refresh period in number of memory clock
  247. cycles.
  248. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  249. uint32_t RowCycleDelay; /*!< Defines the delay between the Refresh command and the Activate command
  250. and the delay between two consecutive Refresh commands in number of
  251. memory clock cycles.
  252. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  253. uint32_t WriteRecoveryTime; /*!< Defines the Write recovery Time in number of memory clock cycles.
  254. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  255. uint32_t RPDelay; /*!< Defines the delay between a Precharge Command and an other command
  256. in number of memory clock cycles.
  257. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  258. uint32_t RCDDelay; /*!< Defines the delay between the Activate Command and a Read/Write
  259. command in number of memory clock cycles.
  260. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  261. }FMC_SDRAM_TimingTypeDef;
  262. /**
  263. * @brief SDRAM command parameters structure definition
  264. */
  265. typedef struct
  266. {
  267. uint32_t CommandMode; /*!< Defines the command issued to the SDRAM device.
  268. This parameter can be a value of @ref FMC_SDRAM_Command_Mode. */
  269. uint32_t CommandTarget; /*!< Defines which device (1 or 2) the command will be issued to.
  270. This parameter can be a value of @ref FMC_SDRAM_Command_Target. */
  271. uint32_t AutoRefreshNumber; /*!< Defines the number of consecutive auto refresh command issued
  272. in auto refresh mode.
  273. This parameter can be a value between Min_Data = 1 and Max_Data = 16 */
  274. uint32_t ModeRegisterDefinition; /*!< Defines the SDRAM Mode register content */
  275. }FMC_SDRAM_CommandTypeDef;
  276. /* Exported constants --------------------------------------------------------*/
  277. /** @defgroup FMC_NOR_SRAM_Controller
  278. * @{
  279. */
  280. /** @defgroup FMC_NORSRAM_Bank
  281. * @{
  282. */
  283. #define FMC_NORSRAM_BANK1 ((uint32_t)0x00000000)
  284. #define FMC_NORSRAM_BANK2 ((uint32_t)0x00000002)
  285. #define FMC_NORSRAM_BANK3 ((uint32_t)0x00000004)
  286. #define FMC_NORSRAM_BANK4 ((uint32_t)0x00000006)
  287. #define IS_FMC_NORSRAM_BANK(BANK) (((BANK) == FMC_NORSRAM_BANK1) || \
  288. ((BANK) == FMC_NORSRAM_BANK2) || \
  289. ((BANK) == FMC_NORSRAM_BANK3) || \
  290. ((BANK) == FMC_NORSRAM_BANK4))
  291. /**
  292. * @}
  293. */
  294. /** @defgroup FMC_Data_Address_Bus_Multiplexing
  295. * @{
  296. */
  297. #define FMC_DATA_ADDRESS_MUX_DISABLE ((uint32_t)0x00000000)
  298. #define FMC_DATA_ADDRESS_MUX_ENABLE ((uint32_t)0x00000002)
  299. #define IS_FMC_MUX(MUX) (((MUX) == FMC_DATA_ADDRESS_MUX_DISABLE) || \
  300. ((MUX) == FMC_DATA_ADDRESS_MUX_ENABLE))
  301. /**
  302. * @}
  303. */
  304. /** @defgroup FMC_Memory_Type
  305. * @{
  306. */
  307. #define FMC_MEMORY_TYPE_SRAM ((uint32_t)0x00000000)
  308. #define FMC_MEMORY_TYPE_PSRAM ((uint32_t)0x00000004)
  309. #define FMC_MEMORY_TYPE_NOR ((uint32_t)0x00000008)
  310. #define IS_FMC_MEMORY(MEMORY) (((MEMORY) == FMC_MEMORY_TYPE_SRAM) || \
  311. ((MEMORY) == FMC_MEMORY_TYPE_PSRAM)|| \
  312. ((MEMORY) == FMC_MEMORY_TYPE_NOR))
  313. /**
  314. * @}
  315. */
  316. /** @defgroup FMC_NORSRAM_Data_Width
  317. * @{
  318. */
  319. #define FMC_NORSRAM_MEM_BUS_WIDTH_8 ((uint32_t)0x00000000)
  320. #define FMC_NORSRAM_MEM_BUS_WIDTH_16 ((uint32_t)0x00000010)
  321. #define FMC_NORSRAM_MEM_BUS_WIDTH_32 ((uint32_t)0x00000020)
  322. #define IS_FMC_NORSRAM_MEMORY_WIDTH(WIDTH) (((WIDTH) == FMC_NORSRAM_MEM_BUS_WIDTH_8) || \
  323. ((WIDTH) == FMC_NORSRAM_MEM_BUS_WIDTH_16) || \
  324. ((WIDTH) == FMC_NORSRAM_MEM_BUS_WIDTH_32))
  325. /**
  326. * @}
  327. */
  328. /** @defgroup FMC_NORSRAM_Flash_Access
  329. * @{
  330. */
  331. #define FMC_NORSRAM_FLASH_ACCESS_ENABLE ((uint32_t)0x00000040)
  332. #define FMC_NORSRAM_FLASH_ACCESS_DISABLE ((uint32_t)0x00000000)
  333. /**
  334. * @}
  335. */
  336. /** @defgroup FMC_Burst_Access_Mode
  337. * @{
  338. */
  339. #define FMC_BURST_ACCESS_MODE_DISABLE ((uint32_t)0x00000000)
  340. #define FMC_BURST_ACCESS_MODE_ENABLE ((uint32_t)0x00000100)
  341. #define IS_FMC_BURSTMODE(STATE) (((STATE) == FMC_BURST_ACCESS_MODE_DISABLE) || \
  342. ((STATE) == FMC_BURST_ACCESS_MODE_ENABLE))
  343. /**
  344. * @}
  345. */
  346. /** @defgroup FMC_Wait_Signal_Polarity
  347. * @{
  348. */
  349. #define FMC_WAIT_SIGNAL_POLARITY_LOW ((uint32_t)0x00000000)
  350. #define FMC_WAIT_SIGNAL_POLARITY_HIGH ((uint32_t)0x00000200)
  351. #define IS_FMC_WAIT_POLARITY(POLARITY) (((POLARITY) == FMC_WAIT_SIGNAL_POLARITY_LOW) || \
  352. ((POLARITY) == FMC_WAIT_SIGNAL_POLARITY_HIGH))
  353. /**
  354. * @}
  355. */
  356. /** @defgroup FMC_Wrap_Mode
  357. * @{
  358. */
  359. #define FMC_WRAP_MODE_DISABLE ((uint32_t)0x00000000)
  360. #define FMC_WRAP_MODE_ENABLE ((uint32_t)0x00000400)
  361. #define IS_FMC_WRAP_MODE(MODE) (((MODE) == FMC_WRAP_MODE_DISABLE) || \
  362. ((MODE) == FMC_WRAP_MODE_ENABLE))
  363. /**
  364. * @}
  365. */
  366. /** @defgroup FMC_Wait_Timing
  367. * @{
  368. */
  369. #define FMC_WAIT_TIMING_BEFORE_WS ((uint32_t)0x00000000)
  370. #define FMC_WAIT_TIMING_DURING_WS ((uint32_t)0x00000800)
  371. #define IS_FMC_WAIT_SIGNAL_ACTIVE(ACTIVE) (((ACTIVE) == FMC_WAIT_TIMING_BEFORE_WS) || \
  372. ((ACTIVE) == FMC_WAIT_TIMING_DURING_WS))
  373. /**
  374. * @}
  375. */
  376. /** @defgroup FMC_Write_Operation
  377. * @{
  378. */
  379. #define FMC_WRITE_OPERATION_DISABLE ((uint32_t)0x00000000)
  380. #define FMC_WRITE_OPERATION_ENABLE ((uint32_t)0x00001000)
  381. #define IS_FMC_WRITE_OPERATION(OPERATION) (((OPERATION) == FMC_WRITE_OPERATION_DISABLE) || \
  382. ((OPERATION) == FMC_WRITE_OPERATION_ENABLE))
  383. /**
  384. * @}
  385. */
  386. /** @defgroup FMC_Wait_Signal
  387. * @{
  388. */
  389. #define FMC_WAIT_SIGNAL_DISABLE ((uint32_t)0x00000000)
  390. #define FMC_WAIT_SIGNAL_ENABLE ((uint32_t)0x00002000)
  391. #define IS_FMC_WAITE_SIGNAL(SIGNAL) (((SIGNAL) == FMC_WAIT_SIGNAL_DISABLE) || \
  392. ((SIGNAL) == FMC_WAIT_SIGNAL_ENABLE))
  393. /**
  394. * @}
  395. */
  396. /** @defgroup FMC_Extended_Mode
  397. * @{
  398. */
  399. #define FMC_EXTENDED_MODE_DISABLE ((uint32_t)0x00000000)
  400. #define FMC_EXTENDED_MODE_ENABLE ((uint32_t)0x00004000)
  401. #define IS_FMC_EXTENDED_MODE(MODE) (((MODE) == FMC_EXTENDED_MODE_DISABLE) || \
  402. ((MODE) == FMC_EXTENDED_MODE_ENABLE))
  403. /**
  404. * @}
  405. */
  406. /** @defgroup FMC_AsynchronousWait
  407. * @{
  408. */
  409. #define FMC_ASYNCHRONOUS_WAIT_DISABLE ((uint32_t)0x00000000)
  410. #define FMC_ASYNCHRONOUS_WAIT_ENABLE ((uint32_t)0x00008000)
  411. #define IS_FMC_ASYNWAIT(STATE) (((STATE) == FMC_ASYNCHRONOUS_WAIT_DISABLE) || \
  412. ((STATE) == FMC_ASYNCHRONOUS_WAIT_ENABLE))
  413. /**
  414. * @}
  415. */
  416. /** @defgroup FMC_Write_Burst
  417. * @{
  418. */
  419. #define FMC_WRITE_BURST_DISABLE ((uint32_t)0x00000000)
  420. #define FMC_WRITE_BURST_ENABLE ((uint32_t)0x00080000)
  421. #define IS_FMC_WRITE_BURST(BURST) (((BURST) == FMC_WRITE_BURST_DISABLE) || \
  422. ((BURST) == FMC_WRITE_BURST_ENABLE))
  423. /**
  424. * @}
  425. */
  426. /** @defgroup FMC_Continous_Clock
  427. * @{
  428. */
  429. #define FMC_CONTINUOUS_CLOCK_SYNC_ONLY ((uint32_t)0x00000000)
  430. #define FMC_CONTINUOUS_CLOCK_SYNC_ASYNC ((uint32_t)0x00100000)
  431. #define IS_FMC_CONTINOUS_CLOCK(CCLOCK) (((CCLOCK) == FMC_CONTINUOUS_CLOCK_SYNC_ONLY) || \
  432. ((CCLOCK) == FMC_CONTINUOUS_CLOCK_SYNC_ASYNC))
  433. /**
  434. * @}
  435. */
  436. /** @defgroup FMC_Address_Setup_Time
  437. * @{
  438. */
  439. #define IS_FMC_ADDRESS_SETUP_TIME(TIME) ((TIME) <= 15)
  440. /**
  441. * @}
  442. */
  443. /** @defgroup FMC_Address_Hold_Time
  444. * @{
  445. */
  446. #define IS_FMC_ADDRESS_HOLD_TIME(TIME) (((TIME) > 0) && ((TIME) <= 15))
  447. /**
  448. * @}
  449. */
  450. /** @defgroup FMC_Data_Setup_Time
  451. * @{
  452. */
  453. #define IS_FMC_DATASETUP_TIME(TIME) (((TIME) > 0) && ((TIME) <= 255))
  454. /**
  455. * @}
  456. */
  457. /** @defgroup FMC_Bus_Turn_around_Duration
  458. * @{
  459. */
  460. #define IS_FMC_TURNAROUND_TIME(TIME) ((TIME) <= 15)
  461. /**
  462. * @}
  463. */
  464. /** @defgroup FMC_CLK_Division
  465. * @{
  466. */
  467. #define IS_FMC_CLK_DIV(DIV) (((DIV) > 1) && ((DIV) <= 16))
  468. /**
  469. * @}
  470. */
  471. /** @defgroup FMC_Data_Latency
  472. * @{
  473. */
  474. #define IS_FMC_DATA_LATENCY(LATENCY) (((LATENCY) > 1) && ((LATENCY) <= 17))
  475. /**
  476. * @}
  477. */
  478. /** @defgroup FMC_Access_Mode
  479. * @{
  480. */
  481. #define FMC_ACCESS_MODE_A ((uint32_t)0x00000000)
  482. #define FMC_ACCESS_MODE_B ((uint32_t)0x10000000)
  483. #define FMC_ACCESS_MODE_C ((uint32_t)0x20000000)
  484. #define FMC_ACCESS_MODE_D ((uint32_t)0x30000000)
  485. #define IS_FMC_ACCESS_MODE(MODE) (((MODE) == FMC_ACCESS_MODE_A) || \
  486. ((MODE) == FMC_ACCESS_MODE_B) || \
  487. ((MODE) == FMC_ACCESS_MODE_C) || \
  488. ((MODE) == FMC_ACCESS_MODE_D))
  489. /**
  490. * @}
  491. */
  492. /**
  493. * @}
  494. */
  495. /** @defgroup FMC_NAND_Controller
  496. * @{
  497. */
  498. /** @defgroup FMC_NAND_Bank
  499. * @{
  500. */
  501. #define FMC_NAND_BANK2 ((uint32_t)0x00000010)
  502. #define FMC_NAND_BANK3 ((uint32_t)0x00000100)
  503. #define IS_FMC_NAND_BANK(BANK) (((BANK) == FMC_NAND_BANK2) || \
  504. ((BANK) == FMC_NAND_BANK3))
  505. /**
  506. * @}
  507. */
  508. /** @defgroup FMC_Wait_feature
  509. * @{
  510. */
  511. #define FMC_NAND_PCC_WAIT_FEATURE_DISABLE ((uint32_t)0x00000000)
  512. #define FMC_NAND_PCC_WAIT_FEATURE_ENABLE ((uint32_t)0x00000002)
  513. #define IS_FMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FMC_NAND_PCC_WAIT_FEATURE_DISABLE) || \
  514. ((FEATURE) == FMC_NAND_PCC_WAIT_FEATURE_ENABLE))
  515. /**
  516. * @}
  517. */
  518. /** @defgroup FMC_PCR_Memory_Type
  519. * @{
  520. */
  521. #define FMC_PCR_MEMORY_TYPE_PCCARD ((uint32_t)0x00000000)
  522. #define FMC_PCR_MEMORY_TYPE_NAND ((uint32_t)0x00000008)
  523. /**
  524. * @}
  525. */
  526. /** @defgroup FMC_NAND_Data_Width
  527. * @{
  528. */
  529. #define FMC_NAND_PCC_MEM_BUS_WIDTH_8 ((uint32_t)0x00000000)
  530. #define FMC_NAND_PCC_MEM_BUS_WIDTH_16 ((uint32_t)0x00000010)
  531. #define IS_FMC_NAND_MEMORY_WIDTH(WIDTH) (((WIDTH) == FMC_NAND_PCC_MEM_BUS_WIDTH_8) || \
  532. ((WIDTH) == FMC_NAND_PCC_MEM_BUS_WIDTH_16))
  533. /**
  534. * @}
  535. */
  536. /** @defgroup FMC_ECC
  537. * @{
  538. */
  539. #define FMC_NAND_ECC_DISABLE ((uint32_t)0x00000000)
  540. #define FMC_NAND_ECC_ENABLE ((uint32_t)0x00000040)
  541. #define IS_FMC_ECC_STATE(STATE) (((STATE) == FMC_NAND_ECC_DISABLE) || \
  542. ((STATE) == FMC_NAND_ECC_ENABLE))
  543. /**
  544. * @}
  545. */
  546. /** @defgroup FMC_ECC_Page_Size
  547. * @{
  548. */
  549. #define FMC_NAND_ECC_PAGE_SIZE_256BYTE ((uint32_t)0x00000000)
  550. #define FMC_NAND_ECC_PAGE_SIZE_512BYTE ((uint32_t)0x00020000)
  551. #define FMC_NAND_ECC_PAGE_SIZE_1024BYTE ((uint32_t)0x00040000)
  552. #define FMC_NAND_ECC_PAGE_SIZE_2048BYTE ((uint32_t)0x00060000)
  553. #define FMC_NAND_ECC_PAGE_SIZE_4096BYTE ((uint32_t)0x00080000)
  554. #define FMC_NAND_ECC_PAGE_SIZE_8192BYTE ((uint32_t)0x000A0000)
  555. #define IS_FMC_ECCPAGE_SIZE(SIZE) (((SIZE) == FMC_NAND_ECC_PAGE_SIZE_256BYTE) || \
  556. ((SIZE) == FMC_NAND_ECC_PAGE_SIZE_512BYTE) || \
  557. ((SIZE) == FMC_NAND_ECC_PAGE_SIZE_1024BYTE) || \
  558. ((SIZE) == FMC_NAND_ECC_PAGE_SIZE_2048BYTE) || \
  559. ((SIZE) == FMC_NAND_ECC_PAGE_SIZE_4096BYTE) || \
  560. ((SIZE) == FMC_NAND_ECC_PAGE_SIZE_8192BYTE))
  561. /**
  562. * @}
  563. */
  564. /** @defgroup FMC_TCLR_Setup_Time
  565. * @{
  566. */
  567. #define IS_FMC_TCLR_TIME(TIME) ((TIME) <= 255)
  568. /**
  569. * @}
  570. */
  571. /** @defgroup FMC_TAR_Setup_Time
  572. * @{
  573. */
  574. #define IS_FMC_TAR_TIME(TIME) ((TIME) <= 255)
  575. /**
  576. * @}
  577. */
  578. /** @defgroup FMC_Setup_Time
  579. * @{
  580. */
  581. #define IS_FMC_SETUP_TIME(TIME) ((TIME) <= 255)
  582. /**
  583. * @}
  584. */
  585. /** @defgroup FMC_Wait_Setup_Time
  586. * @{
  587. */
  588. #define IS_FMC_WAIT_TIME(TIME) ((TIME) <= 255)
  589. /**
  590. * @}
  591. */
  592. /** @defgroup FMC_Hold_Setup_Time
  593. * @{
  594. */
  595. #define IS_FMC_HOLD_TIME(TIME) ((TIME) <= 255)
  596. /**
  597. * @}
  598. */
  599. /** @defgroup FMC_HiZ_Setup_Time
  600. * @{
  601. */
  602. #define IS_FMC_HIZ_TIME(TIME) ((TIME) <= 255)
  603. /**
  604. * @}
  605. */
  606. /**
  607. * @}
  608. */
  609. /** @defgroup FMC_SDRAM_Controller
  610. * @{
  611. */
  612. /** @defgroup FMC_SDRAM_Bank
  613. * @{
  614. */
  615. #define FMC_SDRAM_BANK1 ((uint32_t)0x00000000)
  616. #define FMC_SDRAM_BANK2 ((uint32_t)0x00000001)
  617. #define IS_FMC_SDRAM_BANK(BANK) (((BANK) == FMC_SDRAM_BANK1) || \
  618. ((BANK) == FMC_SDRAM_BANK2))
  619. /**
  620. * @}
  621. */
  622. /** @defgroup FMC_SDRAM_Column_Bits_number
  623. * @{
  624. */
  625. #define FMC_SDRAM_COLUMN_BITS_NUM_8 ((uint32_t)0x00000000)
  626. #define FMC_SDRAM_COLUMN_BITS_NUM_9 ((uint32_t)0x00000001)
  627. #define FMC_SDRAM_COLUMN_BITS_NUM_10 ((uint32_t)0x00000002)
  628. #define FMC_SDRAM_COLUMN_BITS_NUM_11 ((uint32_t)0x00000003)
  629. #define IS_FMC_COLUMNBITS_NUMBER(COLUMN) (((COLUMN) == FMC_SDRAM_COLUMN_BITS_NUM_8) || \
  630. ((COLUMN) == FMC_SDRAM_COLUMN_BITS_NUM_9) || \
  631. ((COLUMN) == FMC_SDRAM_COLUMN_BITS_NUM_10) || \
  632. ((COLUMN) == FMC_SDRAM_COLUMN_BITS_NUM_11))
  633. /**
  634. * @}
  635. */
  636. /** @defgroup FMC_SDRAM_Row_Bits_number
  637. * @{
  638. */
  639. #define FMC_SDRAM_ROW_BITS_NUM_11 ((uint32_t)0x00000000)
  640. #define FMC_SDRAM_ROW_BITS_NUM_12 ((uint32_t)0x00000004)
  641. #define FMC_SDRAM_ROW_BITS_NUM_13 ((uint32_t)0x00000008)
  642. #define IS_FMC_ROWBITS_NUMBER(ROW) (((ROW) == FMC_SDRAM_ROW_BITS_NUM_11) || \
  643. ((ROW) == FMC_SDRAM_ROW_BITS_NUM_12) || \
  644. ((ROW) == FMC_SDRAM_ROW_BITS_NUM_13))
  645. /**
  646. * @}
  647. */
  648. /** @defgroup FMC_SDRAM_Memory_Bus_Width
  649. * @{
  650. */
  651. #define FMC_SDRAM_MEM_BUS_WIDTH_8 ((uint32_t)0x00000000)
  652. #define FMC_SDRAM_MEM_BUS_WIDTH_16 ((uint32_t)0x00000010)
  653. #define FMC_SDRAM_MEM_BUS_WIDTH_32 ((uint32_t)0x00000020)
  654. #define IS_FMC_SDMEMORY_WIDTH(WIDTH) (((WIDTH) == FMC_SDRAM_MEM_BUS_WIDTH_8) || \
  655. ((WIDTH) == FMC_SDRAM_MEM_BUS_WIDTH_16) || \
  656. ((WIDTH) == FMC_SDRAM_MEM_BUS_WIDTH_32))
  657. /**
  658. * @}
  659. */
  660. /** @defgroup FMC_SDRAM_Internal_Banks_Number
  661. * @{
  662. */
  663. #define FMC_SDRAM_INTERN_BANKS_NUM_2 ((uint32_t)0x00000000)
  664. #define FMC_SDRAM_INTERN_BANKS_NUM_4 ((uint32_t)0x00000040)
  665. #define IS_FMC_INTERNALBANK_NUMBER(NUMBER) (((NUMBER) == FMC_SDRAM_INTERN_BANKS_NUM_2) || \
  666. ((NUMBER) == FMC_SDRAM_INTERN_BANKS_NUM_4))
  667. /**
  668. * @}
  669. */
  670. /** @defgroup FMC_SDRAM_CAS_Latency
  671. * @{
  672. */
  673. #define FMC_SDRAM_CAS_LATENCY_1 ((uint32_t)0x00000080)
  674. #define FMC_SDRAM_CAS_LATENCY_2 ((uint32_t)0x00000100)
  675. #define FMC_SDRAM_CAS_LATENCY_3 ((uint32_t)0x00000180)
  676. #define IS_FMC_CAS_LATENCY(LATENCY) (((LATENCY) == FMC_SDRAM_CAS_LATENCY_1) || \
  677. ((LATENCY) == FMC_SDRAM_CAS_LATENCY_2) || \
  678. ((LATENCY) == FMC_SDRAM_CAS_LATENCY_3))
  679. /**
  680. * @}
  681. */
  682. /** @defgroup FMC_SDRAM_Write_Protection
  683. * @{
  684. */
  685. #define FMC_SDRAM_WRITE_PROTECTION_DISABLE ((uint32_t)0x00000000)
  686. #define FMC_SDRAM_WRITE_PROTECTION_ENABLE ((uint32_t)0x00000200)
  687. #define IS_FMC_WRITE_PROTECTION(WRITE) (((WRITE) == FMC_SDRAM_WRITE_PROTECTION_DISABLE) || \
  688. ((WRITE) == FMC_SDRAM_WRITE_PROTECTION_ENABLE))
  689. /**
  690. * @}
  691. */
  692. /** @defgroup FMC_SDRAM_Clock_Period
  693. * @{
  694. */
  695. #define FMC_SDRAM_CLOCK_DISABLE ((uint32_t)0x00000000)
  696. #define FMC_SDRAM_CLOCK_PERIOD_2 ((uint32_t)0x00000800)
  697. #define FMC_SDRAM_CLOCK_PERIOD_3 ((uint32_t)0x00000C00)
  698. #define IS_FMC_SDCLOCK_PERIOD(PERIOD) (((PERIOD) == FMC_SDRAM_CLOCK_DISABLE) || \
  699. ((PERIOD) == FMC_SDRAM_CLOCK_PERIOD_2) || \
  700. ((PERIOD) == FMC_SDRAM_CLOCK_PERIOD_3))
  701. /**
  702. * @}
  703. */
  704. /** @defgroup FMC_SDRAM_Read_Burst
  705. * @{
  706. */
  707. #define FMC_SDRAM_RBURST_DISABLE ((uint32_t)0x00000000)
  708. #define FMC_SDRAM_RBURST_ENABLE ((uint32_t)0x00001000)
  709. #define IS_FMC_READ_BURST(RBURST) (((RBURST) == FMC_SDRAM_RBURST_DISABLE) || \
  710. ((RBURST) == FMC_SDRAM_RBURST_ENABLE))
  711. /**
  712. * @}
  713. */
  714. /** @defgroup FMC_SDRAM_Read_Pipe_Delay
  715. * @{
  716. */
  717. #define FMC_SDRAM_RPIPE_DELAY_0 ((uint32_t)0x00000000)
  718. #define FMC_SDRAM_RPIPE_DELAY_1 ((uint32_t)0x00002000)
  719. #define FMC_SDRAM_RPIPE_DELAY_2 ((uint32_t)0x00004000)
  720. #define IS_FMC_READPIPE_DELAY(DELAY) (((DELAY) == FMC_SDRAM_RPIPE_DELAY_0) || \
  721. ((DELAY) == FMC_SDRAM_RPIPE_DELAY_1) || \
  722. ((DELAY) == FMC_SDRAM_RPIPE_DELAY_2))
  723. /**
  724. * @}
  725. */
  726. /** @defgroup FMC_SDRAM_LoadToActive_Delay
  727. * @{
  728. */
  729. #define IS_FMC_LOADTOACTIVE_DELAY(DELAY) (((DELAY) > 0) && ((DELAY) <= 16))
  730. /**
  731. * @}
  732. */
  733. /** @defgroup FMC_SDRAM_ExitSelfRefresh_Delay
  734. * @{
  735. */
  736. #define IS_FMC_EXITSELFREFRESH_DELAY(DELAY) (((DELAY) > 0) && ((DELAY) <= 16))
  737. /**
  738. * @}
  739. */
  740. /** @defgroup FMC_SDRAM_SelfRefresh_Time
  741. * @{
  742. */
  743. #define IS_FMC_SELFREFRESH_TIME(TIME) (((TIME) > 0) && ((TIME) <= 16))
  744. /**
  745. * @}
  746. */
  747. /** @defgroup FMC_SDRAM_RowCycle_Delay
  748. * @{
  749. */
  750. #define IS_FMC_ROWCYCLE_DELAY(DELAY) (((DELAY) > 0) && ((DELAY) <= 16))
  751. /**
  752. * @}
  753. */
  754. /** @defgroup FMC_SDRAM_Write_Recovery_Time
  755. * @{
  756. */
  757. #define IS_FMC_WRITE_RECOVERY_TIME(TIME) (((TIME) > 0) && ((TIME) <= 16))
  758. /**
  759. * @}
  760. */
  761. /** @defgroup FMC_SDRAM_RP_Delay
  762. * @{
  763. */
  764. #define IS_FMC_RP_DELAY(DELAY) (((DELAY) > 0) && ((DELAY) <= 16))
  765. /**
  766. * @}
  767. */
  768. /** @defgroup FMC_SDRAM_RCD_Delay
  769. * @{
  770. */
  771. #define IS_FMC_RCD_DELAY(DELAY) (((DELAY) > 0) && ((DELAY) <= 16))
  772. /**
  773. * @}
  774. */
  775. /** @defgroup FMC_SDRAM_Command_Mode
  776. * @{
  777. */
  778. #define FMC_SDRAM_CMD_NORMAL_MODE ((uint32_t)0x00000000)
  779. #define FMC_SDRAM_CMD_CLK_ENABLE ((uint32_t)0x00000001)
  780. #define FMC_SDRAM_CMD_PALL ((uint32_t)0x00000002)
  781. #define FMC_SDRAM_CMD_AUTOREFRESH_MODE ((uint32_t)0x00000003)
  782. #define FMC_SDRAM_CMD_LOAD_MODE ((uint32_t)0x00000004)
  783. #define FMC_SDRAM_CMD_SELFREFRESH_MODE ((uint32_t)0x00000005)
  784. #define FMC_SDRAM_CMD_POWERDOWN_MODE ((uint32_t)0x00000006)
  785. #define IS_FMC_COMMAND_MODE(COMMAND) (((COMMAND) == FMC_SDRAM_CMD_NORMAL_MODE) || \
  786. ((COMMAND) == FMC_SDRAM_CMD_CLK_ENABLE) || \
  787. ((COMMAND) == FMC_SDRAM_CMD_PALL) || \
  788. ((COMMAND) == FMC_SDRAM_CMD_AUTOREFRESH_MODE) || \
  789. ((COMMAND) == FMC_SDRAM_CMD_LOAD_MODE) || \
  790. ((COMMAND) == FMC_SDRAM_CMD_SELFREFRESH_MODE) || \
  791. ((COMMAND) == FMC_SDRAM_CMD_POWERDOWN_MODE))
  792. /**
  793. * @}
  794. */
  795. /** @defgroup FMC_SDRAM_Command_Target
  796. * @{
  797. */
  798. #define FMC_SDRAM_CMD_TARGET_BANK2 FMC_SDCMR_CTB2
  799. #define FMC_SDRAM_CMD_TARGET_BANK1 FMC_SDCMR_CTB1
  800. #define FMC_SDRAM_CMD_TARGET_BANK1_2 ((uint32_t)0x00000018)
  801. #define IS_FMC_COMMAND_TARGET(TARGET) (((TARGET) == FMC_SDRAM_CMD_TARGET_BANK1) || \
  802. ((TARGET) == FMC_SDRAM_CMD_TARGET_BANK2) || \
  803. ((TARGET) == FMC_SDRAM_CMD_TARGET_BANK1_2))
  804. /**
  805. * @}
  806. */
  807. /** @defgroup FMC_SDRAM_AutoRefresh_Number
  808. * @{
  809. */
  810. #define IS_FMC_AUTOREFRESH_NUMBER(NUMBER) (((NUMBER) > 0) && ((NUMBER) <= 16))
  811. /**
  812. * @}
  813. */
  814. /** @defgroup FMC_SDRAM_ModeRegister_Definition
  815. * @{
  816. */
  817. #define IS_FMC_MODE_REGISTER(CONTENT) ((CONTENT) <= 8191)
  818. /**
  819. * @}
  820. */
  821. /** @defgroup FMC_SDRAM_Refresh_rate
  822. * @{
  823. */
  824. #define IS_FMC_REFRESH_RATE(RATE) ((RATE) <= 8191)
  825. /**
  826. * @}
  827. */
  828. /** @defgroup FMC_SDRAM_Mode_Status
  829. * @{
  830. */
  831. #define FMC_SDRAM_NORMAL_MODE ((uint32_t)0x00000000)
  832. #define FMC_SDRAM_SELF_REFRESH_MODE FMC_SDSR_MODES1_0
  833. #define FMC_SDRAM_POWER_DOWN_MODE FMC_SDSR_MODES1_1
  834. /**
  835. * @}
  836. */
  837. /** @defgroup FMC_NORSRAM_Device_Instance
  838. * @{
  839. */
  840. #define IS_FMC_NORSRAM_DEVICE(INSTANCE) ((INSTANCE) == FMC_NORSRAM_DEVICE)
  841. /**
  842. * @}
  843. */
  844. /** @defgroup FMC_NORSRAM_EXTENDED_Device_Instance
  845. * @{
  846. */
  847. #define IS_FMC_NORSRAM_EXTENDED_DEVICE(INSTANCE) ((INSTANCE) == FMC_NORSRAM_EXTENDED_DEVICE)
  848. /**
  849. * @}
  850. */
  851. /** @defgroup FMC_NAND_Device_Instance
  852. * @{
  853. */
  854. #define IS_FMC_NAND_DEVICE(INSTANCE) ((INSTANCE) == FMC_NAND_DEVICE)
  855. /**
  856. * @}
  857. */
  858. /** @defgroup FMC_PCCARD_Device_Instance
  859. * @{
  860. */
  861. #define IS_FMC_PCCARD_DEVICE(INSTANCE) ((INSTANCE) == FMC_PCCARD_DEVICE)
  862. /**
  863. * @}
  864. */
  865. /** @defgroup FMC_SDRAM_Device_Instance
  866. * @{
  867. */
  868. #define IS_FMC_SDRAM_DEVICE(INSTANCE) ((INSTANCE) == FMC_SDRAM_DEVICE)
  869. /**
  870. * @}
  871. */
  872. /**
  873. * @}
  874. */
  875. /** @defgroup FMC_Interrupt_definition
  876. * @brief FMC Interrupt definition
  877. * @{
  878. */
  879. #define FMC_IT_RISING_EDGE ((uint32_t)0x00000008)
  880. #define FMC_IT_LEVEL ((uint32_t)0x00000010)
  881. #define FMC_IT_FALLING_EDGE ((uint32_t)0x00000020)
  882. #define FMC_IT_REFRESH_ERROR ((uint32_t)0x00004000)
  883. #define IS_FMC_IT(IT) ((((IT) & (uint32_t)0xFFFFBFC7) == 0x00000000) && ((IT) != 0x00000000))
  884. #define IS_FMC_GET_IT(IT) (((IT) == FMC_IT_RISING_EDGE) || \
  885. ((IT) == FMC_IT_LEVEL) || \
  886. ((IT) == FMC_IT_FALLING_EDGE) || \
  887. ((IT) == FMC_IT_REFRESH_ERROR))
  888. /**
  889. * @}
  890. */
  891. /** @defgroup FMC_Flag_definition
  892. * @brief FMC Flag definition
  893. * @{
  894. */
  895. #define FMC_FLAG_RISING_EDGE ((uint32_t)0x00000001)
  896. #define FMC_FLAG_LEVEL ((uint32_t)0x00000002)
  897. #define FMC_FLAG_FALLING_EDGE ((uint32_t)0x00000004)
  898. #define FMC_FLAG_FEMPT ((uint32_t)0x00000040)
  899. #define FMC_SDRAM_FLAG_REFRESH_IT FMC_SDSR_RE
  900. #define FMC_SDRAM_FLAG_BUSY FMC_SDSR_BUSY
  901. #define FMC_SDRAM_FLAG_REFRESH_ERROR FMC_SDRTR_CRE
  902. #define IS_FMC_GET_FLAG(FLAG) (((FLAG) == FMC_FLAG_RISING_EDGE) || \
  903. ((FLAG) == FMC_FLAG_LEVEL) || \
  904. ((FLAG) == FMC_FLAG_FALLING_EDGE) || \
  905. ((FLAG) == FMC_FLAG_FEMPT) || \
  906. ((FLAG) == FMC_SDRAM_FLAG_REFRESH_IT) || \
  907. ((FLAG) == FMC_SDRAM_FLAG_BUSY))
  908. #define IS_FMC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFF8) == 0x00000000) && ((FLAG) != 0x00000000))
  909. /**
  910. * @}
  911. */
  912. /* Exported macro ------------------------------------------------------------*/
  913. /** @defgroup FMC_NOR_Macros
  914. * @brief macros to handle NOR device enable/disable and read/write operations
  915. * @{
  916. */
  917. /**
  918. * @brief Enable the NORSRAM device access.
  919. * @param __INSTANCE__: FMC_NORSRAM Instance
  920. * @param __BANK__: FMC_NORSRAM Bank
  921. * @retval None
  922. */
  923. #define __FMC_NORSRAM_ENABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] |= FMC_BCR1_MBKEN)
  924. /**
  925. * @brief Disable the NORSRAM device access.
  926. * @param __INSTANCE__: FMC_NORSRAM Instance
  927. * @param __BANK__: FMC_NORSRAM Bank
  928. * @retval None
  929. */
  930. #define __FMC_NORSRAM_DISABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] &= ~FMC_BCR1_MBKEN)
  931. /**
  932. * @}
  933. */
  934. /** @defgroup FMC_NAND_Macros
  935. * @brief macros to handle NAND device enable/disable
  936. * @{
  937. */
  938. /**
  939. * @brief Enable the NAND device access.
  940. * @param __INSTANCE__: FMC_NAND Instance
  941. * @param __BANK__: FMC_NAND Bank
  942. * @retval None
  943. */
  944. #define __FMC_NAND_ENABLE(__INSTANCE__, __BANK__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 |= FMC_PCR2_PBKEN): \
  945. ((__INSTANCE__)->PCR3 |= FMC_PCR3_PBKEN))
  946. /**
  947. * @brief Disable the NAND device access.
  948. * @param __INSTANCE__: FMC_NAND Instance
  949. * @param __BANK__: FMC_NAND Bank
  950. * @retval None
  951. */
  952. #define __FMC_NAND_DISABLE(__INSTANCE__, __BANK__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 &= ~FMC_PCR2_PBKEN): \
  953. ((__INSTANCE__)->PCR3 &= ~FMC_PCR3_PBKEN))
  954. /**
  955. * @}
  956. */
  957. /** @defgroup FMC_PCCARD_Macros
  958. * @brief macros to handle SRAM read/write operations
  959. * @{
  960. */
  961. /**
  962. * @brief Enable the PCCARD device access.
  963. * @param __INSTANCE__: FMC_PCCARD Instance
  964. * @retval None
  965. */
  966. #define __FMC_PCCARD_ENABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 |= FMC_PCR4_PBKEN)
  967. /**
  968. * @brief Disable the PCCARD device access.
  969. * @param __INSTANCE__: FMC_PCCARD Instance
  970. * @retval None
  971. */
  972. #define __FMC_PCCARD_DISABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 &= ~FMC_PCR4_PBKEN)
  973. /**
  974. * @}
  975. */
  976. /** @defgroup FMC_Interrupt
  977. * @brief macros to handle FMC interrupts
  978. * @{
  979. */
  980. /**
  981. * @brief Enable the NAND device interrupt.
  982. * @param __INSTANCE__: FMC_NAND instance
  983. * @param __BANK__: FMC_NAND Bank
  984. * @param __INTERRUPT__: FMC_NAND interrupt
  985. * This parameter can be any combination of the following values:
  986. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  987. * @arg FMC_IT_LEVEL: Interrupt level.
  988. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  989. * @retval None
  990. */
  991. #define __FMC_NAND_ENABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->SR2 |= (__INTERRUPT__)): \
  992. ((__INSTANCE__)->SR3 |= (__INTERRUPT__)))
  993. /**
  994. * @brief Disable the NAND device interrupt.
  995. * @param __INSTANCE__: FMC_NAND handle
  996. * @param __BANK__: FMC_NAND Bank
  997. * @param __INTERRUPT__: FMC_NAND interrupt
  998. * This parameter can be any combination of the following values:
  999. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  1000. * @arg FMC_IT_LEVEL: Interrupt level.
  1001. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  1002. * @retval None
  1003. */
  1004. #define __FMC_NAND_DISABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__INTERRUPT__)): \
  1005. ((__INSTANCE__)->SR3 &= ~(__INTERRUPT__)))
  1006. /**
  1007. * @brief Get flag status of the NAND device.
  1008. * @param __INSTANCE__: FMC_NAND handle
  1009. * @param __BANK__: FMC_NAND Bank
  1010. * @param __FLAG__: FMC_NAND flag
  1011. * This parameter can be any combination of the following values:
  1012. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  1013. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  1014. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  1015. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  1016. * @retval The state of FLAG (SET or RESET).
  1017. */
  1018. #define __FMC_NAND_GET_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__BANK__) == FMC_NAND_BANK2)? (((__INSTANCE__)->SR2 &(__FLAG__)) == (__FLAG__)): \
  1019. (((__INSTANCE__)->SR3 &(__FLAG__)) == (__FLAG__)))
  1020. /**
  1021. * @brief Clear flag status of the NAND device.
  1022. * @param __INSTANCE__: FMC_NAND handle
  1023. * @param __BANK__: FMC_NAND Bank
  1024. * @param __FLAG__: FMC_NAND flag
  1025. * This parameter can be any combination of the following values:
  1026. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  1027. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  1028. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  1029. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  1030. * @retval None
  1031. */
  1032. #define __FMC_NAND_CLEAR_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__BANK__) == FMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__FLAG__)): \
  1033. ((__INSTANCE__)->SR3 &= ~(__FLAG__)))
  1034. /**
  1035. * @brief Enable the PCCARD device interrupt.
  1036. * @param __INSTANCE__: FMC_PCCARD instance
  1037. * @param __INTERRUPT__: FMC_PCCARD interrupt
  1038. * This parameter can be any combination of the following values:
  1039. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  1040. * @arg FMC_IT_LEVEL: Interrupt level.
  1041. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  1042. * @retval None
  1043. */
  1044. #define __FMC_PCCARD_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR4 |= (__INTERRUPT__))
  1045. /**
  1046. * @brief Disable the PCCARD device interrupt.
  1047. * @param __INSTANCE__: FMC_PCCARD instance
  1048. * @param __INTERRUPT__: FMC_PCCARD interrupt
  1049. * This parameter can be any combination of the following values:
  1050. * @arg FMC_IT_RISING_EDGE: Interrupt rising edge.
  1051. * @arg FMC_IT_LEVEL: Interrupt level.
  1052. * @arg FMC_IT_FALLING_EDGE: Interrupt falling edge.
  1053. * @retval None
  1054. */
  1055. #define __FMC_PCCARD_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR4 &= ~(__INTERRUPT__))
  1056. /**
  1057. * @brief Get flag status of the PCCARD device.
  1058. * @param __INSTANCE__: FMC_PCCARD instance
  1059. * @param __FLAG__: FMC_PCCARD flag
  1060. * This parameter can be any combination of the following values:
  1061. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  1062. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  1063. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  1064. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  1065. * @retval The state of FLAG (SET or RESET).
  1066. */
  1067. #define __FMC_PCCARD_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->SR4 &(__FLAG__)) == (__FLAG__))
  1068. /**
  1069. * @brief Clear flag status of the PCCARD device.
  1070. * @param __INSTANCE__: FMC_PCCARD instance
  1071. * @param __FLAG__: FMC_PCCARD flag
  1072. * This parameter can be any combination of the following values:
  1073. * @arg FMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  1074. * @arg FMC_FLAG_LEVEL: Interrupt level edge flag.
  1075. * @arg FMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  1076. * @arg FMC_FLAG_FEMPT: FIFO empty flag.
  1077. * @retval None
  1078. */
  1079. #define __FMC_PCCARD_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->SR4 &= ~(__FLAG__))
  1080. /**
  1081. * @brief Enable the SDRAM device interrupt.
  1082. * @param __INSTANCE__: FMC_SDRAM instance
  1083. * @param __INTERRUPT__: FMC_SDRAM interrupt
  1084. * This parameter can be any combination of the following values:
  1085. * @arg FMC_IT_REFRESH_ERROR: Interrupt refresh error
  1086. * @retval None
  1087. */
  1088. #define __FMC_SDRAM_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SDRTR |= (__INTERRUPT__))
  1089. /**
  1090. * @brief Disable the SDRAM device interrupt.
  1091. * @param __INSTANCE__: FMC_SDRAM instance
  1092. * @param __INTERRUPT__: FMC_SDRAM interrupt
  1093. * This parameter can be any combination of the following values:
  1094. * @arg FMC_IT_REFRESH_ERROR: Interrupt refresh error
  1095. * @retval None
  1096. */
  1097. #define __FMC_SDRAM_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SDRTR &= ~(__INTERRUPT__))
  1098. /**
  1099. * @brief Get flag status of the SDRAM device.
  1100. * @param __INSTANCE__: FMC_SDRAM instance
  1101. * @param __FLAG__: FMC_SDRAM flag
  1102. * This parameter can be any combination of the following values:
  1103. * @arg FMC_SDRAM_FLAG_REFRESH_IT: Interrupt refresh error.
  1104. * @arg FMC_SDRAM_FLAG_BUSY: SDRAM busy flag.
  1105. * @arg FMC_SDRAM_FLAG_REFRESH_ERROR: Refresh error flag.
  1106. * @retval The state of FLAG (SET or RESET).
  1107. */
  1108. #define __FMC_SDRAM_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->SDSR &(__FLAG__)) == (__FLAG__))
  1109. /**
  1110. * @brief Clear flag status of the SDRAM device.
  1111. * @param __INSTANCE__: FMC_SDRAM instance
  1112. * @param __FLAG__: FMC_SDRAM flag
  1113. * This parameter can be any combination of the following values:
  1114. * @arg FMC_SDRAM_FLAG_REFRESH_ERROR
  1115. * @retval None
  1116. */
  1117. #define __FMC_SDRAM_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->SDRTR |= (__FLAG__))
  1118. /**
  1119. * @}
  1120. */
  1121. /* Exported functions --------------------------------------------------------*/
  1122. /* FMC_NORSRAM Controller functions *******************************************/
  1123. /* Initialization/de-initialization functions */
  1124. HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_InitTypeDef *Init);
  1125. HAL_StatusTypeDef FMC_NORSRAM_Timing_Init(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank);
  1126. HAL_StatusTypeDef FMC_NORSRAM_Extended_Timing_Init(FMC_NORSRAM_EXTENDED_TypeDef *Device, FMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode);
  1127. HAL_StatusTypeDef FMC_NORSRAM_DeInit(FMC_NORSRAM_TypeDef *Device, FMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank);
  1128. /* FMC_NORSRAM Control functions */
  1129. HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Enable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  1130. HAL_StatusTypeDef FMC_NORSRAM_WriteOperation_Disable(FMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  1131. /* FMC_NAND Controller functions **********************************************/
  1132. /* Initialization/de-initialization functions */
  1133. HAL_StatusTypeDef FMC_NAND_Init(FMC_NAND_TypeDef *Device, FMC_NAND_InitTypeDef *Init);
  1134. HAL_StatusTypeDef FMC_NAND_CommonSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  1135. HAL_StatusTypeDef FMC_NAND_AttributeSpace_Timing_Init(FMC_NAND_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  1136. HAL_StatusTypeDef FMC_NAND_DeInit(FMC_NAND_TypeDef *Device, uint32_t Bank);
  1137. /* FMC_NAND Control functions */
  1138. HAL_StatusTypeDef FMC_NAND_ECC_Enable(FMC_NAND_TypeDef *Device, uint32_t Bank);
  1139. HAL_StatusTypeDef FMC_NAND_ECC_Disable(FMC_NAND_TypeDef *Device, uint32_t Bank);
  1140. HAL_StatusTypeDef FMC_NAND_GetECC(FMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout);
  1141. /* FMC_PCCARD Controller functions ********************************************/
  1142. /* Initialization/de-initialization functions */
  1143. HAL_StatusTypeDef FMC_PCCARD_Init(FMC_PCCARD_TypeDef *Device, FMC_PCCARD_InitTypeDef *Init);
  1144. HAL_StatusTypeDef FMC_PCCARD_CommonSpace_Timing_Init(FMC_PCCARD_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing);
  1145. HAL_StatusTypeDef FMC_PCCARD_AttributeSpace_Timing_Init(FMC_PCCARD_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing);
  1146. HAL_StatusTypeDef FMC_PCCARD_IOSpace_Timing_Init(FMC_PCCARD_TypeDef *Device, FMC_NAND_PCC_TimingTypeDef *Timing);
  1147. HAL_StatusTypeDef FMC_PCCARD_DeInit(FMC_PCCARD_TypeDef *Device);
  1148. /* FMC_SDRAM Controller functions *********************************************/
  1149. /* Initialization/de-initialization functions */
  1150. HAL_StatusTypeDef FMC_SDRAM_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_InitTypeDef *Init);
  1151. HAL_StatusTypeDef FMC_SDRAM_Timing_Init(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_TimingTypeDef *Timing, uint32_t Bank);
  1152. HAL_StatusTypeDef FMC_SDRAM_DeInit(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  1153. /* FMC_SDRAM Control functions */
  1154. HAL_StatusTypeDef FMC_SDRAM_WriteProtection_Enable(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  1155. HAL_StatusTypeDef FMC_SDRAM_WriteProtection_Disable(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  1156. HAL_StatusTypeDef FMC_SDRAM_SendCommand(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_CommandTypeDef *Command, uint32_t Timeout);
  1157. HAL_StatusTypeDef FMC_SDRAM_ProgramRefreshRate(FMC_SDRAM_TypeDef *Device, uint32_t RefreshRate);
  1158. HAL_StatusTypeDef FMC_SDRAM_SetAutoRefreshNumber(FMC_SDRAM_TypeDef *Device, uint32_t AutoRefreshNumber);
  1159. uint32_t FMC_SDRAM_GetModeStatus(FMC_SDRAM_TypeDef *Device, uint32_t Bank);
  1160. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
  1161. /**
  1162. * @}
  1163. */
  1164. /**
  1165. * @}
  1166. */
  1167. #ifdef __cplusplus
  1168. }
  1169. #endif
  1170. #endif /* __STM32F4xx_LL_FMC_H */
  1171. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/