stm32f4xx_ll_fsmc.c 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_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 Static Memory Controller (FSMC) peripheral memories:
  9. * + Initialization/de-initialization functions
  10. * + Peripheral Control functions
  11. * + Peripheral State functions
  12. *
  13. @verbatim
  14. ==============================================================================
  15. ##### FSMC peripheral features #####
  16. ==============================================================================
  17. [..] The Flexible static memory controller (FSMC) includes two memory controllers:
  18. (+) The NOR/PSRAM memory controller
  19. (+) The NAND/PC Card memory controller
  20. [..] The FSMC functional block makes the interface with synchronous and asynchronous static
  21. memories, SDRAM memories, and 16-bit PC memory cards. Its main purposes are:
  22. (+) to translate AHB transactions into the appropriate external device protocol.
  23. (+) to meet the access time requirements of the external memory devices.
  24. [..] All external memories share the addresses, data and control signals with the controller.
  25. Each external device is accessed by means of a unique Chip Select. The FSMC performs
  26. only one access at a time to an external device.
  27. The main features of the FSMC controller are the following:
  28. (+) Interface with static-memory mapped devices including:
  29. (++) Static random access memory (SRAM).
  30. (++) Read-only memory (ROM).
  31. (++) NOR Flash memory/OneNAND Flash memory.
  32. (++) PSRAM (4 memory banks).
  33. (++) 16-bit PC Card compatible devices.
  34. (++) Two banks of NAND Flash memory with ECC hardware to check up to 8 Kbytes of
  35. data.
  36. (+) Independent Chip Select control for each memory bank.
  37. (+) Independent configuration for each memory bank.
  38. @endverbatim
  39. ******************************************************************************
  40. * @attention
  41. *
  42. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  43. *
  44. * Redistribution and use in source and binary forms, with or without modification,
  45. * are permitted provided that the following conditions are met:
  46. * 1. Redistributions of source code must retain the above copyright notice,
  47. * this list of conditions and the following disclaimer.
  48. * 2. Redistributions in binary form must reproduce the above copyright notice,
  49. * this list of conditions and the following disclaimer in the documentation
  50. * and/or other materials provided with the distribution.
  51. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  52. * may be used to endorse or promote products derived from this software
  53. * without specific prior written permission.
  54. *
  55. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  56. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  58. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  59. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  61. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  62. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  63. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  64. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  65. *
  66. ******************************************************************************
  67. */
  68. /* Includes ------------------------------------------------------------------*/
  69. #include "stm32f4xx_hal.h"
  70. /** @addtogroup STM32F4xx_HAL_Driver
  71. * @{
  72. */
  73. /** @defgroup FSMC_LL FSMC Low Layer
  74. * @brief FSMC driver modules
  75. * @{
  76. */
  77. #if defined (HAL_SRAM_MODULE_ENABLED) || defined(HAL_NOR_MODULE_ENABLED) || defined(HAL_NAND_MODULE_ENABLED) || defined(HAL_PCCARD_MODULE_ENABLED)
  78. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
  79. defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  80. /* Private typedef -----------------------------------------------------------*/
  81. /* Private define ------------------------------------------------------------*/
  82. /* Private macro -------------------------------------------------------------*/
  83. /* Private variables ---------------------------------------------------------*/
  84. /* Private function prototypes -----------------------------------------------*/
  85. /* Private functions ---------------------------------------------------------*/
  86. /** @addtogroup FSMC_LL_Private_Functions
  87. * @{
  88. */
  89. /** @addtogroup FSMC_LL_NORSRAM
  90. * @brief NORSRAM Controller functions
  91. *
  92. @verbatim
  93. ==============================================================================
  94. ##### How to use NORSRAM device driver #####
  95. ==============================================================================
  96. [..]
  97. This driver contains a set of APIs to interface with the FSMC NORSRAM banks in order
  98. to run the NORSRAM external devices.
  99. (+) FSMC NORSRAM bank reset using the function FSMC_NORSRAM_DeInit()
  100. (+) FSMC NORSRAM bank control configuration using the function FSMC_NORSRAM_Init()
  101. (+) FSMC NORSRAM bank timing configuration using the function FSMC_NORSRAM_Timing_Init()
  102. (+) FSMC NORSRAM bank extended timing configuration using the function
  103. FSMC_NORSRAM_Extended_Timing_Init()
  104. (+) FSMC NORSRAM bank enable/disable write operation using the functions
  105. FSMC_NORSRAM_WriteOperation_Enable()/FSMC_NORSRAM_WriteOperation_Disable()
  106. @endverbatim
  107. * @{
  108. */
  109. /** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group1
  110. * @brief Initialization and Configuration functions
  111. *
  112. @verbatim
  113. ==============================================================================
  114. ##### Initialization and de_initialization functions #####
  115. ==============================================================================
  116. [..]
  117. This section provides functions allowing to:
  118. (+) Initialize and configure the FSMC NORSRAM interface
  119. (+) De-initialize the FSMC NORSRAM interface
  120. (+) Configure the FSMC clock and associated GPIOs
  121. @endverbatim
  122. * @{
  123. */
  124. /**
  125. * @brief Initialize the FSMC_NORSRAM device according to the specified
  126. * control parameters in the FSMC_NORSRAM_InitTypeDef
  127. * @param Device Pointer to NORSRAM device instance
  128. * @param Init Pointer to NORSRAM Initialization structure
  129. * @retval HAL status
  130. */
  131. HAL_StatusTypeDef FSMC_NORSRAM_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_InitTypeDef* Init)
  132. {
  133. uint32_t tmpr = 0U;
  134. /* Check the parameters */
  135. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  136. assert_param(IS_FSMC_NORSRAM_BANK(Init->NSBank));
  137. assert_param(IS_FSMC_MUX(Init->DataAddressMux));
  138. assert_param(IS_FSMC_MEMORY(Init->MemoryType));
  139. assert_param(IS_FSMC_NORSRAM_MEMORY_WIDTH(Init->MemoryDataWidth));
  140. assert_param(IS_FSMC_BURSTMODE(Init->BurstAccessMode));
  141. assert_param(IS_FSMC_WAIT_POLARITY(Init->WaitSignalPolarity));
  142. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  143. assert_param(IS_FSMC_WRAP_MODE(Init->WrapMode));
  144. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  145. assert_param(IS_FSMC_WAIT_SIGNAL_ACTIVE(Init->WaitSignalActive));
  146. assert_param(IS_FSMC_WRITE_OPERATION(Init->WriteOperation));
  147. assert_param(IS_FSMC_WAITE_SIGNAL(Init->WaitSignal));
  148. assert_param(IS_FSMC_EXTENDED_MODE(Init->ExtendedMode));
  149. assert_param(IS_FSMC_ASYNWAIT(Init->AsynchronousWait));
  150. assert_param(IS_FSMC_WRITE_BURST(Init->WriteBurst));
  151. assert_param(IS_FSMC_PAGESIZE(Init->PageSize));
  152. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  153. assert_param(IS_FSMC_WRITE_FIFO(Init->WriteFifo));
  154. assert_param(IS_FSMC_CONTINOUS_CLOCK(Init->ContinuousClock));
  155. #endif /* STM32F412Zx || STM32F412Vx || STM32F413xx || STM32F423xx */
  156. /* Get the BTCR register value */
  157. tmpr = Device->BTCR[Init->NSBank];
  158. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  159. /* Clear MBKEN, MUXEN, MTYP, MWID, FACCEN, BURSTEN, WAITPOL, WRAPMOD, WAITCFG, WREN,
  160. WAITEN, EXTMOD, ASYNCWAIT, CPSIZE and CBURSTRW bits */
  161. tmpr &= ((uint32_t)~(FSMC_BCR1_MBKEN | FSMC_BCR1_MUXEN | FSMC_BCR1_MTYP | \
  162. FSMC_BCR1_MWID | FSMC_BCR1_FACCEN | FSMC_BCR1_BURSTEN | \
  163. FSMC_BCR1_WAITPOL | FSMC_BCR1_WRAPMOD | FSMC_BCR1_WAITCFG | \
  164. FSMC_BCR1_WREN | FSMC_BCR1_WAITEN | FSMC_BCR1_EXTMOD | \
  165. FSMC_BCR1_ASYNCWAIT | FSMC_BCR1_CPSIZE | FSMC_BCR1_CBURSTRW));
  166. /* Set NORSRAM device control parameters */
  167. tmpr |= (uint32_t)(Init->DataAddressMux |\
  168. Init->MemoryType |\
  169. Init->MemoryDataWidth |\
  170. Init->BurstAccessMode |\
  171. Init->WaitSignalPolarity |\
  172. Init->WrapMode |\
  173. Init->WaitSignalActive |\
  174. Init->WriteOperation |\
  175. Init->WaitSignal |\
  176. Init->ExtendedMode |\
  177. Init->AsynchronousWait |\
  178. Init->PageSize |\
  179. Init->WriteBurst
  180. );
  181. #else /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  182. /* Clear MBKEN, MUXEN, MTYP, MWID, FACCEN, BURSTEN, WAITPOL, WAITCFG, WREN,
  183. WAITEN, EXTMOD, ASYNCWAIT,CPSIZE, CBURSTRW, CCLKEN and WFDIS bits */
  184. tmpr &= ((uint32_t)~(FSMC_BCR1_MBKEN | FSMC_BCR1_MUXEN | FSMC_BCR1_MTYP | \
  185. FSMC_BCR1_MWID | FSMC_BCR1_FACCEN | FSMC_BCR1_BURSTEN | \
  186. FSMC_BCR1_WAITPOL | FSMC_BCR1_WAITCFG | FSMC_BCR1_WREN | \
  187. FSMC_BCR1_WAITEN | FSMC_BCR1_EXTMOD | FSMC_BCR1_ASYNCWAIT | \
  188. FSMC_BCR1_CPSIZE | FSMC_BCR1_CBURSTRW | FSMC_BCR1_CCLKEN | \
  189. FSMC_BCR1_WFDIS));
  190. /* Set NORSRAM device control parameters */
  191. tmpr |= (uint32_t)(Init->DataAddressMux |\
  192. Init->MemoryType |\
  193. Init->MemoryDataWidth |\
  194. Init->BurstAccessMode |\
  195. Init->WaitSignalPolarity |\
  196. Init->WaitSignalActive |\
  197. Init->WriteOperation |\
  198. Init->WaitSignal |\
  199. Init->ExtendedMode |\
  200. Init->AsynchronousWait |\
  201. Init->WriteBurst |\
  202. Init->ContinuousClock |\
  203. Init->PageSize |\
  204. Init->WriteFifo);
  205. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  206. if(Init->MemoryType == FSMC_MEMORY_TYPE_NOR)
  207. {
  208. tmpr |= (uint32_t)FSMC_NORSRAM_FLASH_ACCESS_ENABLE;
  209. }
  210. Device->BTCR[Init->NSBank] = tmpr;
  211. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  212. /* Configure synchronous mode when Continuous clock is enabled for bank2..4 */
  213. if((Init->ContinuousClock == FSMC_CONTINUOUS_CLOCK_SYNC_ASYNC) && (Init->NSBank != FSMC_NORSRAM_BANK1))
  214. {
  215. Device->BTCR[FSMC_NORSRAM_BANK1] |= (uint32_t)(Init->ContinuousClock);
  216. }
  217. if(Init->NSBank != FSMC_NORSRAM_BANK1)
  218. {
  219. Device->BTCR[FSMC_NORSRAM_BANK1] |= (uint32_t)(Init->WriteFifo);
  220. }
  221. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  222. return HAL_OK;
  223. }
  224. /**
  225. * @brief DeInitialize the FSMC_NORSRAM peripheral
  226. * @param Device Pointer to NORSRAM device instance
  227. * @param ExDevice Pointer to NORSRAM extended mode device instance
  228. * @param Bank NORSRAM bank number
  229. * @retval HAL status
  230. */
  231. HAL_StatusTypeDef FSMC_NORSRAM_DeInit(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_EXTENDED_TypeDef *ExDevice, uint32_t Bank)
  232. {
  233. /* Check the parameters */
  234. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  235. assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(ExDevice));
  236. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  237. /* Disable the FSMC_NORSRAM device */
  238. __FSMC_NORSRAM_DISABLE(Device, Bank);
  239. /* De-initialize the FSMC_NORSRAM device */
  240. /* FSMC_NORSRAM_BANK1 */
  241. if(Bank == FSMC_NORSRAM_BANK1)
  242. {
  243. Device->BTCR[Bank] = 0x000030DBU;
  244. }
  245. /* FSMC_NORSRAM_BANK2, FSMC_NORSRAM_BANK3 or FSMC_NORSRAM_BANK4 */
  246. else
  247. {
  248. Device->BTCR[Bank] = 0x000030D2U;
  249. }
  250. Device->BTCR[Bank + 1U] = 0x0FFFFFFFU;
  251. ExDevice->BWTR[Bank] = 0x0FFFFFFFU;
  252. return HAL_OK;
  253. }
  254. /**
  255. * @brief Initialize the FSMC_NORSRAM Timing according to the specified
  256. * parameters in the FSMC_NORSRAM_TimingTypeDef
  257. * @param Device Pointer to NORSRAM device instance
  258. * @param Timing Pointer to NORSRAM Timing structure
  259. * @param Bank NORSRAM bank number
  260. * @retval HAL status
  261. */
  262. HAL_StatusTypeDef FSMC_NORSRAM_Timing_Init(FSMC_NORSRAM_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank)
  263. {
  264. uint32_t tmpr = 0U;
  265. /* Check the parameters */
  266. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  267. assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
  268. assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
  269. assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
  270. assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
  271. assert_param(IS_FSMC_CLK_DIV(Timing->CLKDivision));
  272. assert_param(IS_FSMC_DATA_LATENCY(Timing->DataLatency));
  273. assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
  274. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  275. /* Get the BTCR register value */
  276. tmpr = Device->BTCR[Bank + 1U];
  277. /* Clear ADDSET, ADDHLD, DATAST, BUSTURN, CLKDIV, DATLAT and ACCMOD bits */
  278. tmpr &= ((uint32_t)~(FSMC_BTR1_ADDSET | FSMC_BTR1_ADDHLD | FSMC_BTR1_DATAST | \
  279. FSMC_BTR1_BUSTURN | FSMC_BTR1_CLKDIV | FSMC_BTR1_DATLAT | \
  280. FSMC_BTR1_ACCMOD));
  281. /* Set FSMC_NORSRAM device timing parameters */
  282. tmpr |= (uint32_t)(Timing->AddressSetupTime |\
  283. ((Timing->AddressHoldTime) << 4U) |\
  284. ((Timing->DataSetupTime) << 8U) |\
  285. ((Timing->BusTurnAroundDuration) << 16U) |\
  286. (((Timing->CLKDivision)-1U) << 20U) |\
  287. (((Timing->DataLatency)-2U) << 24U) |\
  288. (Timing->AccessMode));
  289. Device->BTCR[Bank + 1] = tmpr;
  290. #if defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F413xx) || defined(STM32F423xx)
  291. /* Configure Clock division value (in NORSRAM bank 1) when continuous clock is enabled */
  292. if(HAL_IS_BIT_SET(Device->BTCR[FSMC_NORSRAM_BANK1], FSMC_BCR1_CCLKEN))
  293. {
  294. tmpr = (uint32_t)(Device->BTCR[FSMC_NORSRAM_BANK1 + 1U] & ~(0x0FU << 20U));
  295. tmpr |= (uint32_t)(((Timing->CLKDivision)-1U) << 20U);
  296. Device->BTCR[FSMC_NORSRAM_BANK1 + 1U] = tmpr;
  297. }
  298. #endif /* STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F413xx || STM32F423xx */
  299. return HAL_OK;
  300. }
  301. /**
  302. * @brief Initialize the FSMC_NORSRAM Extended mode Timing according to the specified
  303. * parameters in the FSMC_NORSRAM_TimingTypeDef
  304. * @param Device Pointer to NORSRAM device instance
  305. * @param Timing Pointer to NORSRAM Timing structure
  306. * @param Bank NORSRAM bank number
  307. * @retval HAL status
  308. */
  309. HAL_StatusTypeDef FSMC_NORSRAM_Extended_Timing_Init(FSMC_NORSRAM_EXTENDED_TypeDef *Device, FSMC_NORSRAM_TimingTypeDef *Timing, uint32_t Bank, uint32_t ExtendedMode)
  310. {
  311. uint32_t tmpr = 0U;
  312. /* Check the parameters */
  313. assert_param(IS_FSMC_EXTENDED_MODE(ExtendedMode));
  314. /* Set NORSRAM device timing register for write configuration, if extended mode is used */
  315. if(ExtendedMode == FSMC_EXTENDED_MODE_ENABLE)
  316. {
  317. /* Check the parameters */
  318. assert_param(IS_FSMC_NORSRAM_EXTENDED_DEVICE(Device));
  319. assert_param(IS_FSMC_ADDRESS_SETUP_TIME(Timing->AddressSetupTime));
  320. assert_param(IS_FSMC_ADDRESS_HOLD_TIME(Timing->AddressHoldTime));
  321. assert_param(IS_FSMC_DATASETUP_TIME(Timing->DataSetupTime));
  322. assert_param(IS_FSMC_TURNAROUND_TIME(Timing->BusTurnAroundDuration));
  323. assert_param(IS_FSMC_ACCESS_MODE(Timing->AccessMode));
  324. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  325. /* Get the BWTR register value */
  326. tmpr = Device->BWTR[Bank];
  327. /* Clear ADDSET, ADDHLD, DATAST, BUSTURN and ACCMOD bits */
  328. tmpr &= ((uint32_t)~(FSMC_BWTR1_ADDSET | FSMC_BWTR1_ADDHLD | FSMC_BWTR1_DATAST | \
  329. FSMC_BWTR1_BUSTURN | FSMC_BWTR1_ACCMOD));
  330. tmpr |= (uint32_t)(Timing->AddressSetupTime |\
  331. ((Timing->AddressHoldTime) << 4U) |\
  332. ((Timing->DataSetupTime) << 8U) |\
  333. ((Timing->BusTurnAroundDuration) << 16U) |\
  334. (Timing->AccessMode));
  335. Device->BWTR[Bank] = tmpr;
  336. }
  337. else
  338. {
  339. Device->BWTR[Bank] = 0x0FFFFFFFU;
  340. }
  341. return HAL_OK;
  342. }
  343. /**
  344. * @}
  345. */
  346. /** @addtogroup FSMC_LL_NORSRAM_Private_Functions_Group2
  347. * @brief management functions
  348. *
  349. @verbatim
  350. ==============================================================================
  351. ##### FSMC_NORSRAM Control functions #####
  352. ==============================================================================
  353. [..]
  354. This subsection provides a set of functions allowing to control dynamically
  355. the FSMC NORSRAM interface.
  356. @endverbatim
  357. * @{
  358. */
  359. /**
  360. * @brief Enables dynamically FSMC_NORSRAM write operation.
  361. * @param Device Pointer to NORSRAM device instance
  362. * @param Bank NORSRAM bank number
  363. * @retval HAL status
  364. */
  365. HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Enable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
  366. {
  367. /* Check the parameters */
  368. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  369. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  370. /* Enable write operation */
  371. Device->BTCR[Bank] |= FSMC_WRITE_OPERATION_ENABLE;
  372. return HAL_OK;
  373. }
  374. /**
  375. * @brief Disables dynamically FSMC_NORSRAM write operation.
  376. * @param Device Pointer to NORSRAM device instance
  377. * @param Bank NORSRAM bank number
  378. * @retval HAL status
  379. */
  380. HAL_StatusTypeDef FSMC_NORSRAM_WriteOperation_Disable(FSMC_NORSRAM_TypeDef *Device, uint32_t Bank)
  381. {
  382. /* Check the parameters */
  383. assert_param(IS_FSMC_NORSRAM_DEVICE(Device));
  384. assert_param(IS_FSMC_NORSRAM_BANK(Bank));
  385. /* Disable write operation */
  386. Device->BTCR[Bank] &= ~FSMC_WRITE_OPERATION_ENABLE;
  387. return HAL_OK;
  388. }
  389. /**
  390. * @}
  391. */
  392. /**
  393. * @}
  394. */
  395. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
  396. /** @addtogroup FSMC_LL_NAND
  397. * @brief NAND Controller functions
  398. *
  399. @verbatim
  400. ==============================================================================
  401. ##### How to use NAND device driver #####
  402. ==============================================================================
  403. [..]
  404. This driver contains a set of APIs to interface with the FSMC NAND banks in order
  405. to run the NAND external devices.
  406. (+) FSMC NAND bank reset using the function FSMC_NAND_DeInit()
  407. (+) FSMC NAND bank control configuration using the function FSMC_NAND_Init()
  408. (+) FSMC NAND bank common space timing configuration using the function
  409. FSMC_NAND_CommonSpace_Timing_Init()
  410. (+) FSMC NAND bank attribute space timing configuration using the function
  411. FSMC_NAND_AttributeSpace_Timing_Init()
  412. (+) FSMC NAND bank enable/disable ECC correction feature using the functions
  413. FSMC_NAND_ECC_Enable()/FSMC_NAND_ECC_Disable()
  414. (+) FSMC NAND bank get ECC correction code using the function FSMC_NAND_GetECC()
  415. @endverbatim
  416. * @{
  417. */
  418. /** @addtogroup FSMC_LL_NAND_Private_Functions_Group1
  419. * @brief Initialization and Configuration functions
  420. *
  421. @verbatim
  422. ==============================================================================
  423. ##### Initialization and de_initialization functions #####
  424. ==============================================================================
  425. [..]
  426. This section provides functions allowing to:
  427. (+) Initialize and configure the FSMC NAND interface
  428. (+) De-initialize the FSMC NAND interface
  429. (+) Configure the FSMC clock and associated GPIOs
  430. @endverbatim
  431. * @{
  432. */
  433. /**
  434. * @brief Initializes the FSMC_NAND device according to the specified
  435. * control parameters in the FSMC_NAND_HandleTypeDef
  436. * @param Device Pointer to NAND device instance
  437. * @param Init Pointer to NAND Initialization structure
  438. * @retval HAL status
  439. */
  440. HAL_StatusTypeDef FSMC_NAND_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_InitTypeDef *Init)
  441. {
  442. uint32_t tmpr = 0U;
  443. /* Check the parameters */
  444. assert_param(IS_FSMC_NAND_BANK(Init->NandBank));
  445. assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
  446. assert_param(IS_FSMC_NAND_MEMORY_WIDTH(Init->MemoryDataWidth));
  447. assert_param(IS_FSMC_ECC_STATE(Init->EccComputation));
  448. assert_param(IS_FSMC_ECCPAGE_SIZE(Init->ECCPageSize));
  449. assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
  450. assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
  451. if(Init->NandBank == FSMC_NAND_BANK2)
  452. {
  453. /* Get the NAND bank 2 register value */
  454. tmpr = Device->PCR2;
  455. }
  456. else
  457. {
  458. /* Get the NAND bank 3 register value */
  459. tmpr = Device->PCR3;
  460. }
  461. /* Clear PWAITEN, PBKEN, PTYP, PWID, ECCEN, TCLR, TAR and ECCPS bits */
  462. tmpr &= ((uint32_t)~(FSMC_PCR2_PWAITEN | FSMC_PCR2_PBKEN | FSMC_PCR2_PTYP | \
  463. FSMC_PCR2_PWID | FSMC_PCR2_ECCEN | FSMC_PCR2_TCLR | \
  464. FSMC_PCR2_TAR | FSMC_PCR2_ECCPS));
  465. /* Set NAND device control parameters */
  466. tmpr |= (uint32_t)(Init->Waitfeature |\
  467. FSMC_PCR_MEMORY_TYPE_NAND |\
  468. Init->MemoryDataWidth |\
  469. Init->EccComputation |\
  470. Init->ECCPageSize |\
  471. ((Init->TCLRSetupTime) << 9U) |\
  472. ((Init->TARSetupTime) << 13U));
  473. if(Init->NandBank == FSMC_NAND_BANK2)
  474. {
  475. /* NAND bank 2 registers configuration */
  476. Device->PCR2 = tmpr;
  477. }
  478. else
  479. {
  480. /* NAND bank 3 registers configuration */
  481. Device->PCR3 = tmpr;
  482. }
  483. return HAL_OK;
  484. }
  485. /**
  486. * @brief Initializes the FSMC_NAND Common space Timing according to the specified
  487. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  488. * @param Device Pointer to NAND device instance
  489. * @param Timing Pointer to NAND timing structure
  490. * @param Bank NAND bank number
  491. * @retval HAL status
  492. */
  493. HAL_StatusTypeDef FSMC_NAND_CommonSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
  494. {
  495. uint32_t tmpr = 0U;
  496. /* Check the parameters */
  497. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  498. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  499. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  500. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  501. if(Bank == FSMC_NAND_BANK2)
  502. {
  503. /* Get the NAND bank 2 register value */
  504. tmpr = Device->PMEM2;
  505. }
  506. else
  507. {
  508. /* Get the NAND bank 3 register value */
  509. tmpr = Device->PMEM3;
  510. }
  511. /* Clear MEMSETx, MEMWAITx, MEMHOLDx and MEMHIZx bits */
  512. tmpr &= ((uint32_t)~(FSMC_PMEM2_MEMSET2 | FSMC_PMEM2_MEMWAIT2 | FSMC_PMEM2_MEMHOLD2 | \
  513. FSMC_PMEM2_MEMHIZ2));
  514. /* Set FSMC_NAND device timing parameters */
  515. tmpr |= (uint32_t)(Timing->SetupTime |\
  516. ((Timing->WaitSetupTime) << 8U) |\
  517. ((Timing->HoldSetupTime) << 16U) |\
  518. ((Timing->HiZSetupTime) << 24U)
  519. );
  520. if(Bank == FSMC_NAND_BANK2)
  521. {
  522. /* NAND bank 2 registers configuration */
  523. Device->PMEM2 = tmpr;
  524. }
  525. else
  526. {
  527. /* NAND bank 3 registers configuration */
  528. Device->PMEM3 = tmpr;
  529. }
  530. return HAL_OK;
  531. }
  532. /**
  533. * @brief Initializes the FSMC_NAND Attribute space Timing according to the specified
  534. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  535. * @param Device Pointer to NAND device instance
  536. * @param Timing Pointer to NAND timing structure
  537. * @param Bank NAND bank number
  538. * @retval HAL status
  539. */
  540. HAL_StatusTypeDef FSMC_NAND_AttributeSpace_Timing_Init(FSMC_NAND_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing, uint32_t Bank)
  541. {
  542. uint32_t tmpr = 0U;
  543. /* Check the parameters */
  544. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  545. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  546. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  547. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  548. if(Bank == FSMC_NAND_BANK2)
  549. {
  550. /* Get the NAND bank 2 register value */
  551. tmpr = Device->PATT2;
  552. }
  553. else
  554. {
  555. /* Get the NAND bank 3 register value */
  556. tmpr = Device->PATT3;
  557. }
  558. /* Clear ATTSETx, ATTWAITx, ATTHOLDx and ATTHIZx bits */
  559. tmpr &= ((uint32_t)~(FSMC_PATT2_ATTSET2 | FSMC_PATT2_ATTWAIT2 | FSMC_PATT2_ATTHOLD2 | \
  560. FSMC_PATT2_ATTHIZ2));
  561. /* Set FSMC_NAND device timing parameters */
  562. tmpr |= (uint32_t)(Timing->SetupTime |\
  563. ((Timing->WaitSetupTime) << 8U) |\
  564. ((Timing->HoldSetupTime) << 16U) |\
  565. ((Timing->HiZSetupTime) << 24U)
  566. );
  567. if(Bank == FSMC_NAND_BANK2)
  568. {
  569. /* NAND bank 2 registers configuration */
  570. Device->PATT2 = tmpr;
  571. }
  572. else
  573. {
  574. /* NAND bank 3 registers configuration */
  575. Device->PATT3 = tmpr;
  576. }
  577. return HAL_OK;
  578. }
  579. /**
  580. * @brief DeInitializes the FSMC_NAND device
  581. * @param Device Pointer to NAND device instance
  582. * @param Bank NAND bank number
  583. * @retval HAL status
  584. */
  585. HAL_StatusTypeDef FSMC_NAND_DeInit(FSMC_NAND_TypeDef *Device, uint32_t Bank)
  586. {
  587. /* Disable the NAND Bank */
  588. __FSMC_NAND_DISABLE(Device, Bank);
  589. /* De-initialize the NAND Bank */
  590. if(Bank == FSMC_NAND_BANK2)
  591. {
  592. /* Set the FSMC_NAND_BANK2 registers to their reset values */
  593. Device->PCR2 = 0x00000018U;
  594. Device->SR2 = 0x00000040U;
  595. Device->PMEM2 = 0xFCFCFCFCU;
  596. Device->PATT2 = 0xFCFCFCFCU;
  597. }
  598. /* FSMC_Bank3_NAND */
  599. else
  600. {
  601. /* Set the FSMC_NAND_BANK3 registers to their reset values */
  602. Device->PCR3 = 0x00000018U;
  603. Device->SR3 = 0x00000040U;
  604. Device->PMEM3 = 0xFCFCFCFCU;
  605. Device->PATT3 = 0xFCFCFCFCU;
  606. }
  607. return HAL_OK;
  608. }
  609. /**
  610. * @}
  611. */
  612. /** @addtogroup FSMC_LL_NAND_Private_Functions_Group2
  613. * @brief management functions
  614. *
  615. @verbatim
  616. ==============================================================================
  617. ##### FSMC_NAND Control functions #####
  618. ==============================================================================
  619. [..]
  620. This subsection provides a set of functions allowing to control dynamically
  621. the FSMC NAND interface.
  622. @endverbatim
  623. * @{
  624. */
  625. /**
  626. * @brief Enables dynamically FSMC_NAND ECC feature.
  627. * @param Device Pointer to NAND device instance
  628. * @param Bank NAND bank number
  629. * @retval HAL status
  630. */
  631. HAL_StatusTypeDef FSMC_NAND_ECC_Enable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
  632. {
  633. /* Enable ECC feature */
  634. if(Bank == FSMC_NAND_BANK2)
  635. {
  636. Device->PCR2 |= FSMC_PCR2_ECCEN;
  637. }
  638. else
  639. {
  640. Device->PCR3 |= FSMC_PCR3_ECCEN;
  641. }
  642. return HAL_OK;
  643. }
  644. /**
  645. * @brief Disables dynamically FSMC_NAND ECC feature.
  646. * @param Device Pointer to NAND device instance
  647. * @param Bank NAND bank number
  648. * @retval HAL status
  649. */
  650. HAL_StatusTypeDef FSMC_NAND_ECC_Disable(FSMC_NAND_TypeDef *Device, uint32_t Bank)
  651. {
  652. /* Disable ECC feature */
  653. if(Bank == FSMC_NAND_BANK2)
  654. {
  655. Device->PCR2 &= ~FSMC_PCR2_ECCEN;
  656. }
  657. else
  658. {
  659. Device->PCR3 &= ~FSMC_PCR3_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, uint32_t Timeout)
  672. {
  673. uint32_t tickstart = 0U;
  674. /* Check the parameters */
  675. assert_param(IS_FSMC_NAND_DEVICE(Device));
  676. assert_param(IS_FSMC_NAND_BANK(Bank));
  677. /* Get tick */
  678. tickstart = HAL_GetTick();
  679. /* Wait until FIFO is empty */
  680. while(__FSMC_NAND_GET_FLAG(Device, Bank, FSMC_FLAG_FEMPT) == RESET)
  681. {
  682. /* Check for the Timeout */
  683. if(Timeout != HAL_MAX_DELAY)
  684. {
  685. if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout))
  686. {
  687. return HAL_TIMEOUT;
  688. }
  689. }
  690. }
  691. if(Bank == FSMC_NAND_BANK2)
  692. {
  693. /* Get the ECCR2 register value */
  694. *ECCval = (uint32_t)Device->ECCR2;
  695. }
  696. else
  697. {
  698. /* Get the ECCR3 register value */
  699. *ECCval = (uint32_t)Device->ECCR3;
  700. }
  701. return HAL_OK;
  702. }
  703. /**
  704. * @}
  705. */
  706. /**
  707. * @}
  708. */
  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. uint32_t tmpr = 0U;
  755. /* Check the parameters */
  756. assert_param(IS_FSMC_WAIT_FEATURE(Init->Waitfeature));
  757. assert_param(IS_FSMC_TCLR_TIME(Init->TCLRSetupTime));
  758. assert_param(IS_FSMC_TAR_TIME(Init->TARSetupTime));
  759. /* Get PCCARD control register value */
  760. tmpr = Device->PCR4;
  761. /* Clear TAR, TCLR, PWAITEN and PWID bits */
  762. tmpr &= ((uint32_t)~(FSMC_PCR4_TAR | FSMC_PCR4_TCLR | FSMC_PCR4_PWAITEN | \
  763. FSMC_PCR4_PWID | FSMC_PCR4_PTYP));
  764. /* Set FSMC_PCCARD device control parameters */
  765. tmpr |= (uint32_t)(Init->Waitfeature |\
  766. FSMC_NAND_PCC_MEM_BUS_WIDTH_16 |\
  767. (Init->TCLRSetupTime << 9U) |\
  768. (Init->TARSetupTime << 13U));
  769. Device->PCR4 = tmpr;
  770. return HAL_OK;
  771. }
  772. /**
  773. * @brief Initializes the FSMC_PCCARD Common space Timing according to the specified
  774. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  775. * @param Device Pointer to PCCARD device instance
  776. * @param Timing Pointer to PCCARD timing structure
  777. * @retval HAL status
  778. */
  779. HAL_StatusTypeDef FSMC_PCCARD_CommonSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
  780. {
  781. uint32_t tmpr = 0U;
  782. /* Check the parameters */
  783. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  784. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  785. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  786. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  787. /* Get PCCARD common space timing register value */
  788. tmpr = Device->PMEM4;
  789. /* Clear MEMSETx, MEMWAITx, MEMHOLDx and MEMHIZx bits */
  790. tmpr &= ((uint32_t)~(FSMC_PMEM4_MEMSET4 | FSMC_PMEM4_MEMWAIT4 | FSMC_PMEM4_MEMHOLD4 | \
  791. FSMC_PMEM4_MEMHIZ4));
  792. /* Set PCCARD timing parameters */
  793. tmpr |= (uint32_t)((Timing->SetupTime |\
  794. ((Timing->WaitSetupTime) << 8U) |\
  795. (Timing->HoldSetupTime) << 16U) |\
  796. ((Timing->HiZSetupTime) << 24U));
  797. Device->PMEM4 = tmpr;
  798. return HAL_OK;
  799. }
  800. /**
  801. * @brief Initializes the FSMC_PCCARD Attribute space Timing according to the specified
  802. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  803. * @param Device Pointer to PCCARD device instance
  804. * @param Timing Pointer to PCCARD timing structure
  805. * @retval HAL status
  806. */
  807. HAL_StatusTypeDef FSMC_PCCARD_AttributeSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
  808. {
  809. uint32_t tmpr = 0U;
  810. /* Check the parameters */
  811. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  812. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  813. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  814. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  815. /* Get PCCARD timing parameters */
  816. tmpr = Device->PATT4;
  817. /* Clear ATTSETx, ATTWAITx, ATTHOLDx and ATTHIZx bits */
  818. tmpr &= ((uint32_t)~(FSMC_PATT4_ATTSET4 | FSMC_PATT4_ATTWAIT4 | FSMC_PATT4_ATTHOLD4 | \
  819. FSMC_PATT4_ATTHIZ4));
  820. /* Set PCCARD timing parameters */
  821. tmpr |= (uint32_t)(Timing->SetupTime |\
  822. ((Timing->WaitSetupTime) << 8U) |\
  823. ((Timing->HoldSetupTime) << 16U) |\
  824. ((Timing->HiZSetupTime) << 24U));
  825. Device->PATT4 = tmpr;
  826. return HAL_OK;
  827. }
  828. /**
  829. * @brief Initializes the FSMC_PCCARD IO space Timing according to the specified
  830. * parameters in the FSMC_NAND_PCC_TimingTypeDef
  831. * @param Device Pointer to PCCARD device instance
  832. * @param Timing Pointer to PCCARD timing structure
  833. * @retval HAL status
  834. */
  835. HAL_StatusTypeDef FSMC_PCCARD_IOSpace_Timing_Init(FSMC_PCCARD_TypeDef *Device, FSMC_NAND_PCC_TimingTypeDef *Timing)
  836. {
  837. uint32_t tmpr = 0U;
  838. /* Check the parameters */
  839. assert_param(IS_FSMC_SETUP_TIME(Timing->SetupTime));
  840. assert_param(IS_FSMC_WAIT_TIME(Timing->WaitSetupTime));
  841. assert_param(IS_FSMC_HOLD_TIME(Timing->HoldSetupTime));
  842. assert_param(IS_FSMC_HIZ_TIME(Timing->HiZSetupTime));
  843. /* Get FSMC_PCCARD device timing parameters */
  844. tmpr = Device->PIO4;
  845. /* Clear IOSET4, IOWAIT4, IOHOLD4 and IOHIZ4 bits */
  846. tmpr &= ((uint32_t)~(FSMC_PIO4_IOSET4 | FSMC_PIO4_IOWAIT4 | FSMC_PIO4_IOHOLD4 | \
  847. FSMC_PIO4_IOHIZ4));
  848. /* Set FSMC_PCCARD device timing parameters */
  849. tmpr |= (uint32_t)(Timing->SetupTime |\
  850. ((Timing->WaitSetupTime) << 8U) |\
  851. ((Timing->HoldSetupTime) << 16U) |\
  852. ((Timing->HiZSetupTime) << 24U));
  853. Device->PIO4 = tmpr;
  854. return HAL_OK;
  855. }
  856. /**
  857. * @brief DeInitializes the FSMC_PCCARD device
  858. * @param Device Pointer to PCCARD device instance
  859. * @retval HAL status
  860. */
  861. HAL_StatusTypeDef FSMC_PCCARD_DeInit(FSMC_PCCARD_TypeDef *Device)
  862. {
  863. /* Disable the FSMC_PCCARD device */
  864. __FSMC_PCCARD_DISABLE(Device);
  865. /* De-initialize the FSMC_PCCARD device */
  866. Device->PCR4 = 0x00000018U;
  867. Device->SR4 = 0x00000000U;
  868. Device->PMEM4 = 0xFCFCFCFCU;
  869. Device->PATT4 = 0xFCFCFCFCU;
  870. Device->PIO4 = 0xFCFCFCFCU;
  871. return HAL_OK;
  872. }
  873. /**
  874. * @}
  875. */
  876. /**
  877. * @}
  878. */
  879. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
  880. /**
  881. * @}
  882. */
  883. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F413xx || STM32F423xx */
  884. #endif /* HAL_SRAM_MODULE_ENABLED || HAL_NOR_MODULE_ENABLED || HAL_NAND_MODULE_ENABLED || HAL_PCCARD_MODULE_ENABLED */
  885. /**
  886. * @}
  887. */
  888. /**
  889. * @}
  890. */
  891. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/