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