stm32f1xx_ll_fsmc.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. /**
  2. ******************************************************************************
  3. * @file stm32f1xx_ll_fsmc.c
  4. * @author MCD Application Team
  5. * @brief FSMC Low Layer HAL module driver.
  6. *
  7. * This file provides firmware functions to manage the following
  8. * functionalities of the Flexible Memory Controller (FSMC) peripheral memories:
  9. * + Initialization/de-initialization functions
  10. * + Peripheral Control functions
  11. * + Peripheral State functions
  12. *
  13. ******************************************************************************
  14. * @attention
  15. *
  16. * Copyright (c) 2016 STMicroelectronics.
  17. * All rights reserved.
  18. *
  19. * This software is licensed under terms that can be found in the LICENSE file
  20. * in the root directory of this software component.
  21. * If no LICENSE file comes with this software, it is provided AS-IS.
  22. *
  23. ******************************************************************************
  24. @verbatim
  25. ==============================================================================
  26. ##### FSMC peripheral features #####
  27. ==============================================================================
  28. [..] The Flexible memory controller (FSMC) includes following memory controllers:
  29. (+) The NOR/PSRAM memory controller
  30. (+) The NAND/PC Card memory controller
  31. [..] The FSMC functional block makes the interface with synchronous and asynchronous static
  32. memories and 16-bit PC memory cards. Its main purposes are:
  33. (+) to translate AHB transactions into the appropriate external device protocol
  34. (+) to meet the access time requirements of the external memory devices
  35. [..] All external memories share the addresses, data and control signals with the controller.
  36. Each external device is accessed by means of a unique Chip Select. The FSMC performs
  37. only one access at a time to an external device.
  38. The main features of the FSMC controller are the following:
  39. (+) Interface with static-memory mapped devices including:
  40. (++) Static random access memory (SRAM)
  41. (++) Read-only memory (ROM)
  42. (++) NOR Flash memory/OneNAND Flash memory
  43. (++) PSRAM (4 memory banks)
  44. (++) 16-bit PC Card compatible devices
  45. (++) Two banks of NAND Flash memory with ECC hardware to check up to 8 Kbytes of
  46. data
  47. (+) Independent Chip Select control for each memory bank
  48. (+) Independent configuration for each memory bank
  49. @endverbatim
  50. ******************************************************************************
  51. */
  52. /* Includes ------------------------------------------------------------------*/
  53. #include "stm32f1xx_hal.h"
  54. /** @addtogroup STM32F1xx_HAL_Driver
  55. * @{
  56. */
  57. #if defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED) \
  58. || defined(HAL_SRAM_MODULE_ENABLED)
  59. /** @defgroup FSMC_LL FSMC Low Layer
  60. * @brief FSMC driver modules
  61. * @{
  62. */
  63. /* Private typedef -----------------------------------------------------------*/
  64. /* Private define ------------------------------------------------------------*/
  65. /** @defgroup FSMC_LL_Private_Constants FSMC Low Layer Private Constants
  66. * @{
  67. */
  68. /* ----------------------- FSMC registers bit mask --------------------------- */
  69. #if defined(FSMC_BANK1)
  70. /* --- BCR Register ---*/
  71. /* BCR register clear mask */
  72. /* --- BTR Register ---*/
  73. /* BTR register clear mask */
  74. #define BTR_CLEAR_MASK ((uint32_t)(FSMC_BTRx_ADDSET | FSMC_BTRx_ADDHLD |\
  75. FSMC_BTRx_DATAST | FSMC_BTRx_BUSTURN |\
  76. FSMC_BTRx_CLKDIV | FSMC_BTRx_DATLAT |\
  77. FSMC_BTRx_ACCMOD))
  78. /* --- BWTR Register ---*/
  79. /* BWTR register clear mask */
  80. #if defined(FSMC_BWTRx_BUSTURN)
  81. #define BWTR_CLEAR_MASK ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD |\
  82. FSMC_BWTRx_DATAST | FSMC_BWTRx_BUSTURN |\
  83. FSMC_BWTRx_ACCMOD))
  84. #else
  85. #define BWTR_CLEAR_MASK ((uint32_t)(FSMC_BWTRx_ADDSET | FSMC_BWTRx_ADDHLD |\
  86. FSMC_BWTRx_DATAST | FSMC_BWTRx_ACCMOD |\
  87. FSMC_BWTRx_CLKDIV | FSMC_BWTRx_DATLAT))
  88. #endif /* FSMC_BWTRx_BUSTURN */
  89. #endif /* FSMC_BANK1 */
  90. #if defined(FSMC_BANK3)
  91. /* --- PCR Register ---*/
  92. /* PCR register clear mask */
  93. #define PCR_CLEAR_MASK ((uint32_t)(FSMC_PCRx_PWAITEN | FSMC_PCRx_PBKEN | \
  94. FSMC_PCRx_PTYP | FSMC_PCRx_PWID | \
  95. FSMC_PCRx_ECCEN | FSMC_PCRx_TCLR | \
  96. FSMC_PCRx_TAR | FSMC_PCRx_ECCPS))
  97. /* --- PMEM Register ---*/
  98. /* PMEM register clear mask */
  99. #define PMEM_CLEAR_MASK ((uint32_t)(FSMC_PMEMx_MEMSETx | FSMC_PMEMx_MEMWAITx |\
  100. FSMC_PMEMx_MEMHOLDx | FSMC_PMEMx_MEMHIZx))
  101. /* --- PATT Register ---*/
  102. /* PATT register clear mask */
  103. #define PATT_CLEAR_MASK ((uint32_t)(FSMC_PATTx_ATTSETx | FSMC_PATTx_ATTWAITx |\
  104. FSMC_PATTx_ATTHOLDx | FSMC_PATTx_ATTHIZx))
  105. #endif /* FSMC_BANK3 */
  106. #if defined(FSMC_BANK4)
  107. /* --- PCR Register ---*/
  108. /* PCR register clear mask */
  109. #define PCR4_CLEAR_MASK ((uint32_t)(FSMC_PCR4_PWAITEN | FSMC_PCR4_PBKEN | \
  110. FSMC_PCR4_PTYP | FSMC_PCR4_PWID | \
  111. FSMC_PCR4_ECCEN | FSMC_PCR4_TCLR | \
  112. FSMC_PCR4_TAR | FSMC_PCR4_ECCPS))
  113. /* --- PMEM Register ---*/
  114. /* PMEM register clear mask */
  115. #define PMEM4_CLEAR_MASK ((uint32_t)(FSMC_PMEM4_MEMSET4 | FSMC_PMEM4_MEMWAIT4 |\
  116. FSMC_PMEM4_MEMHOLD4 | FSMC_PMEM4_MEMHIZ4))
  117. /* --- PATT Register ---*/
  118. /* PATT register clear mask */
  119. #define PATT4_CLEAR_MASK ((uint32_t)(FSMC_PATT4_ATTSET4 | FSMC_PATT4_ATTWAIT4 |\
  120. FSMC_PATT4_ATTHOLD4 | FSMC_PATT4_ATTHIZ4))
  121. /* --- PIO4 Register ---*/
  122. /* PIO4 register clear mask */
  123. #define PIO4_CLEAR_MASK ((uint32_t)(FSMC_PIO4_IOSET4 | FSMC_PIO4_IOWAIT4 | \
  124. FSMC_PIO4_IOHOLD4 | FSMC_PIO4_IOHIZ4))
  125. #endif /* FSMC_BANK4 */
  126. /**
  127. * @}
  128. */
  129. /* Private macro -------------------------------------------------------------*/
  130. /* Private variables ---------------------------------------------------------*/
  131. /* Private function prototypes -----------------------------------------------*/
  132. /* Exported functions --------------------------------------------------------*/
  133. /** @defgroup FSMC_LL_Exported_Functions FSMC Low Layer Exported Functions
  134. * @{
  135. */
  136. #if defined(FSMC_BANK1)
  137. /** @defgroup FSMC_LL_Exported_Functions_NORSRAM FSMC Low Layer NOR SRAM Exported Functions
  138. * @brief NORSRAM Controller functions
  139. *
  140. @verbatim
  141. ==============================================================================
  142. ##### How to use NORSRAM device driver #####
  143. ==============================================================================
  144. [..]
  145. This driver contains a set of APIs to interface with the FSMC NORSRAM banks in order
  146. to run the NORSRAM external devices.
  147. (+) FSMC NORSRAM bank reset using the function FSMC_NORSRAM_DeInit()
  148. (+) FSMC NORSRAM bank control configuration using the function FSMC_NORSRAM_Init()
  149. (+) FSMC NORSRAM bank timing configuration using the function FSMC_NORSRAM_Timing_Init()
  150. (+) FSMC NORSRAM bank extended timing configuration using the function
  151. FSMC_NORSRAM_Extended_Timing_Init()
  152. (+) FSMC NORSRAM bank enable/disable write operation using the functions
  153. FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable()
  154. @endverbatim
  155. * @{
  156. */
  157. /** @defgroup FSMC_LL_NORSRAM_Exported_Functions_Group1 Initialization and de-initialization functions
  158. * @brief Initialization and Configuration functions
  159. *
  160. @verbatim
  161. ==============================================================================
  162. ##### Initialization and de_initialization functions #####
  163. ==============================================================================
  164. [..]
  165. This section provides functions allowing to:
  166. (+) Initialize and configure the FSMC NORSRAM interface
  167. (+) De-initialize the FSMC NORSRAM interface
  168. (+) Configure the FSMC clock and associated GPIOs
  169. @endverbatim
  170. * @{
  171. */
  172. /**
  173. * @brief Initialize the FSMC_NORSRAM device according to the specified
  174. * control parameters in the FSMC_NORSRAM_InitTypeDef
  175. * @param Device Pointer to NORSRAM device instance
  176. * @param Init Pointer to NORSRAM Initialization structure
  177. * @retval HAL status
  178. */
  179. HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device,
  180. FSMC_NORSRAM_InitTypeDef *Init)
  181. {
  182. uint32_t flashaccess;
  183. uint32_t btcr_reg;
  184. uint32_t mask;
  185. /* Check the parameters */
  186. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  187. assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank));
  188. assert_param(IS_FSMC_MUX(Init->DataAddressMux));
  189. assert_param(IS_FSMC_MEMORY(Init->MemoryType));
  190. assert_param(IS_FSMC_NORSRAM_MEMORY_WIDTH(Init->MemoryDataWidth));
  191. assert_param(IS_FSMC_BURSTMODE(Init->BurstAccessMode));
  192. assert_param(IS_FSMC_WAIT_POLARITY(Init->WaitSignalPolarity));
  193. assert_param(IS_FSMC_WRAP_MODE(Init->WrapMode));
  194. assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(Init->WaitSignalActive));
  195. assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation));
  196. assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal));
  197. assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode));
  198. assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait));
  199. assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst));
  200. assert_param(IS_FSMC_PAGESIZE(Init->PageSize));
  201. /* Disable NORSRAM Device */
  202. __FSMC_NORSRAM_DISABLE(Device, Init->NSBank);
  203. /* Set NORSRAM device control parameters */
  204. if (Init->MemoryType == FSMC_MEMORY_TYPE_NOR)
  205. {
  206. flashaccess = FSMC_NORSRAM_FLASH_ACCESS_ENABLE;
  207. }
  208. else
  209. {
  210. flashaccess = FSMC_NORSRAM_FLASH_ACCESS_DISABLE;
  211. }
  212. btcr_reg = (flashaccess | \
  213. Init->DataAddressMux | \
  214. Init->MemoryType | \
  215. Init->MemoryDataWidth | \
  216. Init->BurstAccessMode | \
  217. Init->WaitSignalPolarity | \
  218. Init->WaitSignalActive | \
  219. Init->WriteOperation | \
  220. Init->WaitSignal | \
  221. Init->ExtendedMode | \
  222. Init->AsynchronousWait | \
  223. Init->WriteBurst);
  224. btcr_reg |= Init->WrapMode;
  225. btcr_reg |= Init->PageSize;
  226. mask = (FSMC_BCRx_MBKEN |
  227. FSMC_BCRx_MUXEN |
  228. FSMC_BCRx_MTYP |
  229. FSMC_BCRx_MWID |
  230. FSMC_BCRx_FACCEN |
  231. FSMC_BCRx_BURSTEN |
  232. FSMC_BCRx_WAITPOL |
  233. FSMC_BCRx_WAITCFG |
  234. FSMC_BCRx_WREN |
  235. FSMC_BCRx_WAITEN |
  236. FSMC_BCRx_EXTMOD |
  237. FSMC_BCRx_ASYNCWAIT |
  238. FSMC_BCRx_CBURSTRW);
  239. mask |= FSMC_BCRx_WRAPMOD;
  240. mask |= 0x00070000U; /* CPSIZE to be defined in CMSIS file */
  241. MODIFY_REG(Device->BTCR[Init->NSBank], mask, btcr_reg);
  242. return HAL_OK;
  243. }
  244. /**
  245. * @brief DeInitialize the FSMC_NORSRAM peripheral
  246. * @param Device Pointer to NORSRAM device instance
  247. * @param ExDevice Pointer to NORSRAM extended mode device instance
  248. * @param Bank NORSRAM bank number
  249. * @retval HAL status
  250. */
  251. HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device,
  252. FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
  253. {
  254. /* Check the parameters */
  255. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  256. assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice));
  257. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  258. /* Disable the FSMC_NORSRAM device */
  259. __FSMC_NORSRAM_DISABLE(Device, Bank);
  260. /* De-initialize the FSMC_NORSRAM device */
  261. /* FSMC_NORSRAM_BANK1 */
  262. if (Bank == FSMC_NORSRAM_BANK1)
  263. {
  264. Device->BTCR[Bank] = 0x000030DBU;
  265. }
  266. /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */
  267. else
  268. {
  269. Device->BTCR[Bank] = 0x000030D2U;
  270. }
  271. Device->BTCR[Bank + 1U] = 0x0FFFFFFFU;
  272. ExDevice->BWTR[Bank] = 0x0FFFFFFFU;
  273. return HAL_OK;
  274. }
  275. /**
  276. * @brief Initialize the FSMC_NORSRAM Timing according to the specified
  277. * parameters in the FSMC_NORSRAM_TimingTypeDef
  278. * @param Device Pointer to NORSRAM device instance
  279. * @param Timing Pointer to NORSRAM Timing structure
  280. * @param Bank NORSRAM bank number
  281. * @retval HAL status
  282. */
  283. HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device,
  284. FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank)
  285. {
  286. /* Check the parameters */
  287. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  288. assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
  289. assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
  290. assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
  291. assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
  292. assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
  293. assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
  294. assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
  295. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  296. /* Set FSMC_NORSRAM device timing parameters */
  297. MODIFY_REG(Device->BTCR[Bank + 1U], BTR_CLEAR_MASK, (Timing->AddressSetupTime |
  298. ((Timing->AddressHoldTime) << FSMC_BTRx_ADDHLD_Pos) |
  299. ((Timing->DataSetupTime) << FSMC_BTRx_DATAST_Pos) |
  300. ((Timing->BusTurnAroundDuration) << FSMC_BTRx_BUSTURN_Pos) |
  301. (((Timing->CLKDivision) - 1U) << FSMC_BTRx_CLKDIV_Pos) |
  302. (((Timing->DataLatency) - 2U) << FSMC_BTRx_DATLAT_Pos) |
  303. (Timing->AccessMode)));
  304. return HAL_OK;
  305. }
  306. /**
  307. * @brief Initialize the FSMC_NORSRAM Extended mode Timing according to the specified
  308. * parameters in the FSMC_NORSRAM_TimingTypeDef
  309. * @param Device Pointer to NORSRAM device instance
  310. * @param Timing Pointer to NORSRAM Timing structure
  311. * @param Bank NORSRAM bank number
  312. * @param ExtendedMode FSMC Extended Mode
  313. * This parameter can be one of the following values:
  314. * @arg FSMC_EXTENDED_MODE_DISABLE
  315. * @arg FSMC_EXTENDED_MODE_ENABLE
  316. * @retval HAL status
  317. */
  318. HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device,
  319. FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank,
  320. uint32_t ExtendedMode)
  321. {
  322. /* Check the parameters */
  323. assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode));
  324. /* Set NORSRAM device timing register for write configuration, if extended mode is used */
  325. if (ExtendedMode == FSMC_EXTENDED_MODE_ENABLE)
  326. {
  327. /* Check the parameters */
  328. assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(Device));
  329. assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
  330. assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
  331. assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
  332. #if defined(FSMC_BWTRx_BUSTURN)
  333. assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
  334. #else
  335. assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
  336. assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
  337. #endif /* FSMC_BWTRx_BUSTURN */
  338. assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
  339. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  340. /* Set NORSRAM device timing register for write configuration, if extended mode is used */
  341. #if defined(FSMC_BWTRx_BUSTURN)
  342. MODIFY_REG(Device->BWTR[Bank], BWTR_CLEAR_MASK, (Timing->AddressSetupTime |
  343. ((Timing->AddressHoldTime) << FSMC_BWTRx_ADDHLD_Pos) |
  344. ((Timing->DataSetupTime) << FSMC_BWTRx_DATAST_Pos) |
  345. Timing->AccessMode |
  346. ((Timing->BusTurnAroundDuration) << FSMC_BWTRx_BUSTURN_Pos)));
  347. #else
  348. MODIFY_REG(Device->BWTR[Bank], BWTR_CLEAR_MASK, (Timing->AddressSetupTime |
  349. ((Timing->AddressHoldTime) << FSMC_BWTRx_ADDHLD_Pos) |
  350. ((Timing->DataSetupTime) << FSMC_BWTRx_DATAST_Pos) |
  351. Timing->AccessMode |
  352. (((Timing->CLKDivision) - 1U) << FSMC_BWTRx_CLKDIV_Pos) |
  353. (((Timing->DataLatency) - 2U) << FSMC_BWTRx_DATLAT_Pos)));
  354. #endif /* FSMC_BWTRx_BUSTURN */
  355. }
  356. else
  357. {
  358. Device->BWTR[Bank] = 0x0FFFFFFFU;
  359. }
  360. return HAL_OK;
  361. }
  362. /**
  363. * @}
  364. */
  365. /** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group2
  366. * @brief management functions
  367. *
  368. @verbatim
  369. ==============================================================================
  370. ##### FSMC_NORSRAM Control functions #####
  371. ==============================================================================
  372. [..]
  373. This subsection provides a set of functions allowing to control dynamically
  374. the FSMC NORSRAM interface.
  375. @endverbatim
  376. * @{
  377. */
  378. /**
  379. * @brief Enables dynamically FSMC_NORSRAM write operation.
  380. * @param Device Pointer to NORSRAM device instance
  381. * @param Bank NORSRAM bank number
  382. * @retval HAL status
  383. */
  384. HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
  385. {
  386. /* Check the parameters */
  387. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  388. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  389. /* Enable write operation */
  390. SET_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE);
  391. return HAL_OK;
  392. }
  393. /**
  394. * @brief Disables dynamically FSMC_NORSRAM write operation.
  395. * @param Device Pointer to NORSRAM device instance
  396. * @param Bank NORSRAM bank number
  397. * @retval HAL status
  398. */
  399. HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
  400. {
  401. /* Check the parameters */
  402. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  403. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  404. /* Disable write operation */
  405. CLEAR_BIT(Device->BTCR[Bank], FSMC_WRITE_OPERATION_ENABLE);
  406. return HAL_OK;
  407. }
  408. /**
  409. * @}
  410. */
  411. /**
  412. * @}
  413. */
  414. #endif /* FSMC_BANK1 */
  415. #if defined(FSMC_BANK3)
  416. /** @defgroup FSMC_LL_Exported_Functions_NAND FSMC Low Layer NAND Exported Functions
  417. * @brief NAND Controller functions
  418. *
  419. @verbatim
  420. ==============================================================================
  421. ##### How to use NAND device driver #####
  422. ==============================================================================
  423. [..]
  424. This driver contains a set of APIs to interface with the FSMC NAND banks in order
  425. to run the NAND external devices.
  426. (+) FSMC NAND bank reset using the function FSMC_NAND_DeInit()
  427. (+) FSMC NAND bank control configuration using the function FSMC_NAND_Init()
  428. (+) FSMC NAND bank common space timing configuration using the function
  429. FSMC_NAND_CommonSpace_Timing_Init()
  430. (+) FSMC NAND bank attribute space timing configuration using the function
  431. FSMC_NAND_AttributeSpace_Timing_Init()
  432. (+) FSMC NAND bank enable/disable ECC correction feature using the functions
  433. FSMC_NAND_ECC_Enable()/FSMC_NAND_ECC_Disable()
  434. (+) FSMC NAND bank get ECC correction code using the function FSMC_NAND_GetECC()
  435. @endverbatim
  436. * @{
  437. */
  438. /** @defgroup FSMC_LL_NAND_Exported_Functions_Group1 Initialization and de-initialization functions
  439. * @brief Initialization and Configuration functions
  440. *
  441. @verbatim
  442. ==============================================================================
  443. ##### Initialization and de_initialization functions #####
  444. ==============================================================================
  445. [..]
  446. This section provides functions allowing to:
  447. (+) Initialize and configure the FSMC NAND interface
  448. (+) De-initialize the FSMC NAND interface
  449. (+) Configure the FSMC clock and associated GPIOs
  450. @endverbatim
  451. * @{
  452. */
  453. /**
  454. * @brief Initializes the FSMC_NAND device according to the specified
  455. * control parameters in the FSMC_NAND_HandleTypeDef
  456. * @param Device Pointer to NAND device instance
  457. * @param Init Pointer to NAND Initialization structure
  458. * @retval HAL status
  459. */
  460. HAL_StatusTypeDef FSMC_NAND_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_InitTypeDef *Init)
  461. {
  462. /* Check the parameters */
  463. assert_param(IS_FSMC_NAND_DEVICE(Device));
  464. assert_param(IS_FSMC_NAND_BANK(Init->NandBank));
  465. assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
  466. assert_param(IS_FSMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth));
  467. assert_param(IS_FSMC_ECC_STATE(Init->EccComputation));
  468. assert_param(IS_FSMC_ECCPAGE_SIZE(Init->ECCPageSize));
  469. assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
  470. assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
  471. /* Set NAND device control parameters */
  472. if (Init->NandBank == FSMC_NAND_BANK2)
  473. {
  474. /* NAND bank 2 registers configuration */
  475. MODIFY_REG(Device->PCR2, PCR_CLEAR_MASK, (Init->Waitfeature |
  476. FSMC_PCR_MEMORY_TYPE_NAND |
  477. Init->MemoryDataWidth |
  478. Init->EccComputation |
  479. Init->ECCPageSize |
  480. ((Init->TCLRSetupTime) << FSMC_PCRx_TCLR_Pos) |
  481. ((Init->TARSetupTime) << FSMC_PCRx_TAR_Pos)));
  482. }
  483. else
  484. {
  485. /* NAND bank 3 registers configuration */
  486. MODIFY_REG(Device->PCR3, PCR_CLEAR_MASK, (Init->Waitfeature |
  487. FSMC_PCR_MEMORY_TYPE_NAND |
  488. Init->MemoryDataWidth |
  489. Init->EccComputation |
  490. Init->ECCPageSize |
  491. ((Init->TCLRSetupTime) << FSMC_PCRx_TCLR_Pos) |
  492. ((Init->TARSetupTime) << FSMC_PCRx_TAR_Pos)));
  493. }
  494. return HAL_OK;
  495. }
  496. /**
  497. * @brief Initializes the FSMC_NAND Common space Timing according to the specified
  498. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  499. * @param Device Pointer to NAND device instance
  500. * @param Timing Pointer to NAND timing structure
  501. * @param Bank NAND bank number
  502. * @retval HAL status
  503. */
  504. HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device,
  505. FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
  506. {
  507. /* Check the parameters */
  508. assert_param(IS_FSMC_NAND_DEVICE(Device));
  509. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  510. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  511. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  512. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  513. assert_param(IS_FSMC_NAND_BANK(Bank));
  514. /* Set FSMC_NAND device timing parameters */
  515. if (Bank == FSMC_NAND_BANK2)
  516. {
  517. /* NAND bank 2 registers configuration */
  518. MODIFY_REG(Device->PMEM2, PMEM_CLEAR_MASK, (Timing->SetupTime |
  519. ((Timing->WaitSetupTime) << FSMC_PMEMx_MEMWAITx_Pos) |
  520. ((Timing->HoldSetupTime) << FSMC_PMEMx_MEMHOLDx_Pos) |
  521. ((Timing->HiZSetupTime) << FSMC_PMEMx_MEMHIZx_Pos)));
  522. }
  523. else
  524. {
  525. /* NAND bank 3 registers configuration */
  526. MODIFY_REG(Device->PMEM3, PMEM_CLEAR_MASK, (Timing->SetupTime |
  527. ((Timing->WaitSetupTime) << FSMC_PMEMx_MEMWAITx_Pos) |
  528. ((Timing->HoldSetupTime) << FSMC_PMEMx_MEMHOLDx_Pos) |
  529. ((Timing->HiZSetupTime) << FSMC_PMEMx_MEMHIZx_Pos)));
  530. }
  531. return HAL_OK;
  532. }
  533. /**
  534. * @brief Initializes the FSMC_NAND Attribute space Timing according to the specified
  535. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  536. * @param Device Pointer to NAND device instance
  537. * @param Timing Pointer to NAND timing structure
  538. * @param Bank NAND bank number
  539. * @retval HAL status
  540. */
  541. HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device,
  542. FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
  543. {
  544. /* Check the parameters */
  545. assert_param(IS_FSMC_NAND_DEVICE(Device));
  546. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  547. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  548. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  549. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  550. assert_param(IS_FSMC_NAND_BANK(Bank));
  551. /* Set FSMC_NAND device timing parameters */
  552. if (Bank == FSMC_NAND_BANK2)
  553. {
  554. /* NAND bank 2 registers configuration */
  555. MODIFY_REG(Device->PATT2, PATT_CLEAR_MASK, (Timing->SetupTime |
  556. ((Timing->WaitSetupTime) << FSMC_PATTx_ATTWAITx_Pos) |
  557. ((Timing->HoldSetupTime) << FSMC_PATTx_ATTHOLDx_Pos) |
  558. ((Timing->HiZSetupTime) << FSMC_PATTx_ATTHIZx_Pos)));
  559. }
  560. else
  561. {
  562. /* NAND bank 3 registers configuration */
  563. MODIFY_REG(Device->PATT3, PATT_CLEAR_MASK, (Timing->SetupTime |
  564. ((Timing->WaitSetupTime) << FSMC_PATTx_ATTWAITx_Pos) |
  565. ((Timing->HoldSetupTime) << FSMC_PATTx_ATTHOLDx_Pos) |
  566. ((Timing->HiZSetupTime) << FSMC_PATTx_ATTHIZx_Pos)));
  567. }
  568. return HAL_OK;
  569. }
  570. /**
  571. * @brief DeInitializes the FSMC_NAND device
  572. * @param Device Pointer to NAND device instance
  573. * @param Bank NAND bank number
  574. * @retval HAL status
  575. */
  576. HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank)
  577. {
  578. /* Check the parameters */
  579. assert_param(IS_FSMC_NAND_DEVICE(Device));
  580. assert_param(IS_FSMC_NAND_BANK(Bank));
  581. /* Disable the NAND Bank */
  582. __FSMC_NAND_DISABLE(Device, Bank);
  583. /* De-initialize the NAND Bank */
  584. if (Bank == FSMC_NAND_BANK2)
  585. {
  586. /* Set the FSMC_NAND_BANK2 registers to their reset values */
  587. WRITE_REG(Device->PCR2, 0x00000018U);
  588. WRITE_REG(Device->SR2, 0x00000040U);
  589. WRITE_REG(Device->PMEM2, 0xFCFCFCFCU);
  590. WRITE_REG(Device->PATT2, 0xFCFCFCFCU);
  591. }
  592. /* FSMC_Bank3_NAND */
  593. else
  594. {
  595. /* Set the FSMC_NAND_BANK3 registers to their reset values */
  596. WRITE_REG(Device->PCR3, 0x00000018U);
  597. WRITE_REG(Device->SR3, 0x00000040U);
  598. WRITE_REG(Device->PMEM3, 0xFCFCFCFCU);
  599. WRITE_REG(Device->PATT3, 0xFCFCFCFCU);
  600. }
  601. return HAL_OK;
  602. }
  603. /**
  604. * @}
  605. */
  606. /** @defgroup HAL_FSMC_NAND_Group2 Peripheral Control functions
  607. * @brief management functions
  608. *
  609. @verbatim
  610. ==============================================================================
  611. ##### FSMC_NAND Control functions #####
  612. ==============================================================================
  613. [..]
  614. This subsection provides a set of functions allowing to control dynamically
  615. the FSMC NAND interface.
  616. @endverbatim
  617. * @{
  618. */
  619. /**
  620. * @brief Enables dynamically FSMC_NAND ECC feature.
  621. * @param Device Pointer to NAND device instance
  622. * @param Bank NAND bank number
  623. * @retval HAL status
  624. */
  625. HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
  626. {
  627. /* Check the parameters */
  628. assert_param(IS_FSMC_NAND_DEVICE(Device));
  629. assert_param(IS_FSMC_NAND_BANK(Bank));
  630. /* Enable ECC feature */
  631. if (Bank == FSMC_NAND_BANK2)
  632. {
  633. SET_BIT(Device->PCR2, FSMC_PCRx_ECCEN);
  634. }
  635. else
  636. {
  637. SET_BIT(Device->PCR3, FSMC_PCRx_ECCEN);
  638. }
  639. return HAL_OK;
  640. }
  641. /**
  642. * @brief Disables dynamically FSMC_NAND ECC feature.
  643. * @param Device Pointer to NAND device instance
  644. * @param Bank NAND bank number
  645. * @retval HAL status
  646. */
  647. HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
  648. {
  649. /* Check the parameters */
  650. assert_param(IS_FSMC_NAND_DEVICE(Device));
  651. assert_param(IS_FSMC_NAND_BANK(Bank));
  652. /* Disable ECC feature */
  653. if (Bank == FSMC_NAND_BANK2)
  654. {
  655. CLEAR_BIT(Device->PCR2, FSMC_PCRx_ECCEN);
  656. }
  657. else
  658. {
  659. CLEAR_BIT(Device->PCR3, FSMC_PCRx_ECCEN);
  660. }
  661. return HAL_OK;
  662. }
  663. /**
  664. * @brief Disables dynamically FSMC_NAND ECC feature.
  665. * @param Device Pointer to NAND device instance
  666. * @param ECCval Pointer to ECC value
  667. * @param Bank NAND bank number
  668. * @param Timeout Timeout wait value
  669. * @retval HAL status
  670. */
  671. HAL_StatusTypeDef FSMC_NAND_GetECC(FSMC_NAND_TypeDef *Device, uint32_t *ECCval, uint32_t Bank,
  672. uint32_t Timeout)
  673. {
  674. uint32_t tickstart;
  675. /* Check the parameters */
  676. assert_param(IS_FSMC_NAND_DEVICE(Device));
  677. assert_param(IS_FSMC_NAND_BANK(Bank));
  678. /* Get tick */
  679. tickstart = HAL_GetTick();
  680. /* Wait until FIFO is empty */
  681. while (__FSMC_NAND_GET_FLAG(Device, Bank, FSMC_FLAG_FEMPT) == RESET)
  682. {
  683. /* Check for the Timeout */
  684. if (Timeout != HAL_MAX_DELAY)
  685. {
  686. if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
  687. {
  688. return HAL_TIMEOUT;
  689. }
  690. }
  691. }
  692. if (Bank == FSMC_NAND_BANK2)
  693. {
  694. /* Get the ECCR2 register value */
  695. *ECCval = (uint32_t)Device->ECCR2;
  696. }
  697. else
  698. {
  699. /* Get the ECCR3 register value */
  700. *ECCval = (uint32_t)Device->ECCR3;
  701. }
  702. return HAL_OK;
  703. }
  704. /**
  705. * @}
  706. */
  707. #endif /* FSMC_BANK3 */
  708. #if defined(FSMC_BANK4)
  709. /** @addtogroup FSMC_LL_PCCARD
  710. * @brief PCCARD Controller functions
  711. *
  712. @verbatim
  713. ==============================================================================
  714. ##### How to use PCCARD device driver #####
  715. ==============================================================================
  716. [..]
  717. This driver contains a set of APIs to interface with the FSMC PCCARD bank in order
  718. to run the PCCARD/compact flash external devices.
  719. (+) FSMC PCCARD bank reset using the function FSMC_PCCARD_DeInit()
  720. (+) FSMC PCCARD bank control configuration using the function FSMC_PCCARD_Init()
  721. (+) FSMC PCCARD bank common space timing configuration using the function
  722. FSMC_PCCARD_CommonSpace_Timing_Init()
  723. (+) FSMC PCCARD bank attribute space timing configuration using the function
  724. FSMC_PCCARD_AttributeSpace_Timing_Init()
  725. (+) FSMC PCCARD bank IO space timing configuration using the function
  726. FSMC_PCCARD_IOSpace_Timing_Init()
  727. @endverbatim
  728. * @{
  729. */
  730. /** @addtogroup FSMC_LL_PCCARD_Private_Functions_Group1
  731. * @brief Initialization and Configuration functions
  732. *
  733. @verbatim
  734. ==============================================================================
  735. ##### Initialization and de_initialization functions #####
  736. ==============================================================================
  737. [..]
  738. This section provides functions allowing to:
  739. (+) Initialize and configure the FSMC PCCARD interface
  740. (+) De-initialize the FSMC PCCARD interface
  741. (+) Configure the FSMC clock and associated GPIOs
  742. @endverbatim
  743. * @{
  744. */
  745. /**
  746. * @brief Initializes the FSMC_PCCARD device according to the specified
  747. * control parameters in the FSMC_PCCARD_HandleTypeDef
  748. * @param Device Pointer to PCCARD device instance
  749. * @param Init Pointer to PCCARD Initialization structure
  750. * @retval HAL status
  751. */
  752. HAL_StatusTypeDef FSMC_PCCARD_Init(FSMC_PCCARD_TypeDef *Device, FSMC_PCCARD_InitTypeDef *Init)
  753. {
  754. /* Check the parameters */
  755. assert_param(IS_FSMC_PCCARD_DEVICE(Device));
  756. #if defined(FSMC_BANK3)
  757. assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
  758. assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
  759. assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
  760. #endif /* FSMC_BANK3 */
  761. /* Set FSMC_PCCARD device control parameters */
  762. MODIFY_REG(Device->PCR4,
  763. (FSMC_PCRx_PTYP |
  764. FSMC_PCRx_PWAITEN |
  765. FSMC_PCRx_PWID |
  766. FSMC_PCRx_TCLR |
  767. FSMC_PCRx_TAR),
  768. (FSMC_PCR_MEMORY_TYPE_PCCARD |
  769. Init->Waitfeature |
  770. FSMC_NAND_PCC_MEM_BUS_WIDTH_16 |
  771. (Init->TCLRSetupTime << FSMC_PCRx_TCLR_Pos) |
  772. (Init->TARSetupTime << FSMC_PCRx_TAR_Pos)));
  773. return HAL_OK;
  774. }
  775. /**
  776. * @brief Initializes the FSMC_PCCARD Common space Timing according to the specified
  777. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  778. * @param Device Pointer to PCCARD device instance
  779. * @param Timing Pointer to PCCARD timing structure
  780. * @retval HAL status
  781. */
  782. HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device,
  783. FSMC_NAND_PCC_TimingTypeDef *Timing)
  784. {
  785. /* Check the parameters */
  786. assert_param(IS_FSMC_PCCARD_DEVICE(Device));
  787. #if defined(FSMC_BANK3)
  788. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  789. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  790. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  791. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  792. #endif /* FSMC_BANK3 */
  793. /* Set PCCARD timing parameters */
  794. MODIFY_REG(Device->PMEM4, PMEM_CLEAR_MASK,
  795. (Timing->SetupTime |
  796. ((Timing->WaitSetupTime) << FSMC_PMEMx_MEMWAITx_Pos) |
  797. ((Timing->HoldSetupTime) << FSMC_PMEMx_MEMHOLDx_Pos) |
  798. ((Timing->HiZSetupTime) << FSMC_PMEMx_MEMHIZx_Pos)));
  799. return HAL_OK;
  800. }
  801. /**
  802. * @brief Initializes the FSMC_PCCARD Attribute space Timing according to the specified
  803. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  804. * @param Device Pointer to PCCARD device instance
  805. * @param Timing Pointer to PCCARD timing structure
  806. * @retval HAL status
  807. */
  808. HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device,
  809. FSMC_NAND_PCC_TimingTypeDef *Timing)
  810. {
  811. /* Check the parameters */
  812. assert_param(IS_FSMC_PCCARD_DEVICE(Device));
  813. #if defined(FSMC_BANK3)
  814. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  815. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  816. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  817. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  818. #endif /* FSMC_BANK3 */
  819. /* Set PCCARD timing parameters */
  820. MODIFY_REG(Device->PATT4, PATT_CLEAR_MASK,
  821. (Timing->SetupTime |
  822. ((Timing->WaitSetupTime) << FSMC_PATTx_ATTWAITx_Pos) |
  823. ((Timing->HoldSetupTime) << FSMC_PATTx_ATTHOLDx_Pos) |
  824. ((Timing->HiZSetupTime) << FSMC_PATTx_ATTHIZx_Pos)));
  825. return HAL_OK;
  826. }
  827. /**
  828. * @brief Initializes the FSMC_PCCARD IO space Timing according to the specified
  829. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  830. * @param Device Pointer to PCCARD device instance
  831. * @param Timing Pointer to PCCARD timing structure
  832. * @retval HAL status
  833. */
  834. HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device,
  835. FSMC_NAND_PCC_TimingTypeDef *Timing)
  836. {
  837. /* Check the parameters */
  838. assert_param(IS_FSMC_PCCARD_DEVICE(Device));
  839. #if defined(FSMC_BANK3)
  840. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  841. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  842. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  843. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  844. #endif /* FSMC_BANK3 */
  845. /* Set FSMC_PCCARD device timing parameters */
  846. MODIFY_REG(Device->PIO4, PIO4_CLEAR_MASK,
  847. (Timing->SetupTime |
  848. (Timing->WaitSetupTime << FSMC_PIO4_IOWAIT4_Pos) |
  849. (Timing->HoldSetupTime << FSMC_PIO4_IOHOLD4_Pos) |
  850. (Timing->HiZSetupTime << FSMC_PIO4_IOHIZ4_Pos)));
  851. return HAL_OK;
  852. }
  853. /**
  854. * @brief DeInitializes the FSMC_PCCARD device
  855. * @param Device Pointer to PCCARD device instance
  856. * @retval HAL status
  857. */
  858. HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device)
  859. {
  860. /* Check the parameters */
  861. assert_param(IS_FSMC_PCCARD_DEVICE(Device));
  862. /* Disable the FSMC_PCCARD device */
  863. __FSMC_PCCARD_DISABLE(Device);
  864. /* De-initialize the FSMC_PCCARD device */
  865. Device->PCR4 = 0x00000018U;
  866. Device->SR4 = 0x00000040U;
  867. Device->PMEM4 = 0xFCFCFCFCU;
  868. Device->PATT4 = 0xFCFCFCFCU;
  869. Device->PIO4 = 0xFCFCFCFCU;
  870. return HAL_OK;
  871. }
  872. /**
  873. * @}
  874. */
  875. #endif /* FSMC_BANK4 */
  876. /**
  877. * @}
  878. */
  879. /**
  880. * @}
  881. */
  882. #endif /* HAL_NOR_MODULE_ENABLED */
  883. /**
  884. * @}
  885. */
  886. /**
  887. * @}
  888. */