stm32f4xx_ll_fsmc.h 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_ll_fsmc.h
  4. * @author MCD Application Team
  5. * @brief Header file of FSMC HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F4xx_LL_FSMC_H
  37. #define __STM32F4xx_LL_FSMC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f4xx_hal_def.h"
  43. /** @addtogroup STM32F4xx_HAL_Driver
  44. * @{
  45. */
  46. /** @addtogroup FSMC_LL
  47. * @{
  48. */
  49. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  50. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  51. /* Private types -------------------------------------------------------------*/
  52. /** @defgroup FSMC_LL_Private_Types FSMC Private Types
  53. * @{
  54. */
  55. /**
  56. * @brief FSMC NORSRAM Configuration Structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t NSBank; /*!< Specifies the NORSRAM memory device that will be used.
  61. This parameter can be a value of @ref FSMC_NORSRAM_Bank */
  62. uint32_t DataAddressMux; /*!< Specifies whether the address and data values are
  63. multiplexed on the data bus or not.
  64. This parameter can be a value of @ref FSMC_Data_Address_Bus_Multiplexing */
  65. uint32_t MemoryType; /*!< Specifies the type of external memory attached to
  66. the corresponding memory device.
  67. This parameter can be a value of @ref FSMC_Memory_Type */
  68. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  69. This parameter can be a value of @ref FSMC_NORSRAM_Data_Width */
  70. uint32_t BurstAccessMode; /*!< Enables or disables the burst access mode for Flash memory,
  71. valid only with synchronous burst Flash memories.
  72. This parameter can be a value of @ref FSMC_Burst_Access_Mode */
  73. uint32_t WaitSignalPolarity; /*!< Specifies the wait signal polarity, valid only when accessing
  74. the Flash memory in burst mode.
  75. This parameter can be a value of @ref FSMC_Wait_Signal_Polarity */
  76. uint32_t WrapMode; /*!< Enables or disables the Wrapped burst access mode for Flash
  77. memory, valid only when accessing Flash memories in burst mode.
  78. This parameter can be a value of @ref FSMC_Wrap_Mode
  79. This mode is available only for the STM32F405/407/4015/417xx devices */
  80. uint32_t WaitSignalActive; /*!< Specifies if the wait signal is asserted by the memory one
  81. clock cycle before the wait state or during the wait state,
  82. valid only when accessing memories in burst mode.
  83. This parameter can be a value of @ref FSMC_Wait_Timing */
  84. uint32_t WriteOperation; /*!< Enables or disables the write operation in the selected device by the FSMC.
  85. This parameter can be a value of @ref FSMC_Write_Operation */
  86. uint32_t WaitSignal; /*!< Enables or disables the wait state insertion via wait
  87. signal, valid for Flash memory access in burst mode.
  88. This parameter can be a value of @ref FSMC_Wait_Signal */
  89. uint32_t ExtendedMode; /*!< Enables or disables the extended mode.
  90. This parameter can be a value of @ref FSMC_Extended_Mode */
  91. uint32_t AsynchronousWait; /*!< Enables or disables wait signal during asynchronous transfers,
  92. valid only with asynchronous Flash memories.
  93. This parameter can be a value of @ref FSMC_AsynchronousWait */
  94. uint32_t WriteBurst; /*!< Enables or disables the write burst operation.
  95. This parameter can be a value of @ref FSMC_Write_Burst */
  96. uint32_t ContinuousClock; /*!< Enables or disables the FMC clock output to external memory devices.
  97. This parameter is only enabled through the FMC_BCR1 register, and don't care
  98. through FMC_BCR2..4 registers.
  99. This parameter can be a value of @ref FMC_Continous_Clock
  100. This mode is available only for the STM32F412Vx/Zx/Rx devices */
  101. uint32_t WriteFifo; /*!< Enables or disables the write FIFO used by the FMC controller.
  102. This parameter is only enabled through the FMC_BCR1 register, and don't care
  103. through FMC_BCR2..4 registers.
  104. This parameter can be a value of @ref FMC_Write_FIFO
  105. This mode is available only for the STM32F412Vx/Vx devices */
  106. uint32_t PageSize; /*!< Specifies the memory page size.
  107. This parameter can be a value of @ref FMC_Page_Size */
  108. }FSMC_NORSRAM_InitTypeDef;
  109. /**
  110. * @brief FSMC NORSRAM Timing parameters structure definition
  111. */
  112. typedef struct
  113. {
  114. uint32_t AddressSetupTime; /*!< Defines the number of HCLK cycles to configure
  115. the duration of the address setup time.
  116. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  117. @note This parameter is not used with synchronous NOR Flash memories. */
  118. uint32_t AddressHoldTime; /*!< Defines the number of HCLK cycles to configure
  119. the duration of the address hold time.
  120. This parameter can be a value between Min_Data = 1 and Max_Data = 15.
  121. @note This parameter is not used with synchronous NOR Flash memories. */
  122. uint32_t DataSetupTime; /*!< Defines the number of HCLK cycles to configure
  123. the duration of the data setup time.
  124. This parameter can be a value between Min_Data = 1 and Max_Data = 255.
  125. @note This parameter is used for SRAMs, ROMs and asynchronous multiplexed
  126. NOR Flash memories. */
  127. uint32_t BusTurnAroundDuration; /*!< Defines the number of HCLK cycles to configure
  128. the duration of the bus turnaround.
  129. This parameter can be a value between Min_Data = 0 and Max_Data = 15.
  130. @note This parameter is only used for multiplexed NOR Flash memories. */
  131. uint32_t CLKDivision; /*!< Defines the period of CLK clock output signal, expressed in number of
  132. HCLK cycles. This parameter can be a value between Min_Data = 2 and Max_Data = 16.
  133. @note This parameter is not used for asynchronous NOR Flash, SRAM or ROM
  134. accesses. */
  135. uint32_t DataLatency; /*!< Defines the number of memory clock cycles to issue
  136. to the memory before getting the first data.
  137. The parameter value depends on the memory type as shown below:
  138. - It must be set to 0 in case of a CRAM
  139. - It is don't care in asynchronous NOR, SRAM or ROM accesses
  140. - It may assume a value between Min_Data = 2 and Max_Data = 17 in NOR Flash memories
  141. with synchronous burst mode enable */
  142. uint32_t AccessMode; /*!< Specifies the asynchronous access mode.
  143. This parameter can be a value of @ref FSMC_Access_Mode */
  144. }FSMC_NORSRAM_TimingTypeDef;
  145. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  146. /**
  147. * @brief FSMC NAND Configuration Structure definition
  148. */
  149. typedef struct
  150. {
  151. uint32_t NandBank; /*!< Specifies the NAND memory device that will be used.
  152. This parameter can be a value of @ref FSMC_NAND_Bank */
  153. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the NAND Memory device.
  154. This parameter can be any value of @ref FSMC_Wait_feature */
  155. uint32_t MemoryDataWidth; /*!< Specifies the external memory device width.
  156. This parameter can be any value of @ref FSMC_NAND_Data_Width */
  157. uint32_t EccComputation; /*!< Enables or disables the ECC computation.
  158. This parameter can be any value of @ref FSMC_ECC */
  159. uint32_t ECCPageSize; /*!< Defines the page size for the extended ECC.
  160. This parameter can be any value of @ref FSMC_ECC_Page_Size */
  161. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  162. delay between CLE low and RE low.
  163. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  164. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  165. delay between ALE low and RE low.
  166. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  167. }FSMC_NAND_InitTypeDef;
  168. /**
  169. * @brief FSMC NAND/PCCARD Timing parameters structure definition
  170. */
  171. typedef struct
  172. {
  173. uint32_t SetupTime; /*!< Defines the number of HCLK cycles to setup address before
  174. the command assertion for NAND-Flash read or write access
  175. to common/Attribute or I/O memory space (depending on
  176. the memory space timing to be configured).
  177. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  178. uint32_t WaitSetupTime; /*!< Defines the minimum number of HCLK cycles to assert the
  179. command for NAND-Flash read or write access to
  180. common/Attribute or I/O memory space (depending on the
  181. memory space timing to be configured).
  182. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  183. uint32_t HoldSetupTime; /*!< Defines the number of HCLK clock cycles to hold address
  184. (and data for write access) after the command de-assertion
  185. for NAND-Flash read or write access to common/Attribute
  186. or I/O memory space (depending on the memory space timing
  187. to be configured).
  188. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  189. uint32_t HiZSetupTime; /*!< Defines the number of HCLK clock cycles during which the
  190. data bus is kept in HiZ after the start of a NAND-Flash
  191. write access to common/Attribute or I/O memory space (depending
  192. on the memory space timing to be configured).
  193. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  194. }FSMC_NAND_PCC_TimingTypeDef;
  195. /**
  196. * @brief FSMC NAND Configuration Structure definition
  197. */
  198. typedef struct
  199. {
  200. uint32_t Waitfeature; /*!< Enables or disables the Wait feature for the PCCARD Memory device.
  201. This parameter can be any value of @ref FSMC_Wait_feature */
  202. uint32_t TCLRSetupTime; /*!< Defines the number of HCLK cycles to configure the
  203. delay between CLE low and RE low.
  204. This parameter can be a value between Min_Data = 0 and Max_Data = 255 */
  205. uint32_t TARSetupTime; /*!< Defines the number of HCLK cycles to configure the
  206. delay between ALE low and RE low.
  207. This parameter can be a number between Min_Data = 0 and Max_Data = 255 */
  208. }FSMC_PCCARD_InitTypeDef;
  209. /**
  210. * @}
  211. */
  212. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  213. /* Private constants ---------------------------------------------------------*/
  214. /** @defgroup FSMC_LL_Private_Constants FSMC Private Constants
  215. * @{
  216. */
  217. /** @defgroup FSMC_LL_NOR_SRAM_Controller FSMC NOR/SRAM Controller
  218. * @{
  219. */
  220. /** @defgroup FSMC_NORSRAM_Bank FSMC NOR/SRAM Bank
  221. * @{
  222. */
  223. #define FSMC_NORSRAM_BANK1 0x00000000U
  224. #define FSMC_NORSRAM_BANK2 0x00000002U
  225. #define FSMC_NORSRAM_BANK3 0x00000004U
  226. #define FSMC_NORSRAM_BANK4 0x00000006U
  227. /**
  228. * @}
  229. */
  230. /** @defgroup FSMC_Data_Address_Bus_Multiplexing FSMC Data Address Bus Multiplexing
  231. * @{
  232. */
  233. #define FSMC_DATA_ADDRESS_MUX_DISABLE 0x00000000U
  234. #define FSMC_DATA_ADDRESS_MUX_ENABLE 0x00000002U
  235. /**
  236. * @}
  237. */
  238. /** @defgroup FSMC_Memory_Type FSMC Memory Type
  239. * @{
  240. */
  241. #define FSMC_MEMORY_TYPE_SRAM 0x00000000U
  242. #define FSMC_MEMORY_TYPE_PSRAM 0x00000004U
  243. #define FSMC_MEMORY_TYPE_NOR 0x00000008U
  244. /**
  245. * @}
  246. */
  247. /** @defgroup FSMC_NORSRAM_Data_Width FSMC NOR/SRAM Data Width
  248. * @{
  249. */
  250. #define FSMC_NORSRAM_MEM_BUS_WIDTH_8 0x00000000U
  251. #define FSMC_NORSRAM_MEM_BUS_WIDTH_16 0x00000010U
  252. #define FSMC_NORSRAM_MEM_BUS_WIDTH_32 0x00000020U
  253. /**
  254. * @}
  255. */
  256. /** @defgroup FSMC_NORSRAM_Flash_Access FSMC NOR/SRAM Flash Access
  257. * @{
  258. */
  259. #define FSMC_NORSRAM_FLASH_ACCESS_ENABLE 0x00000040U
  260. #define FSMC_NORSRAM_FLASH_ACCESS_DISABLE 0x00000000U
  261. /**
  262. * @}
  263. */
  264. /** @defgroup FSMC_Burst_Access_Mode FSMC Burst Access Mode
  265. * @{
  266. */
  267. #define FSMC_BURST_ACCESS_MODE_DISABLE 0x00000000U
  268. #define FSMC_BURST_ACCESS_MODE_ENABLE 0x00000100U
  269. /**
  270. * @}
  271. */
  272. /** @defgroup FSMC_Wait_Signal_Polarity FSMC Wait Signal Polarity
  273. * @{
  274. */
  275. #define FSMC_WAIT_SIGNAL_POLARITY_LOW 0x00000000U
  276. #define FSMC_WAIT_SIGNAL_POLARITY_HIGH 0x00000200U
  277. /**
  278. * @}
  279. */
  280. /** @defgroup FSMC_Wrap_Mode FSMC Wrap Mode
  281. * @note These values are available only for the STM32F405/415/407/417xx devices.
  282. * @{
  283. */
  284. #define FSMC_WRAP_MODE_DISABLE 0x00000000U
  285. #define FSMC_WRAP_MODE_ENABLE 0x00000400U
  286. /**
  287. * @}
  288. */
  289. /** @defgroup FSMC_Wait_Timing FSMC Wait Timing
  290. * @{
  291. */
  292. #define FSMC_WAIT_TIMING_BEFORE_WS 0x00000000U
  293. #define FSMC_WAIT_TIMING_DURING_WS 0x00000800U
  294. /**
  295. * @}
  296. */
  297. /** @defgroup FSMC_Write_Operation FSMC Write Operation
  298. * @{
  299. */
  300. #define FSMC_WRITE_OPERATION_DISABLE 0x00000000U
  301. #define FSMC_WRITE_OPERATION_ENABLE 0x00001000U
  302. /**
  303. * @}
  304. */
  305. /** @defgroup FSMC_Wait_Signal FSMC Wait Signal
  306. * @{
  307. */
  308. #define FSMC_WAIT_SIGNAL_DISABLE 0x00000000U
  309. #define FSMC_WAIT_SIGNAL_ENABLE 0x00002000U
  310. /**
  311. * @}
  312. */
  313. /** @defgroup FSMC_Extended_Mode FSMC Extended Mode
  314. * @{
  315. */
  316. #define FSMC_EXTENDED_MODE_DISABLE 0x00000000U
  317. #define FSMC_EXTENDED_MODE_ENABLE 0x00004000U
  318. /**
  319. * @}
  320. */
  321. /** @defgroup FSMC_AsynchronousWait FSMC Asynchronous Wait
  322. * @{
  323. */
  324. #define FSMC_ASYNCHRONOUS_WAIT_DISABLE 0x00000000U
  325. #define FSMC_ASYNCHRONOUS_WAIT_ENABLE 0x00008000U
  326. /**
  327. * @}
  328. */
  329. /** @defgroup FSMC_Page_Size FSMC Page Size
  330. * @{
  331. */
  332. #define FSMC_PAGE_SIZE_NONE 0x00000000U
  333. #define FSMC_PAGE_SIZE_128 ((uint32_t)FSMC_BCR1_CPSIZE_0)
  334. #define FSMC_PAGE_SIZE_256 ((uint32_t)FSMC_BCR1_CPSIZE_1)
  335. #define FSMC_PAGE_SIZE_512 ((uint32_t)(FSMC_BCR1_CPSIZE_0 | FSMC_BCR1_CPSIZE_1))
  336. #define FSMC_PAGE_SIZE_1024 ((uint32_t)FSMC_BCR1_CPSIZE_2)
  337. /**
  338. * @}
  339. */
  340. /** @defgroup FSMC_Write_FIFO FSMC Write FIFO
  341. * @note These values are available only for the STM32F412Vx/Zx/Rx devices.
  342. * @{
  343. */
  344. #define FSMC_WRITE_FIFO_DISABLE ((uint32_t)FSMC_BCR1_WFDIS)
  345. #define FSMC_WRITE_FIFO_ENABLE 0x00000000U
  346. /**
  347. * @}
  348. */
  349. /** @defgroup FSMC_Write_Burst FSMC Write Burst
  350. * @{
  351. */
  352. #define FSMC_WRITE_BURST_DISABLE 0x00000000U
  353. #define FSMC_WRITE_BURST_ENABLE 0x00080000U
  354. /**
  355. * @}
  356. */
  357. /** @defgroup FSMC_Continous_Clock FSMC Continous Clock
  358. * @note These values are available only for the STM32F412Vx/Zx/Rx devices.
  359. * @{
  360. */
  361. #define FSMC_CONTINUOUS_CLOCK_SYNC_ONLY 0x00000000U
  362. #define FSMC_CONTINUOUS_CLOCK_SYNC_ASYNC 0x00100000U
  363. /**
  364. * @}
  365. */
  366. /** @defgroup FSMC_Access_Mode FSMC Access Mode
  367. * @{
  368. */
  369. #define FSMC_ACCESS_MODE_A 0x00000000U
  370. #define FSMC_ACCESS_MODE_B 0x10000000U
  371. #define FSMC_ACCESS_MODE_C 0x20000000U
  372. #define FSMC_ACCESS_MODE_D 0x30000000U
  373. /**
  374. * @}
  375. */
  376. /**
  377. * @}
  378. */
  379. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  380. /** @defgroup FSMC_LL_NAND_Controller FSMC NAND and PCCARD Controller
  381. * @{
  382. */
  383. /** @defgroup FSMC_NAND_Bank FSMC NAND Bank
  384. * @{
  385. */
  386. #define FSMC_NAND_BANK2 0x00000010U
  387. #define FSMC_NAND_BANK3 0x00000100U
  388. /**
  389. * @}
  390. */
  391. /** @defgroup FSMC_Wait_feature FSMC Wait feature
  392. * @{
  393. */
  394. #define FSMC_NAND_PCC_WAIT_FEATURE_DISABLE 0x00000000U
  395. #define FSMC_NAND_PCC_WAIT_FEATURE_ENABLE 0x00000002U
  396. /**
  397. * @}
  398. */
  399. /** @defgroup FSMC_PCR_Memory_Type FSMC PCR Memory Type
  400. * @{
  401. */
  402. #define FSMC_PCR_MEMORY_TYPE_PCCARD 0x00000000U
  403. #define FSMC_PCR_MEMORY_TYPE_NAND 0x00000008U
  404. /**
  405. * @}
  406. */
  407. /** @defgroup FSMC_NAND_Data_Width FSMC NAND Data Width
  408. * @{
  409. */
  410. #define FSMC_NAND_PCC_MEM_BUS_WIDTH_8 0x00000000U
  411. #define FSMC_NAND_PCC_MEM_BUS_WIDTH_16 0x00000010U
  412. /**
  413. * @}
  414. */
  415. /** @defgroup FSMC_ECC FSMC ECC
  416. * @{
  417. */
  418. #define FSMC_NAND_ECC_DISABLE 0x00000000U
  419. #define FSMC_NAND_ECC_ENABLE 0x00000040U
  420. /**
  421. * @}
  422. */
  423. /** @defgroup FSMC_ECC_Page_Size FSMC ECC Page Size
  424. * @{
  425. */
  426. #define FSMC_NAND_ECC_PAGE_SIZE_256BYTE 0x00000000U
  427. #define FSMC_NAND_ECC_PAGE_SIZE_512BYTE 0x00020000U
  428. #define FSMC_NAND_ECC_PAGE_SIZE_1024BYTE 0x00040000U
  429. #define FSMC_NAND_ECC_PAGE_SIZE_2048BYTE 0x00060000U
  430. #define FSMC_NAND_ECC_PAGE_SIZE_4096BYTE 0x00080000U
  431. #define FSMC_NAND_ECC_PAGE_SIZE_8192BYTE 0x000A0000U
  432. /**
  433. * @}
  434. */
  435. /**
  436. * @}
  437. */
  438. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  439. /** @defgroup FSMC_LL_Interrupt_definition FSMC Interrupt definition
  440. * @{
  441. */
  442. #define FSMC_IT_RISING_EDGE 0x00000008U
  443. #define FSMC_IT_LEVEL 0x00000010U
  444. #define FSMC_IT_FALLING_EDGE 0x00000020U
  445. #define FSMC_IT_REFRESH_ERROR 0x00004000U
  446. /**
  447. * @}
  448. */
  449. /** @defgroup FSMC_LL_Flag_definition FSMC Flag definition
  450. * @{
  451. */
  452. #define FSMC_FLAG_RISING_EDGE 0x00000001U
  453. #define FSMC_FLAG_LEVEL 0x00000002U
  454. #define FSMC_FLAG_FALLING_EDGE 0x00000004U
  455. #define FSMC_FLAG_FEMPT 0x00000040U
  456. /**
  457. * @}
  458. */
  459. /** @defgroup FSMC_LL_Alias_definition FSMC Alias definition
  460. * @{
  461. */
  462. #define FSMC_NORSRAM_TypeDef FSMC_Bank1_TypeDef
  463. #define FSMC_NORSRAM_EXTENDED_TypeDef FSMC_Bank1E_TypeDef
  464. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  465. #define FSMC_NAND_TypeDef FSMC_Bank2_3_TypeDef
  466. #define FSMC_PCCARD_TypeDef FSMC_Bank4_TypeDef
  467. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  468. #define FSMC_NORSRAM_DEVICE FSMC_Bank1
  469. #define FSMC_NORSRAM_EXTENDED_DEVICE FSMC_Bank1E
  470. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  471. #define FSMC_NAND_DEVICE FSMC_Bank2_3
  472. #define FSMC_PCCARD_DEVICE FSMC_Bank4
  473. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  474. #define FMC_NORSRAM_MEM_BUS_WIDTH_8 FSMC_NORSRAM_MEM_BUS_WIDTH_8
  475. #define FMC_NORSRAM_MEM_BUS_WIDTH_16 FSMC_NORSRAM_MEM_BUS_WIDTH_16
  476. #define FMC_NORSRAM_MEM_BUS_WIDTH_32 FSMC_NORSRAM_MEM_BUS_WIDTH_32
  477. #define FMC_NORSRAM_TypeDef FSMC_NORSRAM_TypeDef
  478. #define FMC_NORSRAM_EXTENDED_TypeDef FSMC_NORSRAM_EXTENDED_TypeDef
  479. #define FMC_NORSRAM_InitTypeDef FSMC_NORSRAM_InitTypeDef
  480. #define FMC_NORSRAM_TimingTypeDef FSMC_NORSRAM_TimingTypeDef
  481. #define FMC_NORSRAM_Init FSMC_NORSRAM_Init
  482. #define FMC_NORSRAM_Timing_Init FSMC_NORSRAM_Timing_Init
  483. #define FMC_NORSRAM_Extended_Timing_Init FSMC_NORSRAM_Extended_Timing_Init
  484. #define FMC_NORSRAM_DeInit FSMC_NORSRAM_DeInit
  485. #define FMC_NORSRAM_WriteOperation_Enable FSMC_NORSRAM_WriteOperation_Enable
  486. #define FMC_NORSRAM_WriteOperation_Disable FSMC_NORSRAM_WriteOperation_Disable
  487. #define __FMC_NORSRAM_ENABLE __FSMC_NORSRAM_ENABLE
  488. #define __FMC_NORSRAM_DISABLE __FSMC_NORSRAM_DISABLE
  489. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  490. #define FMC_NAND_InitTypeDef FSMC_NAND_InitTypeDef
  491. #define FMC_PCCARD_InitTypeDef FSMC_PCCARD_InitTypeDef
  492. #define FMC_NAND_PCC_TimingTypeDef FSMC_NAND_PCC_TimingTypeDef
  493. #define FMC_NAND_Init FSMC_NAND_Init
  494. #define FMC_NAND_CommonSpace_Timing_Init FSMC_NAND_CommonSpace_Timing_Init
  495. #define FMC_NAND_AttributeSpace_Timing_Init FSMC_NAND_AttributeSpace_Timing_Init
  496. #define FMC_NAND_DeInit FSMC_NAND_DeInit
  497. #define FMC_NAND_ECC_Enable FSMC_NAND_ECC_Enable
  498. #define FMC_NAND_ECC_Disable FSMC_NAND_ECC_Disable
  499. #define FMC_NAND_GetECC FSMC_NAND_GetECC
  500. #define FMC_PCCARD_Init FSMC_PCCARD_Init
  501. #define FMC_PCCARD_CommonSpace_Timing_Init FSMC_PCCARD_CommonSpace_Timing_Init
  502. #define FMC_PCCARD_AttributeSpace_Timing_Init FSMC_PCCARD_AttributeSpace_Timing_Init
  503. #define FMC_PCCARD_IOSpace_Timing_Init FSMC_PCCARD_IOSpace_Timing_Init
  504. #define FMC_PCCARD_DeInit FSMC_PCCARD_DeInit
  505. #define __FMC_NAND_ENABLE __FSMC_NAND_ENABLE
  506. #define __FMC_NAND_DISABLE __FSMC_NAND_DISABLE
  507. #define __FMC_PCCARD_ENABLE __FSMC_PCCARD_ENABLE
  508. #define __FMC_PCCARD_DISABLE __FSMC_PCCARD_DISABLE
  509. #define __FMC_NAND_ENABLE_IT __FSMC_NAND_ENABLE_IT
  510. #define __FMC_NAND_DISABLE_IT __FSMC_NAND_DISABLE_IT
  511. #define __FMC_NAND_GET_FLAG __FSMC_NAND_GET_FLAG
  512. #define __FMC_NAND_CLEAR_FLAG __FSMC_NAND_CLEAR_FLAG
  513. #define __FMC_PCCARD_ENABLE_IT __FSMC_PCCARD_ENABLE_IT
  514. #define __FMC_PCCARD_DISABLE_IT __FSMC_PCCARD_DISABLE_IT
  515. #define __FMC_PCCARD_GET_FLAG __FSMC_PCCARD_GET_FLAG
  516. #define __FMC_PCCARD_CLEAR_FLAG __FSMC_PCCARD_CLEAR_FLAG
  517. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  518. #define FMC_NORSRAM_TypeDef FSMC_NORSRAM_TypeDef
  519. #define FMC_NORSRAM_EXTENDED_TypeDef FSMC_NORSRAM_EXTENDED_TypeDef
  520. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  521. #define FMC_NAND_TypeDef FSMC_NAND_TypeDef
  522. #define FMC_PCCARD_TypeDef FSMC_PCCARD_TypeDef
  523. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  524. #define FMC_NORSRAM_DEVICE FSMC_NORSRAM_DEVICE
  525. #define FMC_NORSRAM_EXTENDED_DEVICE FSMC_NORSRAM_EXTENDED_DEVICE
  526. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  527. #define FMC_NAND_DEVICE FSMC_NAND_DEVICE
  528. #define FMC_PCCARD_DEVICE FSMC_PCCARD_DEVICE
  529. #define FMC_NAND_BANK2 FSMC_NAND_BANK2
  530. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  531. #define FMC_NORSRAM_BANK1 FSMC_NORSRAM_BANK1
  532. #define FMC_NORSRAM_BANK2 FSMC_NORSRAM_BANK2
  533. #define FMC_NORSRAM_BANK3 FSMC_NORSRAM_BANK3
  534. #define FMC_IT_RISING_EDGE FSMC_IT_RISING_EDGE
  535. #define FMC_IT_LEVEL FSMC_IT_LEVEL
  536. #define FMC_IT_FALLING_EDGE FSMC_IT_FALLING_EDGE
  537. #define FMC_IT_REFRESH_ERROR FSMC_IT_REFRESH_ERROR
  538. #define FMC_FLAG_RISING_EDGE FSMC_FLAG_RISING_EDGE
  539. #define FMC_FLAG_LEVEL FSMC_FLAG_LEVEL
  540. #define FMC_FLAG_FALLING_EDGE FSMC_FLAG_FALLING_EDGE
  541. #define FMC_FLAG_FEMPT FSMC_FLAG_FEMPT
  542. /**
  543. * @}
  544. */
  545. /**
  546. * @}
  547. */
  548. /* Private macro -------------------------------------------------------------*/
  549. /** @defgroup FSMC_LL_Private_Macros FSMC Private Macros
  550. * @{
  551. */
  552. /** @defgroup FSMC_LL_NOR_Macros FSMC NOR/SRAM Exported Macros
  553. * @brief macros to handle NOR device enable/disable and read/write operations
  554. * @{
  555. */
  556. /**
  557. * @brief Enable the NORSRAM device access.
  558. * @param __INSTANCE__ FSMC_NORSRAM Instance
  559. * @param __BANK__ FSMC_NORSRAM Bank
  560. * @retval none
  561. */
  562. #define __FSMC_NORSRAM_ENABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] |= FSMC_BCR1_MBKEN)
  563. /**
  564. * @brief Disable the NORSRAM device access.
  565. * @param __INSTANCE__ FSMC_NORSRAM Instance
  566. * @param __BANK__ FSMC_NORSRAM Bank
  567. * @retval none
  568. */
  569. #define __FSMC_NORSRAM_DISABLE(__INSTANCE__, __BANK__) ((__INSTANCE__)->BTCR[(__BANK__)] &= ~FSMC_BCR1_MBKEN)
  570. /**
  571. * @}
  572. */
  573. /** @defgroup FSMC_LL_NAND_Macros FSMC NAND Macros
  574. * @brief macros to handle NAND device enable/disable
  575. * @{
  576. */
  577. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  578. /**
  579. * @brief Enable the NAND device access.
  580. * @param __INSTANCE__ FSMC_NAND Instance
  581. * @param __BANK__ FSMC_NAND Bank
  582. * @retval none
  583. */
  584. #define __FSMC_NAND_ENABLE(__INSTANCE__, __BANK__) (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 |= FSMC_PCR2_PBKEN): \
  585. ((__INSTANCE__)->PCR3 |= FSMC_PCR3_PBKEN))
  586. /**
  587. * @brief Disable the NAND device access.
  588. * @param __INSTANCE__ FSMC_NAND Instance
  589. * @param __BANK__ FSMC_NAND Bank
  590. * @retval none
  591. */
  592. #define __FSMC_NAND_DISABLE(__INSTANCE__, __BANK__) (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->PCR2 &= ~FSMC_PCR2_PBKEN): \
  593. ((__INSTANCE__)->PCR3 &= ~FSMC_PCR3_PBKEN))
  594. /**
  595. * @}
  596. */
  597. /** @defgroup FSMC_LL_PCCARD_Macros FSMC PCCARD Macros
  598. * @brief macros to handle SRAM read/write operations
  599. * @{
  600. */
  601. /**
  602. * @brief Enable the PCCARD device access.
  603. * @param __INSTANCE__ FSMC_PCCARD Instance
  604. * @retval none
  605. */
  606. #define __FSMC_PCCARD_ENABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 |= FSMC_PCR4_PBKEN)
  607. /**
  608. * @brief Disable the PCCARD device access.
  609. * @param __INSTANCE__ FSMC_PCCARD Instance
  610. * @retval none
  611. */
  612. #define __FSMC_PCCARD_DISABLE(__INSTANCE__) ((__INSTANCE__)->PCR4 &= ~FSMC_PCR4_PBKEN)
  613. /**
  614. * @}
  615. */
  616. /** @defgroup FSMC_LL_Flag_Interrupt_Macros FSMC Flag&Interrupt Macros
  617. * @brief macros to handle FSMC flags and interrupts
  618. * @{
  619. */
  620. /**
  621. * @brief Enable the NAND device interrupt.
  622. * @param __INSTANCE__ FSMC_NAND Instance
  623. * @param __BANK__ FSMC_NAND Bank
  624. * @param __INTERRUPT__ FSMC_NAND interrupt
  625. * This parameter can be any combination of the following values:
  626. * @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
  627. * @arg FSMC_IT_LEVEL: Interrupt level.
  628. * @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.
  629. * @retval None
  630. */
  631. #define __FSMC_NAND_ENABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__) (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->SR2 |= (__INTERRUPT__)): \
  632. ((__INSTANCE__)->SR3 |= (__INTERRUPT__)))
  633. /**
  634. * @brief Disable the NAND device interrupt.
  635. * @param __INSTANCE__ FSMC_NAND Instance
  636. * @param __BANK__ FSMC_NAND Bank
  637. * @param __INTERRUPT__ FSMC_NAND interrupt
  638. * This parameter can be any combination of the following values:
  639. * @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
  640. * @arg FSMC_IT_LEVEL: Interrupt level.
  641. * @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.
  642. * @retval None
  643. */
  644. #define __FSMC_NAND_DISABLE_IT(__INSTANCE__, __BANK__, __INTERRUPT__) (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__INTERRUPT__)): \
  645. ((__INSTANCE__)->SR3 &= ~(__INTERRUPT__)))
  646. /**
  647. * @brief Get flag status of the NAND device.
  648. * @param __INSTANCE__ FSMC_NAND Instance
  649. * @param __BANK__ FSMC_NAND Bank
  650. * @param __FLAG__ FSMC_NAND flag
  651. * This parameter can be any combination of the following values:
  652. * @arg FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  653. * @arg FSMC_FLAG_LEVEL: Interrupt level edge flag.
  654. * @arg FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  655. * @arg FSMC_FLAG_FEMPT: FIFO empty flag.
  656. * @retval The state of FLAG (SET or RESET).
  657. */
  658. #define __FSMC_NAND_GET_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__BANK__) == FSMC_NAND_BANK2)? (((__INSTANCE__)->SR2 &(__FLAG__)) == (__FLAG__)): \
  659. (((__INSTANCE__)->SR3 &(__FLAG__)) == (__FLAG__)))
  660. /**
  661. * @brief Clear flag status of the NAND device.
  662. * @param __INSTANCE__ FSMC_NAND Instance
  663. * @param __BANK__ FSMC_NAND Bank
  664. * @param __FLAG__ FSMC_NAND flag
  665. * This parameter can be any combination of the following values:
  666. * @arg FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  667. * @arg FSMC_FLAG_LEVEL: Interrupt level edge flag.
  668. * @arg FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  669. * @arg FSMC_FLAG_FEMPT: FIFO empty flag.
  670. * @retval None
  671. */
  672. #define __FSMC_NAND_CLEAR_FLAG(__INSTANCE__, __BANK__, __FLAG__) (((__BANK__) == FSMC_NAND_BANK2)? ((__INSTANCE__)->SR2 &= ~(__FLAG__)): \
  673. ((__INSTANCE__)->SR3 &= ~(__FLAG__)))
  674. /**
  675. * @brief Enable the PCCARD device interrupt.
  676. * @param __INSTANCE__ FSMC_PCCARD Instance
  677. * @param __INTERRUPT__ FSMC_PCCARD interrupt
  678. * This parameter can be any combination of the following values:
  679. * @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
  680. * @arg FSMC_IT_LEVEL: Interrupt level.
  681. * @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.
  682. * @retval None
  683. */
  684. #define __FSMC_PCCARD_ENABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR4 |= (__INTERRUPT__))
  685. /**
  686. * @brief Disable the PCCARD device interrupt.
  687. * @param __INSTANCE__ FSMC_PCCARD Instance
  688. * @param __INTERRUPT__ FSMC_PCCARD interrupt
  689. * This parameter can be any combination of the following values:
  690. * @arg FSMC_IT_RISING_EDGE: Interrupt rising edge.
  691. * @arg FSMC_IT_LEVEL: Interrupt level.
  692. * @arg FSMC_IT_FALLING_EDGE: Interrupt falling edge.
  693. * @retval None
  694. */
  695. #define __FSMC_PCCARD_DISABLE_IT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->SR4 &= ~(__INTERRUPT__))
  696. /**
  697. * @brief Get flag status of the PCCARD device.
  698. * @param __INSTANCE__ FSMC_PCCARD Instance
  699. * @param __FLAG__ FSMC_PCCARD flag
  700. * This parameter can be any combination of the following values:
  701. * @arg FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  702. * @arg FSMC_FLAG_LEVEL: Interrupt level edge flag.
  703. * @arg FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  704. * @arg FSMC_FLAG_FEMPT: FIFO empty flag.
  705. * @retval The state of FLAG (SET or RESET).
  706. */
  707. #define __FSMC_PCCARD_GET_FLAG(__INSTANCE__, __FLAG__) (((__INSTANCE__)->SR4 &(__FLAG__)) == (__FLAG__))
  708. /**
  709. * @brief Clear flag status of the PCCARD device.
  710. * @param __INSTANCE__ FSMC_PCCARD Instance
  711. * @param __FLAG__ FSMC_PCCARD flag
  712. * This parameter can be any combination of the following values:
  713. * @arg FSMC_FLAG_RISING_EDGE: Interrupt rising edge flag.
  714. * @arg FSMC_FLAG_LEVEL: Interrupt level edge flag.
  715. * @arg FSMC_FLAG_FALLING_EDGE: Interrupt falling edge flag.
  716. * @arg FSMC_FLAG_FEMPT: FIFO empty flag.
  717. * @retval None
  718. */
  719. #define __FSMC_PCCARD_CLEAR_FLAG(__INSTANCE__, __FLAG__) ((__INSTANCE__)->SR4 &= ~(__FLAG__))
  720. /**
  721. * @}
  722. */
  723. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  724. /** @defgroup FSMC_LL_Assert_Macros FSMC Assert Macros
  725. * @{
  726. */
  727. #define IS_FSMC_NORSRAM_BANK(__BANK__) (((__BANK__) == FSMC_NORSRAM_BANK1) || \
  728. ((__BANK__) == FSMC_NORSRAM_BANK2) || \
  729. ((__BANK__) == FSMC_NORSRAM_BANK3) || \
  730. ((__BANK__) == FSMC_NORSRAM_BANK4))
  731. #define IS_FSMC_MUX(__MUX__) (((__MUX__) == FSMC_DATA_ADDRESS_MUX_DISABLE) || \
  732. ((__MUX__) == FSMC_DATA_ADDRESS_MUX_ENABLE))
  733. #define IS_FSMC_MEMORY(__MEMORY__) (((__MEMORY__) == FSMC_MEMORY_TYPE_SRAM) || \
  734. ((__MEMORY__) == FSMC_MEMORY_TYPE_PSRAM)|| \
  735. ((__MEMORY__) == FSMC_MEMORY_TYPE_NOR))
  736. #define IS_FSMC_NORSRAM_MEMORY_WIDTH(__WIDTH__) (((__WIDTH__) == FSMC_NORSRAM_MEM_BUS_WIDTH_8) || \
  737. ((__WIDTH__) == FSMC_NORSRAM_MEM_BUS_WIDTH_16) || \
  738. ((__WIDTH__) == FSMC_NORSRAM_MEM_BUS_WIDTH_32))
  739. #define IS_FSMC_ACCESS_MODE(__MODE__) (((__MODE__) == FSMC_ACCESS_MODE_A) || \
  740. ((__MODE__) == FSMC_ACCESS_MODE_B) || \
  741. ((__MODE__) == FSMC_ACCESS_MODE_C) || \
  742. ((__MODE__) == FSMC_ACCESS_MODE_D))
  743. #define IS_FSMC_NAND_BANK(BANK) (((BANK) == FSMC_NAND_BANK2) || \
  744. ((BANK) == FSMC_NAND_BANK3))
  745. #define IS_FSMC_WAIT_FEATURE(FEATURE) (((FEATURE) == FSMC_NAND_PCC_WAIT_FEATURE_DISABLE) || \
  746. ((FEATURE) == FSMC_NAND_PCC_WAIT_FEATURE_ENABLE))
  747. #define IS_FSMC_NAND_MEMORY_WIDTH(WIDTH) (((WIDTH) == FSMC_NAND_PCC_MEM_BUS_WIDTH_8) || \
  748. ((WIDTH) == FSMC_NAND_PCC_MEM_BUS_WIDTH_16))
  749. #define IS_FSMC_ECC_STATE(STATE) (((STATE) == FSMC_NAND_ECC_DISABLE) || \
  750. ((STATE) == FSMC_NAND_ECC_ENABLE))
  751. #define IS_FSMC_ECCPAGE_SIZE(SIZE) (((SIZE) == FSMC_NAND_ECC_PAGE_SIZE_256BYTE) || \
  752. ((SIZE) == FSMC_NAND_ECC_PAGE_SIZE_512BYTE) || \
  753. ((SIZE) == FSMC_NAND_ECC_PAGE_SIZE_1024BYTE) || \
  754. ((SIZE) == FSMC_NAND_ECC_PAGE_SIZE_2048BYTE) || \
  755. ((SIZE) == FSMC_NAND_ECC_PAGE_SIZE_4096BYTE) || \
  756. ((SIZE) == FSMC_NAND_ECC_PAGE_SIZE_8192BYTE))
  757. #define IS_FSMC_TCLR_TIME(TIME) ((TIME) <= 255U)
  758. #define IS_FSMC_TAR_TIME(TIME) ((TIME) <= 255U)
  759. #define IS_FSMC_SETUP_TIME(TIME) ((TIME) <= 255U)
  760. #define IS_FSMC_WAIT_TIME(TIME) ((TIME) <= 255U)
  761. #define IS_FSMC_HOLD_TIME(TIME) ((TIME) <= 255U)
  762. #define IS_FSMC_HIZ_TIME(TIME) ((TIME) <= 255U)
  763. #define IS_FSMC_NORSRAM_DEVICE(__INSTANCE__) ((__INSTANCE__) == FSMC_NORSRAM_DEVICE)
  764. #define IS_FSMC_NORSRAM_EXTENDED_DEVICE(__INSTANCE__) ((__INSTANCE__) == FSMC_NORSRAM_EXTENDED_DEVICE)
  765. #define IS_FSMC_NAND_DEVICE(INSTANCE) ((INSTANCE) == FSMC_NAND_DEVICE)
  766. #define IS_FSMC_PCCARD_DEVICE(INSTANCE) ((INSTANCE) == FSMC_PCCARD_DEVICE)
  767. #define IS_FSMC_BURSTMODE(__STATE__) (((__STATE__) == FSMC_BURST_ACCESS_MODE_DISABLE) || \
  768. ((__STATE__) == FSMC_BURST_ACCESS_MODE_ENABLE))
  769. #define IS_FSMC_WAIT_POLARITY(__POLARITY__) (((__POLARITY__) == FSMC_WAIT_SIGNAL_POLARITY_LOW) || \
  770. ((__POLARITY__) == FSMC_WAIT_SIGNAL_POLARITY_HIGH))
  771. #define IS_FSMC_WRAP_MODE(__MODE__) (((__MODE__) == FSMC_WRAP_MODE_DISABLE) || \
  772. ((__MODE__) == FSMC_WRAP_MODE_ENABLE))
  773. #define IS_FSMC_WAIT_SIGNAL_ACTIVE(__ACTIVE__) (((__ACTIVE__) == FSMC_WAIT_TIMING_BEFORE_WS) || \
  774. ((__ACTIVE__) == FSMC_WAIT_TIMING_DURING_WS))
  775. #define IS_FSMC_WRITE_OPERATION(__OPERATION__) (((__OPERATION__) == FSMC_WRITE_OPERATION_DISABLE) || \
  776. ((__OPERATION__) == FSMC_WRITE_OPERATION_ENABLE))
  777. #define IS_FSMC_WAITE_SIGNAL(__SIGNAL__) (((__SIGNAL__) == FSMC_WAIT_SIGNAL_DISABLE) || \
  778. ((__SIGNAL__) == FSMC_WAIT_SIGNAL_ENABLE))
  779. #define IS_FSMC_EXTENDED_MODE(__MODE__) (((__MODE__) == FSMC_EXTENDED_MODE_DISABLE) || \
  780. ((__MODE__) == FSMC_EXTENDED_MODE_ENABLE))
  781. #define IS_FSMC_ASYNWAIT(__STATE__) (((__STATE__) == FSMC_ASYNCHRONOUS_WAIT_DISABLE) || \
  782. ((__STATE__) == FSMC_ASYNCHRONOUS_WAIT_ENABLE))
  783. #define IS_FSMC_DATA_LATENCY(__LATENCY__) (((__LATENCY__) > 1U) && ((__LATENCY__) <= 17U))
  784. #define IS_FSMC_WRITE_BURST(__BURST__) (((__BURST__) == FSMC_WRITE_BURST_DISABLE) || \
  785. ((__BURST__) == FSMC_WRITE_BURST_ENABLE))
  786. #define IS_FSMC_ADDRESS_SETUP_TIME(__TIME__) ((__TIME__) <= 15U)
  787. #define IS_FSMC_ADDRESS_HOLD_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 15U))
  788. #define IS_FSMC_DATASETUP_TIME(__TIME__) (((__TIME__) > 0U) && ((__TIME__) <= 255U))
  789. #define IS_FSMC_TURNAROUND_TIME(__TIME__) ((__TIME__) <= 15U)
  790. #define IS_FSMC_CONTINOUS_CLOCK(CCLOCK) (((CCLOCK) == FSMC_CONTINUOUS_CLOCK_SYNC_ONLY) || \
  791. ((CCLOCK) == FSMC_CONTINUOUS_CLOCK_SYNC_ASYNC))
  792. #define IS_FSMC_CLK_DIV(DIV) (((DIV) > 1U) && ((DIV) <= 16U))
  793. #define IS_FSMC_PAGESIZE(SIZE) (((SIZE) == FSMC_PAGE_SIZE_NONE) || \
  794. ((SIZE) == FSMC_PAGE_SIZE_128) || \
  795. ((SIZE) == FSMC_PAGE_SIZE_256) || \
  796. ((SIZE) == FSMC_PAGE_SIZE_512) || \
  797. ((SIZE) == FSMC_PAGE_SIZE_1024))
  798. #define IS_FSMC_WRITE_FIFO(FIFO) (((FIFO) == FSMC_WRITE_FIFO_DISABLE) || \
  799. ((FIFO) == FSMC_WRITE_FIFO_ENABLE))
  800. /**
  801. * @}
  802. */
  803. /**
  804. * @}
  805. */
  806. /* Private functions ---------------------------------------------------------*/
  807. /** @defgroup FSMC_LL_Private_Functions FSMC LL Private Functions
  808. * @{
  809. */
  810. /** @defgroup FSMC_LL_NORSRAM NOR SRAM
  811. * @{
  812. */
  813. /** @defgroup FSMC_LL_NORSRAM_Private_Functions_Group1 NOR SRAM Initialization/de-initialization functions
  814. * @{
  815. */
  816. HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef *Init);
  817. HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank);
  818. HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode);
  819. HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank);
  820. /**
  821. * @}
  822. */
  823. /** @defgroup FSMC_LL_NORSRAM_Private_Functions_Group2 NOR SRAM Control functions
  824. * @{
  825. */
  826. HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  827. HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank);
  828. /**
  829. * @}
  830. */
  831. /**
  832. * @}
  833. */
  834. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  835. /** @defgroup FSMC_LL_NAND NAND
  836. * @{
  837. */
  838. /** @defgroup FSMC_LL_NAND_Private_Functions_Group1 NAND Initialization/de-initialization functions
  839. * @{
  840. */
  841. HAL_StatusTypeDef FSMC_NAND_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_InitTypeDef *Init);
  842. HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  843. HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank);
  844. HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank);
  845. /**
  846. * @}
  847. */
  848. /** @defgroup FSMC_LL_NAND_Private_Functions_Group2 NAND Control functions
  849. * @{
  850. */
  851. HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank);
  852. HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank);
  853. HAL_StatusTypeDef FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank, uint32_t Timeout);
  854. /**
  855. * @}
  856. */
  857. /**
  858. * @}
  859. */
  860. /** @defgroup FSMC_LL_PCCARD PCCARD
  861. * @{
  862. */
  863. /** @defgroup FSMC_LL_PCCARD_Private_Functions_Group1 PCCARD Initialization/de-initialization functions
  864. * @{
  865. */
  866. HAL_StatusTypeDef FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init);
  867. HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing);
  868. HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing);
  869. HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing);
  870. HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device);
  871. /**
  872. * @}
  873. */
  874. /**
  875. * @}
  876. */
  877. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  878. /**
  879. * @}
  880. */
  881. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  882. /**
  883. * @}
  884. */
  885. /**
  886. * @}
  887. */
  888. #ifdef __cplusplus
  889. }
  890. #endif
  891. #endif /* __STM32F4xx_LL_FSMC_H */
  892. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/