2 ******************************************************************************
3 * @file stm32f4xx_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) 2014 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 "stm32f4xx_hal.h"
96 /** @addtogroup STM32F4xx_HAL_Driver
101 * @brief SDRAM driver modules
104 #ifdef HAL_SDRAM_MODULE_ENABLED
105 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
107 /* Private typedef -----------------------------------------------------------*/
108 /* Private define ------------------------------------------------------------*/
109 /* Private macro -------------------------------------------------------------*/
110 /* Private variables ---------------------------------------------------------*/
111 /* Private function prototypes -----------------------------------------------*/
113 /* Private functions ---------------------------------------------------------*/
115 /** @defgroup SDRAM_Private_Functions
119 /** @defgroup SDRAM_Group1 Initialization and de-initialization functions
120 * @brief Initialization and Configuration functions
123 ==============================================================================
124 ##### SDRAM Initialization and de_initialization functions #####
125 ==============================================================================
127 This section provides functions allowing to initialize/de-initialize
135 * @brief Performs the SDRAM device initialization sequence.
136 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
137 * the configuration information for SDRAM module.
138 * @param Timing: Pointer to SDRAM control timing structure
141 HAL_StatusTypeDef
HAL_SDRAM_Init(SDRAM_HandleTypeDef
*hsdram
, FMC_SDRAM_TimingTypeDef
*Timing
)
143 /* Check the SDRAM handle parameter */
144 if(hsdram
== HAL_NULL
)
149 if(hsdram
->State
== HAL_SDRAM_STATE_RESET
)
151 /* Initialize the low level hardware (MSP) */
152 HAL_SDRAM_MspInit(hsdram
);
155 /* Initialize the SDRAM controller state */
156 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
158 /* Initialize SDRAM control Interface */
159 FMC_SDRAM_Init(hsdram
->Instance
, &(hsdram
->Init
));
161 /* Initialize SDRAM timing Interface */
162 FMC_SDRAM_Timing_Init(hsdram
->Instance
, Timing
, hsdram
->Init
.SDBank
);
164 /* Update the SDRAM controller state */
165 hsdram
->State
= HAL_SDRAM_STATE_READY
;
171 * @brief Perform the SDRAM device initialization sequence.
172 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
173 * the configuration information for SDRAM module.
176 HAL_StatusTypeDef
HAL_SDRAM_DeInit(SDRAM_HandleTypeDef
*hsdram
)
178 /* Initialize the low level hardware (MSP) */
179 HAL_SDRAM_MspDeInit(hsdram
);
181 /* Configure the SDRAM registers with their reset values */
182 FMC_SDRAM_DeInit(hsdram
->Instance
, hsdram
->Init
.SDBank
);
184 /* Reset the SDRAM controller state */
185 hsdram
->State
= HAL_SDRAM_STATE_RESET
;
188 __HAL_UNLOCK(hsdram
);
194 * @brief SDRAM MSP Init.
195 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
196 * the configuration information for SDRAM module.
199 __weak
void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef
*hsdram
)
201 /* NOTE: This function Should not be modified, when the callback is needed,
202 the HAL_SDRAM_MspInit could be implemented in the user file
207 * @brief SDRAM MSP DeInit.
208 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
209 * the configuration information for SDRAM module.
212 __weak
void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef
*hsdram
)
214 /* NOTE: This function Should not be modified, when the callback is needed,
215 the HAL_SDRAM_MspDeInit could be implemented in the user file
220 * @brief This function handles SDRAM refresh error interrupt request.
221 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
222 * the configuration information for SDRAM module.
225 void HAL_SDRAM_IRQHandler(SDRAM_HandleTypeDef
*hsdram
)
227 /* Check SDRAM interrupt Rising edge flag */
228 if(__FMC_SDRAM_GET_FLAG(hsdram
->Instance
, FMC_SDRAM_FLAG_REFRESH_IT
))
230 /* SDRAM refresh error interrupt callback */
231 HAL_SDRAM_RefreshErrorCallback(hsdram
);
233 /* Clear SDRAM refresh error interrupt pending bit */
234 __FMC_SDRAM_CLEAR_FLAG(hsdram
->Instance
, FMC_SDRAM_FLAG_REFRESH_ERROR
);
239 * @brief SDRAM Refresh error callback.
240 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
241 * the configuration information for SDRAM module.
244 __weak
void HAL_SDRAM_RefreshErrorCallback(SDRAM_HandleTypeDef
*hsdram
)
246 /* NOTE: This function Should not be modified, when the callback is needed,
247 the HAL_SDRAM_RefreshErrorCallback could be implemented in the user file
252 * @brief DMA transfer complete callback.
253 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
254 * the configuration information for the specified DMA module.
257 __weak
void HAL_SDRAM_DMA_XferCpltCallback(DMA_HandleTypeDef
*hdma
)
259 /* NOTE: This function Should not be modified, when the callback is needed,
260 the HAL_SDRAM_DMA_XferCpltCallback could be implemented in the user file
265 * @brief DMA transfer complete error callback.
266 * @param hdma: DMA handle
269 __weak
void HAL_SDRAM_DMA_XferErrorCallback(DMA_HandleTypeDef
*hdma
)
271 /* NOTE: This function Should not be modified, when the callback is needed,
272 the HAL_SDRAM_DMA_XferErrorCallback could be implemented in the user file
280 /** @defgroup SDRAM_Group2 Input and Output functions
281 * @brief Input Output and memory control functions
284 ==============================================================================
285 ##### SDRAM Input and Output functions #####
286 ==============================================================================
288 This section provides functions allowing to use and control the SDRAM memory
295 * @brief Reads 8-bit data buffer from the SDRAM memory.
296 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
297 * the configuration information for SDRAM module.
298 * @param pAddress: Pointer to read start address
299 * @param pDstBuffer: Pointer to destination buffer
300 * @param BufferSize: Size of the buffer to read from memory
303 HAL_StatusTypeDef
HAL_SDRAM_Read_8b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint8_t *pDstBuffer
, uint32_t BufferSize
)
305 __IO
uint8_t *pSdramAddress
= (uint8_t *)pAddress
;
310 /* Check the SDRAM controller state */
311 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
315 else if(hsdram
->State
== HAL_SDRAM_STATE_PRECHARGED
)
320 /* Read data from source */
321 for(; BufferSize
!= 0; BufferSize
--)
323 *pDstBuffer
= *(__IO
uint8_t *)pSdramAddress
;
328 /* Process Unlocked */
329 __HAL_UNLOCK(hsdram
);
336 * @brief Writes 8-bit data buffer to SDRAM memory.
337 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
338 * the configuration information for SDRAM module.
339 * @param pAddress: Pointer to write start address
340 * @param pSrcBuffer: Pointer to source buffer to write
341 * @param BufferSize: Size of the buffer to write to memory
344 HAL_StatusTypeDef
HAL_SDRAM_Write_8b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint8_t *pSrcBuffer
, uint32_t BufferSize
)
346 __IO
uint8_t *pSdramAddress
= (uint8_t *)pAddress
;
352 /* Check the SDRAM controller state */
355 if(tmp
== HAL_SDRAM_STATE_BUSY
)
359 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
364 /* Write data to memory */
365 for(; BufferSize
!= 0; BufferSize
--)
367 *(__IO
uint8_t *)pSdramAddress
= *pSrcBuffer
;
372 /* Process Unlocked */
373 __HAL_UNLOCK(hsdram
);
380 * @brief Reads 16-bit data buffer from the SDRAM memory.
381 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
382 * the configuration information for SDRAM module.
383 * @param pAddress: Pointer to read start address
384 * @param pDstBuffer: Pointer to destination buffer
385 * @param BufferSize: Size of the buffer to read from memory
388 HAL_StatusTypeDef
HAL_SDRAM_Read_16b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint16_t *pDstBuffer
, uint32_t BufferSize
)
390 __IO
uint16_t *pSdramAddress
= (uint16_t *)pAddress
;
395 /* Check the SDRAM controller state */
396 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
400 else if(hsdram
->State
== HAL_SDRAM_STATE_PRECHARGED
)
405 /* Read data from source */
406 for(; BufferSize
!= 0; BufferSize
--)
408 *pDstBuffer
= *(__IO
uint16_t *)pSdramAddress
;
413 /* Process Unlocked */
414 __HAL_UNLOCK(hsdram
);
420 * @brief Writes 16-bit data buffer to SDRAM memory.
421 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
422 * the configuration information for SDRAM module.
423 * @param pAddress: Pointer to write start address
424 * @param pSrcBuffer: Pointer to source buffer to write
425 * @param BufferSize: Size of the buffer to write to memory
428 HAL_StatusTypeDef
HAL_SDRAM_Write_16b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint16_t *pSrcBuffer
, uint32_t BufferSize
)
430 __IO
uint16_t *pSdramAddress
= (uint16_t *)pAddress
;
436 /* Check the SDRAM controller state */
439 if(tmp
== HAL_SDRAM_STATE_BUSY
)
443 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
448 /* Write data to memory */
449 for(; BufferSize
!= 0; BufferSize
--)
451 *(__IO
uint16_t *)pSdramAddress
= *pSrcBuffer
;
456 /* Process Unlocked */
457 __HAL_UNLOCK(hsdram
);
463 * @brief Reads 32-bit data buffer from the SDRAM memory.
464 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
465 * the configuration information for SDRAM module.
466 * @param pAddress: Pointer to read start address
467 * @param pDstBuffer: Pointer to destination buffer
468 * @param BufferSize: Size of the buffer to read from memory
471 HAL_StatusTypeDef
HAL_SDRAM_Read_32b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pDstBuffer
, uint32_t BufferSize
)
473 __IO
uint32_t *pSdramAddress
= (uint32_t *)pAddress
;
478 /* Check the SDRAM controller state */
479 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
483 else if(hsdram
->State
== HAL_SDRAM_STATE_PRECHARGED
)
488 /* Read data from source */
489 for(; BufferSize
!= 0; BufferSize
--)
491 *pDstBuffer
= *(__IO
uint32_t *)pSdramAddress
;
496 /* Process Unlocked */
497 __HAL_UNLOCK(hsdram
);
503 * @brief Writes 32-bit data buffer to SDRAM memory.
504 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
505 * the configuration information for SDRAM module.
506 * @param pAddress: Pointer to write start address
507 * @param pSrcBuffer: Pointer to source buffer to write
508 * @param BufferSize: Size of the buffer to write to memory
511 HAL_StatusTypeDef
HAL_SDRAM_Write_32b(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pSrcBuffer
, uint32_t BufferSize
)
513 __IO
uint32_t *pSdramAddress
= (uint32_t *)pAddress
;
519 /* Check the SDRAM controller state */
522 if(tmp
== HAL_SDRAM_STATE_BUSY
)
526 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
531 /* Write data to memory */
532 for(; BufferSize
!= 0; BufferSize
--)
534 *(__IO
uint32_t *)pSdramAddress
= *pSrcBuffer
;
539 /* Process Unlocked */
540 __HAL_UNLOCK(hsdram
);
546 * @brief Reads a Words data from the SDRAM memory using DMA transfer.
547 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
548 * the configuration information for SDRAM module.
549 * @param pAddress: Pointer to read start address
550 * @param pDstBuffer: Pointer to destination buffer
551 * @param BufferSize: Size of the buffer to read from memory
554 HAL_StatusTypeDef
HAL_SDRAM_Read_DMA(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pDstBuffer
, uint32_t BufferSize
)
561 /* Check the SDRAM controller state */
564 if(tmp
== HAL_SDRAM_STATE_BUSY
)
568 else if(tmp
== HAL_SDRAM_STATE_PRECHARGED
)
573 /* Configure DMA user callbacks */
574 hsdram
->hdma
->XferCpltCallback
= HAL_SDRAM_DMA_XferCpltCallback
;
575 hsdram
->hdma
->XferErrorCallback
= HAL_SDRAM_DMA_XferErrorCallback
;
577 /* Enable the DMA Stream */
578 HAL_DMA_Start_IT(hsdram
->hdma
, (uint32_t)pAddress
, (uint32_t)pDstBuffer
, (uint32_t)BufferSize
);
580 /* Process Unlocked */
581 __HAL_UNLOCK(hsdram
);
587 * @brief Writes a Words data buffer to SDRAM memory using DMA transfer.
588 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
589 * the configuration information for SDRAM module.
590 * @param pAddress: Pointer to write start address
591 * @param pSrcBuffer: Pointer to source buffer to write
592 * @param BufferSize: Size of the buffer to write to memory
595 HAL_StatusTypeDef
HAL_SDRAM_Write_DMA(SDRAM_HandleTypeDef
*hsdram
, uint32_t *pAddress
, uint32_t *pSrcBuffer
, uint32_t BufferSize
)
602 /* Check the SDRAM controller state */
605 if(tmp
== HAL_SDRAM_STATE_BUSY
)
609 else if((tmp
== HAL_SDRAM_STATE_PRECHARGED
) || (tmp
== HAL_SDRAM_STATE_WRITE_PROTECTED
))
614 /* Configure DMA user callbacks */
615 hsdram
->hdma
->XferCpltCallback
= HAL_SDRAM_DMA_XferCpltCallback
;
616 hsdram
->hdma
->XferErrorCallback
= HAL_SDRAM_DMA_XferErrorCallback
;
618 /* Enable the DMA Stream */
619 HAL_DMA_Start_IT(hsdram
->hdma
, (uint32_t)pSrcBuffer
, (uint32_t)pAddress
, (uint32_t)BufferSize
);
621 /* Process Unlocked */
622 __HAL_UNLOCK(hsdram
);
631 /** @defgroup SDRAM_Group3 Control functions
632 * @brief management functions
635 ==============================================================================
636 ##### SDRAM Control functions #####
637 ==============================================================================
639 This subsection provides a set of functions allowing to control dynamically
647 * @brief Enables dynamically SDRAM write protection.
648 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
649 * the configuration information for SDRAM module.
652 HAL_StatusTypeDef
HAL_SDRAM_WriteProtection_Enable(SDRAM_HandleTypeDef
*hsdram
)
654 /* Check the SDRAM controller state */
655 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
660 /* Update the SDRAM state */
661 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
663 /* Enable write protection */
664 FMC_SDRAM_WriteProtection_Enable(hsdram
->Instance
, hsdram
->Init
.SDBank
);
666 /* Update the SDRAM state */
667 hsdram
->State
= HAL_SDRAM_STATE_WRITE_PROTECTED
;
673 * @brief Disables dynamically SDRAM write protection.
674 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
675 * the configuration information for SDRAM module.
678 HAL_StatusTypeDef
HAL_SDRAM_WriteProtection_Disable(SDRAM_HandleTypeDef
*hsdram
)
680 /* Check the SDRAM controller state */
681 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
686 /* Update the SDRAM state */
687 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
689 /* Disable write protection */
690 FMC_SDRAM_WriteProtection_Disable(hsdram
->Instance
, hsdram
->Init
.SDBank
);
692 /* Update the SDRAM state */
693 hsdram
->State
= HAL_SDRAM_STATE_READY
;
699 * @brief Sends Command to the SDRAM bank.
700 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
701 * the configuration information for SDRAM module.
702 * @param Command: SDRAM command structure
703 * @param Timeout: Timeout duration
706 HAL_StatusTypeDef
HAL_SDRAM_SendCommand(SDRAM_HandleTypeDef
*hsdram
, FMC_SDRAM_CommandTypeDef
*Command
, uint32_t Timeout
)
708 /* Check the SDRAM controller state */
709 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
714 /* Update the SDRAM state */
715 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
717 /* Send SDRAM command */
718 FMC_SDRAM_SendCommand(hsdram
->Instance
, Command
, Timeout
);
720 /* Update the SDRAM controller state state */
721 if(Command
->CommandMode
== FMC_SDRAM_CMD_PALL
)
723 hsdram
->State
= HAL_SDRAM_STATE_PRECHARGED
;
727 hsdram
->State
= HAL_SDRAM_STATE_READY
;
734 * @brief Programs the SDRAM Memory Refresh rate.
735 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
736 * the configuration information for SDRAM module.
737 * @param RefreshRate: The SDRAM refresh rate value
740 HAL_StatusTypeDef
HAL_SDRAM_ProgramRefreshRate(SDRAM_HandleTypeDef
*hsdram
, uint32_t RefreshRate
)
742 /* Check the SDRAM controller state */
743 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
748 /* Update the SDRAM state */
749 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
751 /* Program the refresh rate */
752 FMC_SDRAM_ProgramRefreshRate(hsdram
->Instance
,RefreshRate
);
754 /* Update the SDRAM state */
755 hsdram
->State
= HAL_SDRAM_STATE_READY
;
761 * @brief Sets the Number of consecutive SDRAM Memory auto Refresh commands.
762 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
763 * the configuration information for SDRAM module.
764 * @param AutoRefreshNumber: The SDRAM auto Refresh number
767 HAL_StatusTypeDef
HAL_SDRAM_SetAutoRefreshNumber(SDRAM_HandleTypeDef
*hsdram
, uint32_t AutoRefreshNumber
)
769 /* Check the SDRAM controller state */
770 if(hsdram
->State
== HAL_SDRAM_STATE_BUSY
)
775 /* Update the SDRAM state */
776 hsdram
->State
= HAL_SDRAM_STATE_BUSY
;
778 /* Set the Auto-Refresh number */
779 FMC_SDRAM_SetAutoRefreshNumber(hsdram
->Instance
,AutoRefreshNumber
);
781 /* Update the SDRAM state */
782 hsdram
->State
= HAL_SDRAM_STATE_READY
;
788 * @brief Returns the SDRAM memory current mode.
789 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
790 * the configuration information for SDRAM module.
791 * @retval The SDRAM memory mode.
793 uint32_t HAL_SDRAM_GetModeStatus(SDRAM_HandleTypeDef
*hsdram
)
795 /* Return the SDRAM memory current mode */
796 return(FMC_SDRAM_GetModeStatus(hsdram
->Instance
, hsdram
->Init
.SDBank
));
803 /** @defgroup SDRAM_Group4 State functions
804 * @brief Peripheral State functions
807 ==============================================================================
808 ##### SDRAM State functions #####
809 ==============================================================================
811 This subsection permits to get in run-time the status of the SDRAM controller
819 * @brief Returns the SDRAM state.
820 * @param hsdram: pointer to a SDRAM_HandleTypeDef structure that contains
821 * the configuration information for SDRAM module.
824 HAL_SDRAM_StateTypeDef
HAL_SDRAM_GetState(SDRAM_HandleTypeDef
*hsdram
)
826 return hsdram
->State
;
836 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
837 #endif /* HAL_SDRAM_MODULE_ENABLED */
846 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/