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_SetConfigxxxMemory()

note right: Configure the memory and one of 4 timing API depending on the user case  

"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 or HAL_INVALID_PARAM

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_SetConfigxxxMemory()

note right: ** Adjust the timing configuration

"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_Disable() 

note right: ** Disable the corresponding SRAM sub-bank to save power and maintain the current configuration

"User Application"->"HAL SRAM Driver" : HAL_SRAM_Enable() 

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_Disable() 

note right: Disable the corresponding SRAM sub-bank to save power and maintain the current configuration

"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_SetConfigxxxMemory(&hsramx, &memory_config)

note right: Configure the memory and one of 4 timing API depending on the user case

"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: