You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

691 lines
22 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f7xx_hal_sram.c
  4. * @author MCD Application Team
  5. * @version V1.2.2
  6. * @date 14-April-2017
  7. * @brief SRAM HAL module driver.
  8. * This file provides a generic firmware to drive SRAM memories
  9. * mounted as external device.
  10. *
  11. @verbatim
  12. ==============================================================================
  13. ##### How to use this driver #####
  14. ==============================================================================
  15. [..]
  16. This driver is a generic layered driver which contains a set of APIs used to
  17. control SRAM memories. It uses the FMC layer functions to interface
  18. with SRAM devices.
  19. The following sequence should be followed to configure the FMC to interface
  20. with SRAM/PSRAM memories:
  21. (#) Declare a SRAM_HandleTypeDef handle structure, for example:
  22. SRAM_HandleTypeDef hsram; and:
  23. (++) Fill the SRAM_HandleTypeDef handle "Init" field with the allowed
  24. values of the structure member.
  25. (++) Fill the SRAM_HandleTypeDef handle "Instance" field with a predefined
  26. base register instance for NOR or SRAM device
  27. (++) Fill the SRAM_HandleTypeDef handle "Extended" field with a predefined
  28. base register instance for NOR or SRAM extended mode
  29. (#) Declare two FMC_NORSRAM_TimingTypeDef structures, for both normal and extended
  30. mode timings; for example:
  31. FMC_NORSRAM_TimingTypeDef Timing and FMC_NORSRAM_TimingTypeDef ExTiming;
  32. and fill its fields with the allowed values of the structure member.
  33. (#) Initialize the SRAM Controller by calling the function HAL_SRAM_Init(). This function
  34. performs the following sequence:
  35. (##) MSP hardware layer configuration using the function HAL_SRAM_MspInit()
  36. (##) Control register configuration using the FMC NORSRAM interface function
  37. FMC_NORSRAM_Init()
  38. (##) Timing register configuration using the FMC NORSRAM interface function
  39. FMC_NORSRAM_Timing_Init()
  40. (##) Extended mode Timing register configuration using the FMC NORSRAM interface function
  41. FMC_NORSRAM_Extended_Timing_Init()
  42. (##) Enable the SRAM device using the macro __FMC_NORSRAM_ENABLE()
  43. (#) At this stage you can perform read/write accesses from/to the memory connected
  44. to the NOR/SRAM Bank. You can perform either polling or DMA transfer using the
  45. following APIs:
  46. (++) HAL_SRAM_Read()/HAL_SRAM_Write() for polling read/write access
  47. (++) HAL_SRAM_Read_DMA()/HAL_SRAM_Write_DMA() for DMA read/write transfer
  48. (#) You can also control the SRAM device by calling the control APIs HAL_SRAM_WriteOperation_Enable()/
  49. HAL_SRAM_WriteOperation_Disable() to respectively enable/disable the SRAM write operation
  50. (#) You can continuously monitor the SRAM device HAL state by calling the function
  51. HAL_SRAM_GetState()
  52. @endverbatim
  53. ******************************************************************************
  54. * @attention
  55. *
  56. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  57. *
  58. * Redistribution and use in source and binary forms, with or without modification,
  59. * are permitted provided that the following conditions are met:
  60. * 1. Redistributions of source code must retain the above copyright notice,
  61. * this list of conditions and the following disclaimer.
  62. * 2. Redistributions in binary form must reproduce the above copyright notice,
  63. * this list of conditions and the following disclaimer in the documentation
  64. * and/or other materials provided with the distribution.
  65. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  66. * may be used to endorse or promote products derived from this software
  67. * without specific prior written permission.
  68. *
  69. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  70. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  71. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  72. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  73. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  74. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  75. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  76. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  77. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  78. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  79. *
  80. ******************************************************************************
  81. */
  82. /* Includes ------------------------------------------------------------------*/
  83. #include "stm32f7xx_hal.h"
  84. /** @addtogroup STM32F7xx_HAL_Driver
  85. * @{
  86. */
  87. /** @defgroup SRAM SRAM
  88. * @brief SRAM driver modules
  89. * @{
  90. */
  91. #ifdef HAL_SRAM_MODULE_ENABLED
  92. /* Private typedef -----------------------------------------------------------*/
  93. /* Private define ------------------------------------------------------------*/
  94. /* Private macro -------------------------------------------------------------*/
  95. /* Private variables ---------------------------------------------------------*/
  96. /* Private function prototypes -----------------------------------------------*/
  97. /* Exported functions --------------------------------------------------------*/
  98. /** @defgroup SRAM_Exported_Functions SRAM Exported Functions
  99. * @{
  100. */
  101. /** @defgroup SRAM_Exported_Functions_Group1 Initialization and de-initialization functions
  102. * @brief Initialization and Configuration functions.
  103. *
  104. @verbatim
  105. ==============================================================================
  106. ##### SRAM Initialization and de_initialization functions #####
  107. ==============================================================================
  108. [..] This section provides functions allowing to initialize/de-initialize
  109. the SRAM memory
  110. @endverbatim
  111. * @{
  112. */
  113. /**
  114. * @brief Performs the SRAM device initialization sequence
  115. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  116. * the configuration information for SRAM module.
  117. * @param Timing: Pointer to SRAM control timing structure
  118. * @param ExtTiming: Pointer to SRAM extended mode timing structure
  119. * @retval HAL status
  120. */
  121. HAL_StatusTypeDef HAL_SRAM_Init(SRAM_HandleTypeDef *hsram, FMC_NORSRAM_TimingTypeDef *Timing, FMC_NORSRAM_TimingTypeDef *ExtTiming)
  122. {
  123. /* Check the SRAM handle parameter */
  124. if(hsram == NULL)
  125. {
  126. return HAL_ERROR;
  127. }
  128. if(hsram->State == HAL_SRAM_STATE_RESET)
  129. {
  130. /* Allocate lock resource and initialize it */
  131. hsram->Lock = HAL_UNLOCKED;
  132. /* Initialize the low level hardware (MSP) */
  133. HAL_SRAM_MspInit(hsram);
  134. }
  135. /* Initialize SRAM control Interface */
  136. FMC_NORSRAM_Init(hsram->Instance, &(hsram->Init));
  137. /* Initialize SRAM timing Interface */
  138. FMC_NORSRAM_Timing_Init(hsram->Instance, Timing, hsram->Init.NSBank);
  139. /* Initialize SRAM extended mode timing Interface */
  140. FMC_NORSRAM_Extended_Timing_Init(hsram->Extended, ExtTiming, hsram->Init.NSBank, hsram->Init.ExtendedMode);
  141. /* Enable the NORSRAM device */
  142. __FMC_NORSRAM_ENABLE(hsram->Instance, hsram->Init.NSBank);
  143. return HAL_OK;
  144. }
  145. /**
  146. * @brief Performs the SRAM device De-initialization sequence.
  147. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  148. * the configuration information for SRAM module.
  149. * @retval HAL status
  150. */
  151. HAL_StatusTypeDef HAL_SRAM_DeInit(SRAM_HandleTypeDef *hsram)
  152. {
  153. /* De-Initialize the low level hardware (MSP) */
  154. HAL_SRAM_MspDeInit(hsram);
  155. /* Configure the SRAM registers with their reset values */
  156. FMC_NORSRAM_DeInit(hsram->Instance, hsram->Extended, hsram->Init.NSBank);
  157. hsram->State = HAL_SRAM_STATE_RESET;
  158. /* Release Lock */
  159. __HAL_UNLOCK(hsram);
  160. return HAL_OK;
  161. }
  162. /**
  163. * @brief SRAM MSP Init.
  164. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  165. * the configuration information for SRAM module.
  166. * @retval None
  167. */
  168. __weak void HAL_SRAM_MspInit(SRAM_HandleTypeDef *hsram)
  169. {
  170. /* Prevent unused argument(s) compilation warning */
  171. UNUSED(hsram);
  172. /* NOTE : This function Should not be modified, when the callback is needed,
  173. the HAL_SRAM_MspInit could be implemented in the user file
  174. */
  175. }
  176. /**
  177. * @brief SRAM MSP DeInit.
  178. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  179. * the configuration information for SRAM module.
  180. * @retval None
  181. */
  182. __weak void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef *hsram)
  183. {
  184. /* Prevent unused argument(s) compilation warning */
  185. UNUSED(hsram);
  186. /* NOTE : This function Should not be modified, when the callback is needed,
  187. the HAL_SRAM_MspDeInit could be implemented in the user file
  188. */
  189. }
  190. /**
  191. * @brief DMA transfer complete callback.
  192. * @param hdma: pointer to a SRAM_HandleTypeDef structure that contains
  193. * the configuration information for SRAM module.
  194. * @retval None
  195. */
  196. __weak void HAL_SRAM_DMA_XferCpltCallback(DMA_HandleTypeDef *hdma)
  197. {
  198. /* Prevent unused argument(s) compilation warning */
  199. UNUSED(hdma);
  200. /* NOTE : This function Should not be modified, when the callback is needed,
  201. the HAL_SRAM_DMA_XferCpltCallback could be implemented in the user file
  202. */
  203. }
  204. /**
  205. * @brief DMA transfer complete error callback.
  206. * @param hdma: pointer to a SRAM_HandleTypeDef structure that contains
  207. * the configuration information for SRAM module.
  208. * @retval None
  209. */
  210. __weak void HAL_SRAM_DMA_XferErrorCallback(DMA_HandleTypeDef *hdma)
  211. {
  212. /* Prevent unused argument(s) compilation warning */
  213. UNUSED(hdma);
  214. /* NOTE : This function Should not be modified, when the callback is needed,
  215. the HAL_SRAM_DMA_XferErrorCallback could be implemented in the user file
  216. */
  217. }
  218. /**
  219. * @}
  220. */
  221. /** @defgroup SRAM_Exported_Functions_Group2 Input Output and memory control functions
  222. * @brief Input Output and memory control functions
  223. *
  224. @verbatim
  225. ==============================================================================
  226. ##### SRAM Input and Output functions #####
  227. ==============================================================================
  228. [..]
  229. This section provides functions allowing to use and control the SRAM memory
  230. @endverbatim
  231. * @{
  232. */
  233. /**
  234. * @brief Reads 8-bit buffer from SRAM memory.
  235. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  236. * the configuration information for SRAM module.
  237. * @param pAddress: Pointer to read start address
  238. * @param pDstBuffer: Pointer to destination buffer
  239. * @param BufferSize: Size of the buffer to read from memory
  240. * @retval HAL status
  241. */
  242. HAL_StatusTypeDef HAL_SRAM_Read_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pDstBuffer, uint32_t BufferSize)
  243. {
  244. __IO uint8_t * psramaddress = (uint8_t *)pAddress;
  245. /* Process Locked */
  246. __HAL_LOCK(hsram);
  247. /* Update the SRAM controller state */
  248. hsram->State = HAL_SRAM_STATE_BUSY;
  249. /* Read data from memory */
  250. for(; BufferSize != 0; BufferSize--)
  251. {
  252. *pDstBuffer = *(__IO uint8_t *)psramaddress;
  253. pDstBuffer++;
  254. psramaddress++;
  255. }
  256. /* Update the SRAM controller state */
  257. hsram->State = HAL_SRAM_STATE_READY;
  258. /* Process unlocked */
  259. __HAL_UNLOCK(hsram);
  260. return HAL_OK;
  261. }
  262. /**
  263. * @brief Writes 8-bit buffer to SRAM memory.
  264. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  265. * the configuration information for SRAM module.
  266. * @param pAddress: Pointer to write start address
  267. * @param pSrcBuffer: Pointer to source buffer to write
  268. * @param BufferSize: Size of the buffer to write to memory
  269. * @retval HAL status
  270. */
  271. HAL_StatusTypeDef HAL_SRAM_Write_8b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint8_t *pSrcBuffer, uint32_t BufferSize)
  272. {
  273. __IO uint8_t * psramaddress = (uint8_t *)pAddress;
  274. /* Check the SRAM controller state */
  275. if(hsram->State == HAL_SRAM_STATE_PROTECTED)
  276. {
  277. return HAL_ERROR;
  278. }
  279. /* Process Locked */
  280. __HAL_LOCK(hsram);
  281. /* Update the SRAM controller state */
  282. hsram->State = HAL_SRAM_STATE_BUSY;
  283. /* Write data to memory */
  284. for(; BufferSize != 0; BufferSize--)
  285. {
  286. *(__IO uint8_t *)psramaddress = *pSrcBuffer;
  287. pSrcBuffer++;
  288. psramaddress++;
  289. }
  290. /* Update the SRAM controller state */
  291. hsram->State = HAL_SRAM_STATE_READY;
  292. /* Process unlocked */
  293. __HAL_UNLOCK(hsram);
  294. return HAL_OK;
  295. }
  296. /**
  297. * @brief Reads 16-bit buffer from SRAM memory.
  298. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  299. * the configuration information for SRAM module.
  300. * @param pAddress: Pointer to read start address
  301. * @param pDstBuffer: Pointer to destination buffer
  302. * @param BufferSize: Size of the buffer to read from memory
  303. * @retval HAL status
  304. */
  305. HAL_StatusTypeDef HAL_SRAM_Read_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pDstBuffer, uint32_t BufferSize)
  306. {
  307. __IO uint16_t * psramaddress = (uint16_t *)pAddress;
  308. /* Process Locked */
  309. __HAL_LOCK(hsram);
  310. /* Update the SRAM controller state */
  311. hsram->State = HAL_SRAM_STATE_BUSY;
  312. /* Read data from memory */
  313. for(; BufferSize != 0; BufferSize--)
  314. {
  315. *pDstBuffer = *(__IO uint16_t *)psramaddress;
  316. pDstBuffer++;
  317. psramaddress++;
  318. }
  319. /* Update the SRAM controller state */
  320. hsram->State = HAL_SRAM_STATE_READY;
  321. /* Process unlocked */
  322. __HAL_UNLOCK(hsram);
  323. return HAL_OK;
  324. }
  325. /**
  326. * @brief Writes 16-bit buffer to SRAM memory.
  327. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  328. * the configuration information for SRAM module.
  329. * @param pAddress: Pointer to write start address
  330. * @param pSrcBuffer: Pointer to source buffer to write
  331. * @param BufferSize: Size of the buffer to write to memory
  332. * @retval HAL status
  333. */
  334. HAL_StatusTypeDef HAL_SRAM_Write_16b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint16_t *pSrcBuffer, uint32_t BufferSize)
  335. {
  336. __IO uint16_t * psramaddress = (uint16_t *)pAddress;
  337. /* Check the SRAM controller state */
  338. if(hsram->State == HAL_SRAM_STATE_PROTECTED)
  339. {
  340. return HAL_ERROR;
  341. }
  342. /* Process Locked */
  343. __HAL_LOCK(hsram);
  344. /* Update the SRAM controller state */
  345. hsram->State = HAL_SRAM_STATE_BUSY;
  346. /* Write data to memory */
  347. for(; BufferSize != 0; BufferSize--)
  348. {
  349. *(__IO uint16_t *)psramaddress = *pSrcBuffer;
  350. pSrcBuffer++;
  351. psramaddress++;
  352. }
  353. /* Update the SRAM controller state */
  354. hsram->State = HAL_SRAM_STATE_READY;
  355. /* Process unlocked */
  356. __HAL_UNLOCK(hsram);
  357. return HAL_OK;
  358. }
  359. /**
  360. * @brief Reads 32-bit buffer from SRAM memory.
  361. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  362. * the configuration information for SRAM module.
  363. * @param pAddress: Pointer to read start address
  364. * @param pDstBuffer: Pointer to destination buffer
  365. * @param BufferSize: Size of the buffer to read from memory
  366. * @retval HAL status
  367. */
  368. HAL_StatusTypeDef HAL_SRAM_Read_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize)
  369. {
  370. /* Process Locked */
  371. __HAL_LOCK(hsram);
  372. /* Update the SRAM controller state */
  373. hsram->State = HAL_SRAM_STATE_BUSY;
  374. /* Read data from memory */
  375. for(; BufferSize != 0; BufferSize--)
  376. {
  377. *pDstBuffer = *(__IO uint32_t *)pAddress;
  378. pDstBuffer++;
  379. pAddress++;
  380. }
  381. /* Update the SRAM controller state */
  382. hsram->State = HAL_SRAM_STATE_READY;
  383. /* Process unlocked */
  384. __HAL_UNLOCK(hsram);
  385. return HAL_OK;
  386. }
  387. /**
  388. * @brief Writes 32-bit buffer to SRAM memory.
  389. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  390. * the configuration information for SRAM module.
  391. * @param pAddress: Pointer to write start address
  392. * @param pSrcBuffer: Pointer to source buffer to write
  393. * @param BufferSize: Size of the buffer to write to memory
  394. * @retval HAL status
  395. */
  396. HAL_StatusTypeDef HAL_SRAM_Write_32b(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize)
  397. {
  398. /* Check the SRAM controller state */
  399. if(hsram->State == HAL_SRAM_STATE_PROTECTED)
  400. {
  401. return HAL_ERROR;
  402. }
  403. /* Process Locked */
  404. __HAL_LOCK(hsram);
  405. /* Update the SRAM controller state */
  406. hsram->State = HAL_SRAM_STATE_BUSY;
  407. /* Write data to memory */
  408. for(; BufferSize != 0; BufferSize--)
  409. {
  410. *(__IO uint32_t *)pAddress = *pSrcBuffer;
  411. pSrcBuffer++;
  412. pAddress++;
  413. }
  414. /* Update the SRAM controller state */
  415. hsram->State = HAL_SRAM_STATE_READY;
  416. /* Process unlocked */
  417. __HAL_UNLOCK(hsram);
  418. return HAL_OK;
  419. }
  420. /**
  421. * @brief Reads a Words data from the SRAM memory using DMA transfer.
  422. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  423. * the configuration information for SRAM module.
  424. * @param pAddress: Pointer to read start address
  425. * @param pDstBuffer: Pointer to destination buffer
  426. * @param BufferSize: Size of the buffer to read from memory
  427. * @retval HAL status
  428. */
  429. HAL_StatusTypeDef HAL_SRAM_Read_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pDstBuffer, uint32_t BufferSize)
  430. {
  431. /* Process Locked */
  432. __HAL_LOCK(hsram);
  433. /* Update the SRAM controller state */
  434. hsram->State = HAL_SRAM_STATE_BUSY;
  435. /* Configure DMA user callbacks */
  436. hsram->hdma->XferCpltCallback = HAL_SRAM_DMA_XferCpltCallback;
  437. hsram->hdma->XferErrorCallback = HAL_SRAM_DMA_XferErrorCallback;
  438. /* Enable the DMA Stream */
  439. HAL_DMA_Start_IT(hsram->hdma, (uint32_t)pAddress, (uint32_t)pDstBuffer, (uint32_t)BufferSize);
  440. /* Update the SRAM controller state */
  441. hsram->State = HAL_SRAM_STATE_READY;
  442. /* Process unlocked */
  443. __HAL_UNLOCK(hsram);
  444. return HAL_OK;
  445. }
  446. /**
  447. * @brief Writes a Words data buffer to SRAM memory using DMA transfer.
  448. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  449. * the configuration information for SRAM module.
  450. * @param pAddress: Pointer to write start address
  451. * @param pSrcBuffer: Pointer to source buffer to write
  452. * @param BufferSize: Size of the buffer to write to memory
  453. * @retval HAL status
  454. */
  455. HAL_StatusTypeDef HAL_SRAM_Write_DMA(SRAM_HandleTypeDef *hsram, uint32_t *pAddress, uint32_t *pSrcBuffer, uint32_t BufferSize)
  456. {
  457. /* Check the SRAM controller state */
  458. if(hsram->State == HAL_SRAM_STATE_PROTECTED)
  459. {
  460. return HAL_ERROR;
  461. }
  462. /* Process Locked */
  463. __HAL_LOCK(hsram);
  464. /* Update the SRAM controller state */
  465. hsram->State = HAL_SRAM_STATE_BUSY;
  466. /* Configure DMA user callbacks */
  467. hsram->hdma->XferCpltCallback = HAL_SRAM_DMA_XferCpltCallback;
  468. hsram->hdma->XferErrorCallback = HAL_SRAM_DMA_XferErrorCallback;
  469. /* Enable the DMA Stream */
  470. HAL_DMA_Start_IT(hsram->hdma, (uint32_t)pSrcBuffer, (uint32_t)pAddress, (uint32_t)BufferSize);
  471. /* Update the SRAM controller state */
  472. hsram->State = HAL_SRAM_STATE_READY;
  473. /* Process unlocked */
  474. __HAL_UNLOCK(hsram);
  475. return HAL_OK;
  476. }
  477. /**
  478. * @}
  479. */
  480. /** @defgroup SRAM_Exported_Functions_Group3 Control functions
  481. * @brief Control functions
  482. *
  483. @verbatim
  484. ==============================================================================
  485. ##### SRAM Control functions #####
  486. ==============================================================================
  487. [..]
  488. This subsection provides a set of functions allowing to control dynamically
  489. the SRAM interface.
  490. @endverbatim
  491. * @{
  492. */
  493. /**
  494. * @brief Enables dynamically SRAM write operation.
  495. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  496. * the configuration information for SRAM module.
  497. * @retval HAL status
  498. */
  499. HAL_StatusTypeDef HAL_SRAM_WriteOperation_Enable(SRAM_HandleTypeDef *hsram)
  500. {
  501. /* Process Locked */
  502. __HAL_LOCK(hsram);
  503. /* Enable write operation */
  504. FMC_NORSRAM_WriteOperation_Enable(hsram->Instance, hsram->Init.NSBank);
  505. /* Update the SRAM controller state */
  506. hsram->State = HAL_SRAM_STATE_READY;
  507. /* Process unlocked */
  508. __HAL_UNLOCK(hsram);
  509. return HAL_OK;
  510. }
  511. /**
  512. * @brief Disables dynamically SRAM write operation.
  513. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  514. * the configuration information for SRAM module.
  515. * @retval HAL status
  516. */
  517. HAL_StatusTypeDef HAL_SRAM_WriteOperation_Disable(SRAM_HandleTypeDef *hsram)
  518. {
  519. /* Process Locked */
  520. __HAL_LOCK(hsram);
  521. /* Update the SRAM controller state */
  522. hsram->State = HAL_SRAM_STATE_BUSY;
  523. /* Disable write operation */
  524. FMC_NORSRAM_WriteOperation_Disable(hsram->Instance, hsram->Init.NSBank);
  525. /* Update the SRAM controller state */
  526. hsram->State = HAL_SRAM_STATE_PROTECTED;
  527. /* Process unlocked */
  528. __HAL_UNLOCK(hsram);
  529. return HAL_OK;
  530. }
  531. /**
  532. * @}
  533. */
  534. /** @defgroup SRAM_Exported_Functions_Group4 Peripheral State functions
  535. * @brief Peripheral State functions
  536. *
  537. @verbatim
  538. ==============================================================================
  539. ##### SRAM State functions #####
  540. ==============================================================================
  541. [..]
  542. This subsection permits to get in run-time the status of the SRAM controller
  543. and the data flow.
  544. @endverbatim
  545. * @{
  546. */
  547. /**
  548. * @brief Returns the SRAM controller state
  549. * @param hsram: pointer to a SRAM_HandleTypeDef structure that contains
  550. * the configuration information for SRAM module.
  551. * @retval HAL state
  552. */
  553. HAL_SRAM_StateTypeDef HAL_SRAM_GetState(SRAM_HandleTypeDef *hsram)
  554. {
  555. return hsram->State;
  556. }
  557. /**
  558. * @}
  559. */
  560. /**
  561. * @}
  562. */
  563. #endif /* HAL_SRAM_MODULE_ENABLED */
  564. /**
  565. * @}
  566. */
  567. /**
  568. * @}
  569. */
  570. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/