Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
cubexHal.pdf
Скачиваний:
111
Добавлен:
10.02.2016
Размер:
16.16 Mб
Скачать

HAL SDRAM Generic Driver

UM1725

52 HAL SDRAM Generic Driver

52.1SDRAM Firmware driver registers structures

52.1.1SDRAM_HandleTypeDef

Data Fields

FMC_SDRAM_TypeDef * Instance

FMC_SDRAM_InitTypeDef Init

__IO HAL_SDRAM_StateTypeDef State

HAL_LockTypeDef Lock

DMA_HandleTypeDef * hdma

Field Documentation

FMC_SDRAM_TypeDef* SDRAM_HandleTypeDef::Instance

Register base address

FMC_SDRAM_InitTypeDef SDRAM_HandleTypeDef::Init

SDRAM device configuration parameters

__IO HAL_SDRAM_StateTypeDef SDRAM_HandleTypeDef::State

SDRAM access state

HAL_LockTypeDef SDRAM_HandleTypeDef::Lock

SDRAM locking object

DMA_HandleTypeDef* SDRAM_HandleTypeDef::hdma

Pointer DMA handler

52.2SDRAM Firmware driver API description

52.2.1How to use this driver

This driver is a generic layered driver which contains a set of APIs used to control SDRAM memories. It uses the FMC layer functions to interface with SDRAM devices. The following sequence should be followed to configure the FMC to interface with SDRAM memories:

1.Declare a SDRAM_HandleTypeDef handle structure, for example: SDRAM_HandleTypeDef hdsram

Fill the SDRAM_HandleTypeDef handle "Init" field with the allowed values of the structure member.

Fill the SDRAM_HandleTypeDef handle "Instance" field with a predefined base register instance for NOR or SDRAM device

2.Declare a FMC_SDRAM_TimingTypeDef structure; for example:

FMC_SDRAM_TimingTypeDef Timing; and fill its fields with the allowed values of the structure member.

3. Initialize the SDRAM Controller by calling the function HAL_SDRAM_Init(). This function performs the following sequence:

a.MSP hardware layer configuration using the function HAL_SDRAM_MspInit()

b.Control register configuration using the FMC SDRAM interface function FMC_SDRAM_Init()

688/900

DOCID025834 Rev 2

UM1725

HAL SDRAM Generic Driver

c.Timing register configuration using the FMC SDRAM interface function FMC_SDRAM_Timing_Init()

d.Program the SDRAM external device by applying its initialization sequence according to the device plugged in your hardware. This step is mandatory for accessing the SDRAM device.

4.At this stage you can perform read/write accesses from/to the memory connected to the SDRAM Bank. You can perform either polling or DMA transfer using the following APIs:

HAL_SDRAM_Read()/HAL_SDRAM_Write() for polling read/write access

HAL_SDRAM_Read_DMA()/HAL_SDRAM_Write_DMA() for DMA read/write transfer

5.You can also control the SDRAM device by calling the control APIs

HAL_SDRAM_WriteOperation_Enable()/ HAL_SDRAM_WriteOperation_Disable() to respectively enable/disable the SDRAM write operation or the function HAL_SDRAM_SendCommand() to send a specified command to the SDRAM device. The command to be sent must be configured with the FMC_SDRAM_CommandTypeDef structure.

6. You can continuously monitor the SDRAM device HAL state by calling the function HAL_SDRAM_GetState()

52.2.2SDRAM Initialization and de_initialization functions

This section provides functions allowing to initialize/de-initialize the SDRAM memory

This section contains the following APIs:

HAL_SDRAM_Init()

HAL_SDRAM_DeInit()

HAL_SDRAM_MspInit()

HAL_SDRAM_MspDeInit()

HAL_SDRAM_IRQHandler()

HAL_SDRAM_RefreshErrorCallback()

HAL_SDRAM_DMA_XferCpltCallback()

HAL_SDRAM_DMA_XferErrorCallback()

52.2.3SDRAM Input and Output functions

This section provides functions allowing to use and control the SDRAM memory

This section contains the following APIs:

HAL_SDRAM_Read_8b()

HAL_SDRAM_Write_8b()

HAL_SDRAM_Read_16b()

HAL_SDRAM_Write_16b()

HAL_SDRAM_Read_32b()

HAL_SDRAM_Write_32b()

HAL_SDRAM_Read_DMA()

HAL_SDRAM_Write_DMA()

52.2.4SDRAM Control functions

This subsection provides a set of functions allowing to control dynamically the SDRAM interface.

