HAL SRAM How to Use ¶
- group SRAM_How_To_Use
-
How to use the SRAM HAL module driver ¶
The FMC SRAM main features : ¶
This SRAM HAL driver is a generic driver which contains a set of APIs used to configure the FMC SRAM sub-banks to interface with SRAM, PSRAM and CRAM memories.
The FMC SRAM peripheral supports the following read and write access modes :
-
SRAM memories :
-
Asynchronous read and asynchronous write with identical timing for both operations.
-
Asynchronous read and asynchronous write with distinct timing for each operation.
-
-
PSRAM/CRAM memories :
-
Asynchronous read and asynchronous write with identical timing for both operations.
-
Asynchronous read and asynchronous write with distinct timing for each operation.
-
Synchronous read and synchronous write.
-
Synchronous read and asynchronous write.
-
Asynchronous read and synchronous write.
-
The FMC SRAM peripheral supports the write protection feature.
The SRAM HAL driver can be used as follows : ¶
This module provides 5 different set of APIs that allows to :
-
Initialize and de-initialize the logical FMC SRAM object ( hal_sram_handle_t ) :
-
Initialize the logical FMC SRAM object and associate it to a physical instance (sub-bank). This functionality is ensured by HAL_SRAM_Init() function.
-
De-initialize the logical FMC SRAM object and disable the SRAM sub-bank. This functionality is ensured by HAL_SRAM_DeInit() function.
-
-
Configure the FMC SRAM to be ready to use and retrieve the current configuration :
-
Configure the FMC SRAM through three steps by following the order below :
-
Step 1 (FMC configuration) : is the first step to perform once the HAL SRAM driver is initialized. This functionality is ensured by HAL_SRAM_SetConfig() function.
At this stage, the SRAM is partially configured but not yet ready to use.
-
Step 2 (Memory configuration) : is the second step to perform once the FMC is initialized. This functionality is ensured by one of these 5 functions depending on the external device access mode :
-
HAL_SRAM_SetConfigRdWrAsyncMemory() function to set the configuration for memories with asynchronous read and asynchronous write access mode. This API sets identical timing for both access.
-
HAL_SRAM_SetWrAsyncTimings() function to be called after HAL_SRAM_SetConfigRdWrAsyncMemory() , when memory with asynchronous read and asynchronous write access mode requires a different timing configuration for write transactions.
-
HAL_SRAM_SetConfigRdWrSyncMemory() function to set the configuration for memories with synchronous read and synchronous write access mode.
-
HAL_SRAM_SetConfigRdSyncWrAsyncMemory() function to set the configuration for memories with synchronous read and asynchronous write access mode.
-
HAL_SRAM_SetConfigRdAsyncWrSyncMemory() function to set the configuration for memories with asynchronous read and synchronous write access mode.
At this stage, the SRAM is fully configured but not yet ready to use.
-
-
Step 3 (Memory enable/disable) : is the third step to perform once the SRAM is fully configured. This functionality is ensured by HAL_SRAM_EnableMemory() and HAL_SRAM_DisableMemory() functions.
-
HAL_SRAM_EnableMemory() : function to enable the SRAM sub-bank and make it accessible for read and write operations.
-
HAL_SRAM_DisableMemory() : function to disable the SRAM sub-bank which is useful when memory configuration adjustments are needed. After making the necessary adjustments, the HAL_SRAM_EnableMemory() must be recalled to enable the memory and make it accessible.
At this stage, the SRAM is fully configured, enabled and ready for use.
-
-
-
Retrieve the current configuration through the following functions :
-
Retrieve the FMC configuration : This functionality is ensured by HAL_SRAM_GetConfig() .
-
Retrieve the memory configuration : This functionality is ensured by one of these 5 functions depending on the external device access mode :
-
HAL_SRAM_GetConfigRdWrAsyncMemory() function to get the memory configuration for memories with asynchronous read and asynchronous write access mode.
-
HAL_SRAM_GetWrAsyncTimings() function to get the timing configuration for write operations, when the memory with asynchronous read and asynchronous write access mode has a different timing configuration for write transactions.
-
HAL_SRAM_GetConfigRdWrSyncMemory() function to get the memory configuration for memories with synchronous read and synchronous write access mode.
-
HAL_SRAM_GetConfigRdSyncWrAsyncMemory() function to get the memory configuration for memories with synchronous read and asynchronous write access mode.
-
HAL_SRAM_GetConfigRdAsyncWrSyncMemory() function to get the memory configuration for memories with asynchronous read and synchronous write access mode.
-
-
-
-
Manage the FMC SRAM peripheral access when it is fully configured :
-
Enable the FMC SRAM write protection (when disabled) to prevent any write access to the external device. This functionality is ensured by HAL_SRAM_EnableWriteProtection() function.
-
Disable the FMC SRAM write protection (when enabled) to allow any write access to the external device. This functionality is ensured by HAL_SRAM_DisableWriteProtection() function.
-
Retrieve the FMC SRAM sub-bank write protection state. This functionality is ensured by HAL_SRAM_IsEnabledWriteProtection() function.
-
Enable the FMC SRAM sub-bank (when disabled). This functionality is ensured by HAL_SRAM_Enable() function.
-
Disable the FMC SRAM sub-bank (when enabled). This functionality is ensured by HAL_SRAM_Disable() function.
-
Retrieve the FMC SRAM sub-bank state. This functionality is ensured by HAL_SRAM_IsEnabled() function.
-
-
Store and retrieve user data :
-
Store user data pointer into the handle. This functionality is ensured by HAL_SRAM_SetUserData() function.
-
Retrieve user data pointer from the handle. This functionality is ensured by HAL_SRAM_GetUserData() function.
-
-
Retrieve the HAL SRAM state and clock frequency :
-
Retrieve the HAL SRAM state. This functionality is ensured by HAL_SRAM_GetState() function.
-
Retrieve the clock frequency. This functionality is ensured by HAL_SRAM_GetClockFreq() function.
-
-
The read and write process must be managed within the application side (outside the HAL SRAM module) after fully configuring the FMC SRAM.
-