HAL SRAM Use Cases

Initialization and Configuration

@startuml

== Initialization ==

"User Application"->"HAL SRAM Driver" : HAL_SRAM_Init()
note right:  <b> Initialize the SRAM handle and associate an instance.\n <b>FMC clock is enabled in HAL_SRAM_Init when USE_FMC_CLK_ENABLE_MODEL is set to HAL_CLK_ENABLE_PERIPH_ONLY 
"HAL SRAM Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM
note right: Return 

"User Application"->"System" : SRAM HW Initialisation   
note right: Initialize GPIO
"System" --> "User Application"

== Configuration == 

"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetConfig()
note right: static configuration of FMC peripheral
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return

"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetConfigRdWrAsyncMemory()
note right: Asynchronous memory configuration\n HAL_SRAM_SetConfigRdWrSyncMemory for Synchronous memory configuration\n HAL_SRAM_SetConfigRdSyncWrAsyncMemory for Synchronous Read and Asynchronous Write memory configuration\n HAL_SRAM_SetConfigRdAsyncWrSyncMemory for Asynchronous Read and Synchronous Write memory configuration\n
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return

group #LightBlue Optional: Different timing for the write transactions is needed for read and write asynchronous access
"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetWrAsyncTimings()
note right: set different timing of Write transactions and set the extended mode.
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return
end

"User Application"->"HAL SRAM Driver" : HAL_SRAM_EnableMemory()
note right: Enable the SRAM sub-banks.
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK
note right: return

@enduml

Called functions:

Read/Write Operation

@startuml

==Prerequisite: Initialization and configuration ==

== Process == 
"User Application"->"User Application" : Write user operations
note right: Write buffer to the sram memory

"User Application"->"User Application" : Read user operations
note right: Read buffer from the sram memory

@enduml

Timing Configuration Adjustment

@startuml

==Prerequisite: Initialization and configuration == 

== Process == 
"User Application"->"User Application" : User write operations
note right: Write user operation failed due to wrong timing configuration
"User Application"->"HAL SRAM Driver" : HAL_SRAM_DisableMemory() 
note right: Disable the memory to adjust timing configuration
"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetConfigRdWrAsyncMemory()
note right: Asynchronous memory configuration\n HAL_SRAM_SetConfigRdWrSyncMemory for Synchronous memory configuration\n HAL_SRAM_SetConfigRdSyncWrAsyncMemory for Synchronous Read and Asynchronous Write memory configuration\n HAL_SRAM_SetConfigRdAsyncWrSyncMemory for Asynchronous Read and Synchronous Write memory configuration\n
group #LightBlue Optional: Different timing for the write transactions is needed for read and write asynchronous access
"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetWrAsyncTimings()
note right: set different timing of Write transactions and set the extended mode.
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return
end
"User Application"->"HAL SRAM Driver" : HAL_SRAM_EnableMemory() 
note right: Enable the corresponding SRAM sub-bank
"User Application"->"User Application" : User write operations
note right: Write user operation completed successfully


@enduml

Called functions:

Disable Unused Memory

@startuml

==Prerequisite: Initialization and configuration == 

== Process == 
"User Application"->"User Application" : User write operations
note right: Write user operations
"User Application"->"HAL SRAM Driver" : HAL_SRAM_DisableMemory() 
note right: Disable the corresponding SRAM sub-bank to save power, with the option to reconfigure the current settings
"User Application"->"HAL SRAM Driver" : HAL_SRAM_EnableMemory()
note right: Enable the corresponding SRAM sub-bank to prepare it for a write operation, ensuring it is active and ready to receive and store data accurately
"User Application"->"User Application" : User write operations
note right: Write user operations

@enduml

Called functions:

Starting a Write Operation with Write Protection Enabled

@startuml

==Prerequisite: Initialization and configuration ==

== Process == 
"User Application"->"HAL SRAM Driver" : HAL_SRAM_EnableWriteProtection() 
note right: Enable the Write protection in the corresponding SRAM sub-bank to prevent any write access
"User Application"->"User Application" : User write operations
note right: Write user operations
"HW"-->"User Application" : Hardfault
note right: Accessing a bank with write protection enabled causes an ERROR on AHB bus

