stm32l4xx_ll_fmc.h 38 KB

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