stm32f1xx_ll_fsmc.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013
  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. */