@enduml

Called functions:

Starting a Read/Write Operation within a Disabled Bank

@startuml

==Prerequisite: Initialization and configuration ==

== Process == 
"User Application"->"HAL SRAM Driver" : HAL_SRAM_DisableMemory() 
note right: Disable the corresponding SRAM sub-bank to save power, with the option to reconfigure the current settings
"User Application"->"User Application" : User Read/write operations
note right: Read/Write user operations
"HW"-->"User Application" : Hardfault
note right: Accessing  a disabled bank causes an ERROR on AHB bus


@enduml

Called functions:

Starting Read/Write Operations in All SRAM Sub-banks

@startuml


title <size:18><color:Red> All SRAM sub-banks must be configured before starting any SRAM sub-bank process \n\n


== Initialization ==

group SRAM sub-banks Initialization SRAMx  (x = 1 to 4)
"User Application"->"HAL SRAM Driver" : HAL_SRAM_Init(&hsramx, HAL_SRAMx)
note right:  <b> Initialize the SRAM handle and associate to the HAL_SRAMx instance.\n <b>FMC clock is enabled in HAL_SRAM_Init when USE_FMC_CLK_ENABLE_MODEL is set to HAL_CLK_ENABLE_PERIPH_ONLY 
"HAL SRAM Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM
note right: Return
end

"User Application"->"System" : SRAM HW Initialisation   
note right: Initialize GPIO
"System" --> "User Application"

== Configuration == 
group SRAM sub-banks configuration SRAMx (x = 1 to 4)
"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetConfig(&hsramx, &config)
note right:  static configuration of FMC peripheral
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return

"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetConfigRdWrAsyncMemory(&hsramx, &memory_config)
note right: Asynchronous memory configuration\n HAL_SRAM_SetConfigRdWrSyncMemory for Synchronous memory configuration\n HAL_SRAM_SetConfigRdSyncWrAsyncMemory for Synchronous Read and Asynchronous Write memory configuration\n HAL_SRAM_SetConfigRdAsyncWrSyncMemory for Asynchronous Read and Synchronous Write memory configuration\n
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return

group #LightBlue Optional: Different timing for the write transactions is needed for read and write asynchronous access
"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetWrAsyncTimings(&hsramx, &timings)
note right: set different timing of Write transactions and set the extended mode.
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return
end
"User Application"->"HAL SRAM Driver" : HAL_SRAM_EnableMemory(&hsramx)
note right: Enable the SRAM sub-bank x.
"HAL SRAM Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM
note right: return
end


== Process == 
group SRAM sub-banks Read/Write SRAMx (x = 1 to 4)
"User Application"->"User Application" : User Read/write operations
note right: Read/Write user operations for configured SRAM sub-bank x
end

@enduml

Called functions:

#if defined(GENERATOR_FMC2_IPVx) || defined(GENERATOR_FMC3_IPVx) Remap region **********************


@startuml
== Initialization ==
"User Application"->"HAL SRAM Driver" : HAL_SRAM_Init()
note right:  <b> Initialize the SRAM handle and associate an instance.\n <b>FMC clock is enabled in HAL_SRAM_Init when USE_FMC_CLK_ENABLE_MODEL is set to HAL_CLK_ENABLE_PERIPH_ONLY 
"HAL SRAM Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM
note right: Return 

"User Application"->"System" : SRAM HW Initialization   
note right: Initialize GPIO
"System" --> "User Application"

"System" --> "User Application"
group #LightBlue Optional: FMC region remap (after initialization)
"User Application"->"HAL SRAM Driver" : HAL_SRAM_SetRegionRemap(&hsram, remap_apply)
"HAL SRAM Driver" --> "User Application" : HAL_OK
"User Application"->"HAL SRAM Driver" : remap_readback = HAL_SRAM_GetRegionRemap(&hsram)
end
== Configuration ==
== Process ==
group #LightBlue Optional: Use base resolver under active remap
"User Application"->"HAL SRAM Driver" : base = HAL_SRAM_GetRegionBaseAddress(&hsram)
end
"User Application"->"User Application" : User Read/Write operations
@enduml

Called functions:

#endif