This section contains the following APIs:

HAL_SDRAM_WriteProtection_Enable()

DOCID025834 Rev 2

689/900

HAL SDRAM Generic Driver

UM1725

HAL_SDRAM_WriteProtection_Disable()

HAL_SDRAM_SendCommand()

HAL_SDRAM_ProgramRefreshRate()

HAL_SDRAM_SetAutoRefreshNumber()

HAL_SDRAM_GetModeStatus()

52.2.5SDRAM State functions

This subsection permits to get in run-time the status of the SDRAM controller and the data flow.

This section contains the following APIs:

HAL_SDRAM_GetState()

52.2.6HAL_SDRAM_Init

Function Name

HAL_StatusTypeDef HAL_SDRAM_Init

 

(SDRAM_HandleTypeDef * hsdram,

 

FMC_SDRAM_TimingTypeDef * Timing)

Function Description

Performs the SDRAM device initialization sequence.

Parameters

 

hsdram: pointer to a SDRAM_HandleTypeDef structure that

 

 

contains the configuration information for SDRAM module.

 

Timing: Pointer to SDRAM control timing structure

Return values

 

HAL status

52.2.7HAL_SDRAM_DeInit

Function Name

HAL_StatusTypeDef HAL_SDRAM_DeInit

 

(SDRAM_HandleTypeDef * hsdram)

Function Description

Perform the SDRAM device initialization sequence.

Parameters

 

hsdram: pointer to a SDRAM_HandleTypeDef structure that

 

 

contains the configuration information for SDRAM module.

Return values

 

HAL status

52.2.8HAL_SDRAM_MspInit

Function Name

void HAL_SDRAM_MspInit (SDRAM_HandleTypeDef *

 

hsdram)

Function Description

SDRAM MSP Init.

Parameters

 

hsdram: pointer to a SDRAM_HandleTypeDef structure that

 

 

contains the configuration information for SDRAM module.

Return values

 

None

52.2.9HAL_SDRAM_MspDeInit

Function Name

void HAL_SDRAM_MspDeInit (SDRAM_HandleTypeDef *

 

hsdram)

Function Description

SDRAM MSP DeInit.

Parameters

hsdram: pointer to a SDRAM_HandleTypeDef structure that

690/900

DOCID025834 Rev 2

UM1725

HAL SDRAM Generic Driver

 

contains the configuration information for SDRAM module.

Return values

None

52.2.10HAL_SDRAM_IRQHandler

Function Name

void HAL_SDRAM_IRQHandler (SDRAM_HandleTypeDef *

 

hsdram)

Function Description

This function handles SDRAM refresh error interrupt request.

Parameters

 

hsdram: pointer to a SDRAM_HandleTypeDef structure that

 

 

contains the configuration information for SDRAM module.

Return values

 

HAL status

52.2.11HAL_SDRAM_RefreshErrorCallback

Function Name

void HAL_SDRAM_RefreshErrorCallback

 

(SDRAM_HandleTypeDef * hsdram)

Function Description

SDRAM Refresh error callback.

Parameters

 

hsdram: pointer to a SDRAM_HandleTypeDef structure that

 

 

contains the configuration information for SDRAM module.

Return values

 

None

52.2.12HAL_SDRAM_DMA_XferCpltCallback

Function Name

void HAL_SDRAM_DMA_XferCpltCallback

 

(DMA_HandleTypeDef * hdma)

Function Description

DMA transfer complete callback.

Parameters

 

hdma: pointer to a DMA_HandleTypeDef structure that

 

 

contains the configuration information for the specified DMA

 

 

module.

Return values

 

None

52.2.13HAL_SDRAM_DMA_XferErrorCallback

Function Name

void HAL_SDRAM_DMA_XferErrorCallback

 

(DMA_HandleTypeDef * hdma)

Function Description

DMA transfer complete error callback.

Parameters

 

hdma: DMA handle

Return values

 

None

52.2.14HAL_SDRAM_Read_8b

Function Name

HAL_StatusTypeDef HAL_SDRAM_Read_8b

 

 

(SDRAM_HandleTypeDef * hsdram, uint32_t * pAddress,

 

uint8_t * pDstBuffer, uint32_t BufferSize)

 

Function Description

Reads 8-bit data buffer from the SDRAM memory.

 

Parameters

hsdram: pointer to a SDRAM_HandleTypeDef structure that

 

contains the configuration information for SDRAM module.

 

DOCID025834 Rev 2

691/900

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]