2 ******************************************************************************
3 * @file stm32f7xx_hal_sdram.c
4 * @author MCD Application Team
7 * @brief SDRAM HAL module driver.
8 * This file provides a generic firmware to drive SDRAM memories mounted
12 ==============================================================================
13 ##### How to use this driver #####
14 ==============================================================================
16 This driver is a generic layered driver which contains a set of APIs used to
17 control SDRAM memories. It uses the FMC layer functions to interface
19 The following sequence should be followed to configure the FMC to interface
22 (#) Declare a SDRAM_HandleTypeDef handle structure, for example:
23 SDRAM_HandleTypeDef hdsram
25 (++) Fill the SDRAM_HandleTypeDef handle "Init" field with the allowed
26 values of the structure member.
28 (++) Fill the SDRAM_HandleTypeDef handle "Instance" field with a predefined
29 base register instance for NOR or SDRAM device
31 (#) Declare a FMC_SDRAM_TimingTypeDef structure; for example:
32 FMC_SDRAM_TimingTypeDef Timing;
33 and fill its fields with the allowed values of the structure member.
35 (#) Initialize the SDRAM Controller by calling the function HAL_SDRAM_Init(). This function
36 performs the following sequence:
38 (##) MSP hardware layer configuration using the function HAL_SDRAM_MspInit()
39 (##) Control register configuration using the FMC SDRAM interface function
41 (##) Timing register configuration using the FMC SDRAM interface function
42 FMC_SDRAM_Timing_Init()
43 (##) Program the SDRAM external device by applying its initialization sequence
44 according to the device plugged in your hardware. This step is mandatory
45 for accessing the SDRAM device.
47 (#) At this stage you can perform read/write accesses from/to the memory connected
48 to the SDRAM Bank. You can perform either polling or DMA transfer using the
50 (++) HAL_SDRAM_Read()/HAL_SDRAM_Write() for polling read/write access
51 (++) HAL_SDRAM_Read_DMA()/HAL_SDRAM_Write_DMA() for DMA read/write transfer
53 (#) You can also control the SDRAM device by calling the control APIs HAL_SDRAM_WriteOperation_Enable()/
54 HAL_SDRAM_WriteOperation_Disable() to respectively enable/disable the SDRAM write operation or
55 the function HAL_SDRAM_SendCommand() to send a specified command to the SDRAM
56 device. The command to be sent must be configured with the FMC_SDRAM_CommandTypeDef
59 (#) You can continuously monitor the SDRAM device HAL state by calling the function
63 ******************************************************************************
66 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
68 * Redistribution and use in source and binary forms, with or without modification,
69 * are permitted provided that the following conditions are met:
70 * 1. Redistributions of source code must retain the above copyright notice,
71 * this list of conditions and the following disclaimer.
72 * 2. Redistributions in binary form must reproduce the above copyright notice,
73 * this list of conditions and the following disclaimer in the documentation
74 * and/or other materials provided with the distribution.
75 * 3. Neither the name of STMicroelectronics nor the names of its contributors
76 * may be used to endorse or promote products derived from this software
77 * without specific prior written permission.
79 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
80 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
82 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
85 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
86 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
87 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
88 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90 ******************************************************************************
93 /* Includes ------------------------------------------------------------------*/
94 #include "stm32f7xx_hal.h"
96 /** @addtogroup STM32F7xx_HAL_Driver
100 /** @defgroup SDRAM SDRAM
101 * @brief SDRAM driver modules
104 #ifdef HAL_SDRAM_MODULE_ENABLED
106 /* Private typedef -----------------------------------------------------------*/
107 /* Private define ------------------------------------------------------------*/
108 /* Private macro -------------------------------------------------------------*/
109 /* Private variables ---------------------------------------------------------*/
110 /* Private functions ---------------------------------------------------------*/
111 /* Exported functions --------------------------------------------------------*/
112 /** @defgroup SDRAM_Exported_Functions SDRAM Exported Functions
116 /** @defgroup SDRAM_Exported_Functions_Group1 Initialization and de-initialization functions
117 * @brief Initialization and Configuration functions
120 ==============================================================================
121 ##### SDRAM Initialization and de_initialization functions #####
122 ==============================================================================
124 This section provides functions allowing to initialize/de-initialize
132 * @brief Performs the SDRAM device initialization sequence.
133 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
134 * the configuration information for SDRAM module.
135 * @param Timing: Pointer to SDRAM control timing structure
138 HAL_StatusTypeDef
HAL_SDRAM_Init(SDRAM_HandleTypeDef
*hsdram
, FMC_SDRAM_TimingTypeDef
*Timing
)
140 /* Check the SDRAM handle parameter */
146 if(hsdram
->State
== HAL_SDRAM_STATE_RESET
)
148 /* Allocate lock resource and initialize it */
149 hsdram
->Lock
= HAL_UNLOCKED
;
150 /* Initialize the low level hardware (MSP) */
151 HAL_SDRAM_MspInit(hsdram
);
154 /* Initialize the SDRAM controller state */
155 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
157 /* Initialize SDRAM control Interface */
158 FMC_SDRAM_Init(hsdram
->Instance
, &(hsdram
->Init
));
160 /* Initialize SDRAM timing Interface */
161 FMC_SDRAM_Timing_Init(hsdram
->Instance
, Timing
, hsdram
->Init
.SDBank
);
163 /* Update the SDRAM controller state */
164 hsdram
->State
= HAL_SDRAM_STATE_READY
;
170 * @brief Perform the SDRAM device initialization sequence.
171 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
172 * the configuration information for SDRAM module.
175 HAL_StatusTypeDef
HAL_SDRAM_DeInit(SDRAM_HandleTypeDef
*hsdram
)
177 /* Initialize the low level hardware (MSP) */
178 HAL_SDRAM_MspDeInit(hsdram
);
180 /* Configure the SDRAM registers with their reset values */
181 FMC_SDRAM_DeInit(hsdram
->Instance
, hsdram
->Init
.SDBank
);
183 /* Reset the SDRAM controller state */
184 hsdram
->State
= HAL_SDRAM_STATE_RESET
;
187 __HAL_UNLOCK(hsdram
);
193 * @brief SDRAM MSP Init.
194 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
195 * the configuration information for SDRAM module.
198 __weak
void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef
*hsdram
)
200 /* Prevent unused argument(s) compilation warning */
203 /* NOTE: This function Should not be modified, when the callback is needed,
204 the HAL_SDRAM_MspInit could be implemented in the user file
209 * @brief SDRAM MSP DeInit.
210 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
211 * the configuration information for SDRAM module.
214 __weak
void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef
*hsdram
)
216 /* Prevent unused argument(s) compilation warning */
219 /* NOTE: This function Should not be modified, when the callback is needed,
220 the HAL_SDRAM_MspDeInit could be implemented in the user file
225 * @brief This function handles SDRAM refresh error interrupt request.
226 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
227 * the configuration information for SDRAM module.
230 void HAL_SDRAM_IRQHandler(SDRAM_HandleTypeDef
*hsdram
)
232 /* Check SDRAM interrupt Rising edge flag */
233 if(__FMC_SDRAM_GET_FLAG(hsdram
->Instance
, FMC_SDRAM_FLAG_REFRESH_IT
))
235 /* SDRAM refresh error interrupt callback */
236 HAL_SDRAM_RefreshErrorCallback(hsdram
);
238 /* Clear SDRAM refresh error interrupt pending bit */
239 __FMC_SDRAM_CLEAR_FLAG(hsdram
->Instance
, FMC_SDRAM_FLAG_REFRESH_ERROR
);
244 * @brief SDRAM Refresh error callback.
245 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
246 * the configuration information for SDRAM module.
249 __weak
void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef
*hsdram
)
251 /* Prevent unused argument(s) compilation warning */
254 /* NOTE: This function Should not be modified, when the callback is needed,
255 the HAL_SDRAM_RefreshErrorCallback could be implemented in the user file
260 * @brief DMA transfer complete callback.
261 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
262 * the configuration information for the specified DMA module.
265 __weak
void HAL_SDRAM_DMA_XferCpltCallback(DMA_HandleTypeDef
*hdma
)
267 /* Prevent unused argument(s) compilation warning */
270 /* NOTE: This function Should not be modified, when the callback is needed,
271 the HAL_SDRAM_DMA_XferCpltCallback could be implemented in the user file
276 * @brief DMA transfer complete error callback.
277 * @param hdma: DMA handle
280 __weak
void HAL_SDRAM_DMA_XferErrorCallback(DMA_HandleTypeDef
*hdma
)
282 /* Prevent unused argument(s) compilation warning */
285 /* NOTE: This function Should not be modified, when the callback is needed,
286 the HAL_SDRAM_DMA_XferErrorCallback could be implemented in the user file
294 /** @defgroup SDRAM_Exported_Functions_Group2 Input and Output functions
295 * @brief Input Output and memory control functions
298 ==============================================================================
299 ##### SDRAM Input and Output functions #####
300 ==============================================================================
302 This section provides functions allowing to use and control the SDRAM memory
309 * @brief Reads 8-bit data buffer from the SDRAM memory.
310 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
311 * the configuration information for SDRAM module.
312 * @param pAddress: Pointer to read start address
313 * @param pDstBuffer: Pointer to destination buffer
314 * @param BufferSize: Size of the buffer to read from memory
317 HAL_StatusTypeDef
HAL_SDRAM_Read_8b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint8_t *pDstBuffer
, uint32_t BufferSize
)
319 __IO
uint8_t *pSdramAddress
= (uint8_t *)pAddress
;
324 /* Check the SDRAM controller state */
325 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
329 else if(hsdram
->State
== HAL_SDRAM_STATE_PRECHARGED
)
334 /* Read data from source */
335 for(; BufferSize
!= 0; BufferSize
--)
337 *pDstBuffer
= *(__IO
uint8_t *)pSdramAddress
;
342 /* Process Unlocked */
343 __HAL_UNLOCK(hsdram
);
350 * @brief Writes 8-bit data buffer to SDRAM memory.
351 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
352 * the configuration information for SDRAM module.
353 * @param pAddress: Pointer to write start address
354 * @param pSrcBuffer: Pointer to source buffer to write
355 * @param BufferSize: Size of the buffer to write to memory
358 HAL_StatusTypeDef
HAL_SDRAM_Write_8b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint8_t *pSrcBuffer
, uint32_t BufferSize
)
360 __IO
uint8_t *pSdramAddress
= (uint8_t *)pAddress
;
366 /* Check the SDRAM controller state */
369 if(tmp
== HAL_SDRAM_STATE_BUSY
)
373 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
378 /* Write data to memory */
379 for(; BufferSize
!= 0; BufferSize
--)
381 *(__IO
uint8_t *)pSdramAddress
= *pSrcBuffer
;
386 /* Process Unlocked */
387 __HAL_UNLOCK(hsdram
);
394 * @brief Reads 16-bit data buffer from the SDRAM memory.
395 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
396 * the configuration information for SDRAM module.
397 * @param pAddress: Pointer to read start address
398 * @param pDstBuffer: Pointer to destination buffer
399 * @param BufferSize: Size of the buffer to read from memory
402 HAL_StatusTypeDef
HAL_SDRAM_Read_16b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint16_t *pDstBuffer
, uint32_t BufferSize
)
404 __IO
uint16_t *pSdramAddress
= (uint16_t *)pAddress
;
409 /* Check the SDRAM controller state */
410 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
414 else if(hsdram
->State
== HAL_SDRAM_STATE_PRECHARGED
)
419 /* Read data from source */
420 for(; BufferSize
!= 0; BufferSize
--)
422 *pDstBuffer
= *(__IO
uint16_t *)pSdramAddress
;
427 /* Process Unlocked */
428 __HAL_UNLOCK(hsdram
);
434 * @brief Writes 16-bit data buffer to SDRAM memory.
435 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
436 * the configuration information for SDRAM module.
437 * @param pAddress: Pointer to write start address
438 * @param pSrcBuffer: Pointer to source buffer to write
439 * @param BufferSize: Size of the buffer to write to memory
442 HAL_StatusTypeDef
HAL_SDRAM_Write_16b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint16_t *pSrcBuffer
, uint32_t BufferSize
)
444 __IO
uint16_t *pSdramAddress
= (uint16_t *)pAddress
;
450 /* Check the SDRAM controller state */
453 if(tmp
== HAL_SDRAM_STATE_BUSY
)
457 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
462 /* Write data to memory */
463 for(; BufferSize
!= 0; BufferSize
--)
465 *(__IO
uint16_t *)pSdramAddress
= *pSrcBuffer
;
470 /* Process Unlocked */
471 __HAL_UNLOCK(hsdram
);
477 * @brief Reads 32-bit data buffer from the SDRAM memory.
478 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
479 * the configuration information for SDRAM module.
480 * @param pAddress: Pointer to read start address
481 * @param pDstBuffer: Pointer to destination buffer
482 * @param BufferSize: Size of the buffer to read from memory
485 HAL_StatusTypeDef
HAL_SDRAM_Read_32b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pDstBuffer
, uint32_t BufferSize
)
487 __IO
uint32_t *pSdramAddress
= (uint32_t *)pAddress
;
492 /* Check the SDRAM controller state */
493 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
497 else if(hsdram
->State
== HAL_SDRAM_STATE_PRECHARGED
)
502 /* Read data from source */
503 for(; BufferSize
!= 0; BufferSize
--)
505 *pDstBuffer
= *(__IO
uint32_t *)pSdramAddress
;
510 /* Process Unlocked */
511 __HAL_UNLOCK(hsdram
);
517 * @brief Writes 32-bit data buffer to SDRAM memory.
518 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
519 * the configuration information for SDRAM module.
520 * @param pAddress: Pointer to write start address
521 * @param pSrcBuffer: Pointer to source buffer to write
522 * @param BufferSize: Size of the buffer to write to memory
525 HAL_StatusTypeDef
HAL_SDRAM_Write_32b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pSrcBuffer
, uint32_t BufferSize
)
527 __IO
uint32_t *pSdramAddress
= (uint32_t *)pAddress
;
533 /* Check the SDRAM controller state */
536 if(tmp
== HAL_SDRAM_STATE_BUSY
)
540 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
545 /* Write data to memory */
546 for(; BufferSize
!= 0; BufferSize
--)
548 *(__IO
uint32_t *)pSdramAddress
= *pSrcBuffer
;
553 /* Process Unlocked */
554 __HAL_UNLOCK(hsdram
);
560 * @brief Reads a Words data from the SDRAM memory using DMA transfer.
561 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
562 * the configuration information for SDRAM module.
563 * @param pAddress: Pointer to read start address
564 * @param pDstBuffer: Pointer to destination buffer
565 * @param BufferSize: Size of the buffer to read from memory
568 HAL_StatusTypeDef
HAL_SDRAM_Read_DMA(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pDstBuffer
, uint32_t BufferSize
)
575 /* Check the SDRAM controller state */
578 if(tmp
== HAL_SDRAM_STATE_BUSY
)
582 else if(tmp
== HAL_SDRAM_STATE_PRECHARGED
)
587 /* Configure DMA user callbacks */
588 hsdram
->hdma
->XferCpltCallback
= HAL_SDRAM_DMA_XferCpltCallback
;
589 hsdram
->hdma
->XferErrorCallback
= HAL_SDRAM_DMA_XferErrorCallback
;
591 /* Enable the DMA Stream */
592 HAL_DMA_Start_IT(hsdram
->hdma
, (uint32_t)pAddress
, (uint32_t)pDstBuffer
, (uint32_t)BufferSize
);
594 /* Process Unlocked */
595 __HAL_UNLOCK(hsdram
);
601 * @brief Writes a Words data buffer to SDRAM memory using DMA transfer.
602 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
603 * the configuration information for SDRAM module.
604 * @param pAddress: Pointer to write start address
605 * @param pSrcBuffer: Pointer to source buffer to write
606 * @param BufferSize: Size of the buffer to write to memory
609 HAL_StatusTypeDef
HAL_SDRAM_Write_DMA(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pSrcBuffer
, uint32_t BufferSize
)
616 /* Check the SDRAM controller state */
619 if(tmp
== HAL_SDRAM_STATE_BUSY
)
623 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
628 /* Configure DMA user callbacks */
629 hsdram
->hdma
->XferCpltCallback
= HAL_SDRAM_DMA_XferCpltCallback
;
630 hsdram
->hdma
->XferErrorCallback
= HAL_SDRAM_DMA_XferErrorCallback
;
632 /* Enable the DMA Stream */
633 HAL_DMA_Start_IT(hsdram
->hdma
, (uint32_t)pSrcBuffer
, (uint32_t)pAddress
, (uint32_t)BufferSize
);
635 /* Process Unlocked */
636 __HAL_UNLOCK(hsdram
);
645 /** @defgroup SDRAM_Exported_Functions_Group3 Control functions
646 * @brief management functions
649 ==============================================================================
650 ##### SDRAM Control functions #####
651 ==============================================================================
653 This subsection provides a set of functions allowing to control dynamically
661 * @brief Enables dynamically SDRAM write protection.
662 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
663 * the configuration information for SDRAM module.
666 HAL_StatusTypeDef
HAL_SDRAM_WriteProtection_Enable(SDRAM_HandleTypeDef
*hsdram
)
668 /* Check the SDRAM controller state */
669 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
674 /* Update the SDRAM state */
675 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
677 /* Enable write protection */
678 FMC_SDRAM_WriteProtection_Enable(hsdram
->Instance
, hsdram
->Init
.SDBank
);
680 /* Update the SDRAM state */
681 hsdram
->State
= HAL_SDRAM_STATE_WRITE_PROTECTED
;
687 * @brief Disables dynamically SDRAM write protection.
688 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
689 * the configuration information for SDRAM module.
692 HAL_StatusTypeDef
HAL_SDRAM_WriteProtection_Disable(SDRAM_HandleTypeDef
*hsdram
)
694 /* Check the SDRAM controller state */
695 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
700 /* Update the SDRAM state */
701 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
703 /* Disable write protection */
704 FMC_SDRAM_WriteProtection_Disable(hsdram
->Instance
, hsdram
->Init
.SDBank
);
706 /* Update the SDRAM state */
707 hsdram
->State
= HAL_SDRAM_STATE_READY
;
713 * @brief Sends Command to the SDRAM bank.
714 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
715 * the configuration information for SDRAM module.
716 * @param Command: SDRAM command structure
717 * @param Timeout: Timeout duration
720 HAL_StatusTypeDef
HAL_SDRAM_SendCommand(SDRAM_HandleTypeDef
*hsdram
, FMC_SDRAM_CommandTypeDef
*Command
, uint32_t Timeout
)
722 /* Check the SDRAM controller state */
723 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
728 /* Update the SDRAM state */
729 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
731 /* Send SDRAM command */
732 FMC_SDRAM_SendCommand(hsdram
->Instance
, Command
, Timeout
);
734 /* Update the SDRAM controller state state */
735 if(Command
->CommandMode
== FMC_SDRAM_CMD_PALL
)
737 hsdram
->State
= HAL_SDRAM_STATE_PRECHARGED
;
741 hsdram
->State
= HAL_SDRAM_STATE_READY
;
748 * @brief Programs the SDRAM Memory Refresh rate.
749 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
750 * the configuration information for SDRAM module.
751 * @param RefreshRate: The SDRAM refresh rate value
754 HAL_StatusTypeDef
HAL_SDRAM_ProgramRefreshRate(SDRAM_HandleTypeDef
*hsdram
, uint32_t RefreshRate
)
756 /* Check the SDRAM controller state */
757 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
762 /* Update the SDRAM state */
763 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
765 /* Program the refresh rate */
766 FMC_SDRAM_ProgramRefreshRate(hsdram
->Instance
,RefreshRate
);
768 /* Update the SDRAM state */
769 hsdram
->State
= HAL_SDRAM_STATE_READY
;
775 * @brief Sets the Number of consecutive SDRAM Memory auto Refresh commands.
776 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
777 * the configuration information for SDRAM module.
778 * @param AutoRefreshNumber: The SDRAM auto Refresh number
781 HAL_StatusTypeDef
HAL_SDRAM_SetAutoRefreshNumber(SDRAM_HandleTypeDef
*hsdram
, uint32_t AutoRefreshNumber
)
783 /* Check the SDRAM controller state */
784 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
789 /* Update the SDRAM state */
790 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
792 /* Set the Auto-Refresh number */
793 FMC_SDRAM_SetAutoRefreshNumber(hsdram
->Instance
,AutoRefreshNumber
);
795 /* Update the SDRAM state */
796 hsdram
->State
= HAL_SDRAM_STATE_READY
;
802 * @brief Returns the SDRAM memory current mode.
803 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
804 * the configuration information for SDRAM module.
805 * @retval The SDRAM memory mode.
807 uint32_t HAL_SDRAM_GetModeStatus(SDRAM_HandleTypeDef
*hsdram
)
809 /* Return the SDRAM memory current mode */
810 return(FMC_SDRAM_GetModeStatus(hsdram
->Instance
, hsdram
->Init
.SDBank
));
817 /** @defgroup SDRAM_Exported_Functions_Group4 State functions
818 * @brief Peripheral State functions
821 ==============================================================================
822 ##### SDRAM State functions #####
823 ==============================================================================
825 This subsection permits to get in run-time the status of the SDRAM controller
833 * @brief Returns the SDRAM state.
834 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
835 * the configuration information for SDRAM module.
838 HAL_SDRAM_StateTypeDef
HAL_SDRAM_GetState(SDRAM_HandleTypeDef
*hsdram
)
840 return hsdram
->State
;
850 #endif /* HAL_SDRAM_MODULE_ENABLED */
859 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/