stm32f4xx_ll_fsmc.c 37 KB

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