HAL XSPI Use Cases

User Application Starting a Write/Read in Memory-Mapped Mode for Octal PSRAM Memory

@startuml



== Initialization ==



"User Application"->"System" : HAL_Init()

"User Application"->"System" : SystemClock_Config()

note right: Configure system clock

"User Application"->" XSPI Driver" : HAL_XSPI_SetConfigIOManager

note right:I/O Manager config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM or HAL_ERROR

"User Application"->" XSPI Driver" : HAL_ XSPI_Init()

note right:  <b> Initialize the XSPI handle and associate an instance.\n <b>XSPI clock is enabled

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->"System" : XSPI HW Initialisation   

note right: ** Initialize GPIO**

"System" --> "User Application"



== Configuration ==



"User Application"->" XSPI Driver" : HAL_ XSPI_SetConfig

note right:Global config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->" XSPI Driver" : HAL_XSPI_OSPI_SetConfigDelay()

note right:Set delay block configuration

" XSPI Driver" --> "User Application":hal_status : HAL_OK or HAL_ERROR





"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:Program the Octal PSRAM to read/write

" XSPI Driver" --> "User Application" :hal_status : HAL_OK or HAL_ERROR



"User Application"->" XSPI Driver" :  HAL_XSPI_StartMemoryMappedMode()

note right: Enter the memory-mapped mode

" XSPI Driver" --> "User Application" 



== Process  ==



"User Application"->"System" :Read/Write 

note right: Read/Write from internal memory

"User Application" <-- "System" 



"User Application"->" XSPI Driver" :  HAL_XSPI_StopMemoryMappedMode()

note right: Exit the memory-mapped mode

" XSPI Driver" --> "User Application" 

@enduml

Functions called:

User Application Starting a Write/Read in Polling Mode for Regular Memory (Flash)

@startuml

== Initialization ==

"User Application"->"System" : HAL_Init()

"User Application"->"System" : SystemClock_Config()

note right: Configure system clock

"User Application"->" XSPI Driver" : HAL_XSPI_SetConfigIOManager

note right:I/O Manager config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM or HAL_ERROR

"User Application"->" XSPI Driver" : HAL_ XSPI_Init()

note right:  <b> Initialize the XSPI handle and associate an instance.\n <b>XSPI clock is enabled

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->"System" : XSPI HW Initialisation   

note right: ** Initialize GPIO**

"System" --> "User Application"



== Configuration ==

"User Application"->" XSPI Driver" : HAL_ XSPI_SetConfig

note right:Global config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->" XSPI Driver" : HAL_XSPI_OSPI_SetConfigDelay()

note right:Set delay block configuration

" XSPI Driver" --> "User Application":hal_status : HAL_OK or HAL_ERROR

== Process polling mode ==

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:Enable write operations

" XSPI Driver" --> "User Application" :hal_status : HAL_OK or HAL_ERROR

"User Application"->" XSPI Driver" :  HAL_XSPI_ExecuteRegularAutoPolling()

note right:Reconfigure XSPI to automatic polling mode to wait for write enabling

" XSPI Driver" --> "User Application": match completed

"User Application"->" XSPI Driver" :  HAL_XSPI_SetFifoThreshold()

note right:Configure the Fifo threshold

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

" XSPI Driver" --> "User Application" :hal_status : HAL_OK or HAL_ERROR

"User Application"->" XSPI Driver" :  HAL_XSPI_Transmit()

" XSPI Driver" --> "User Application" 

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

" XSPI Driver" --> "User Application" 

"User Application"->" XSPI Driver" :  HAL_XSPI_ExecuteRegularAutoPolling()

note right:Reconfigure XSPI to automatic polling mode to Wait end of operation

" XSPI Driver" --> "User Application": match completed

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

" XSPI Driver" --> "User Application" 

"User Application"->" XSPI Driver" :  HAL_XSPI_Receive()

" XSPI Driver" --> "User Application" 



@enduml

Functions called:

User Application Starting a Write/Read in Polling Mode for Hyperbus Memory (HyperRAM)

@startuml

== Initialization ==

"User Application"->"System" : HAL_Init()

"User Application"->"System" : SystemClock_Config()

note right: Configure system clock

"User Application"->" XSPI Driver" : HAL_XSPI_SetConfigIOManager

note right: I/O Manager config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM or HAL_ERROR

"User Application"->" XSPI Driver" : HAL_ XSPI_Init()

note right:  <b> Initialize the XSPI handle and associate an instance.\n <b>XSPI clock is enabled

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->"System" : XSPI HW Initialisation   

note right: ** Initialize GPIO**

"System" --> "User Application"



== Configuration ==

"User Application"->" XSPI Driver" : HAL_ XSPI_SetConfig

note right:Global config

" XSPI Driver" --> "User Application"



"User Application"->" XSPI Driver" : HAL_XSPI_OSPI_SetConfigDelay()

note right:Set delay block configuration

" XSPI Driver" --> "User Application":hal_status : HAL_OK or HAL_ERROR



== Process polling mode ==

"User Application"->" XSPI Driver" :  HAL_XSPI_SendHyperbusCmd()

" XSPI Driver" --> "User Application" 

"User Application"->" XSPI Driver" :  HAL_XSPI_Transmit()

" XSPI Driver" --> "User Application" 

"User Application"->" XSPI Driver" :  HAL_XSPI_SendHyperbusCmd()

" XSPI Driver" --> "User Application" 

"User Application"->" XSPI Driver" :  HAL_XSPI_Receive()

" XSPI Driver" --> "User Application" 



@enduml

Functions called:

User Application Starting a Write/Read in Interrupt Mode for Regular Memory (PSRAM)

@startuml

== Initialization ==

"User Application"->"System" : HAL_Init()

"User Application"->"System" : SystemClock_Config()

note right: Configure system clock

"User Application"->" XSPI Driver" : HAL_XSPI_SetConfigIOManager

note right:I/O Manager config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM or HAL_ERROR

"User Application"->" XSPI Driver" : HAL_ XSPI_Init()

note right:  <b> Initialize the XSPI handle and associate an instance.\n <b>XSPI clock is enabled

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->"System" : XSPI HW Initialisation   

note right: ** Initialize GPIO**

"System" --> "User Application"





== Configuration ==

"User Application"->" XSPI Driver" : HAL_ XSPI_SetConfig

note right:Global config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->" XSPI Driver" : HAL_XSPI_OSPI_SetConfigDelay()

note right:Set delay block configuration

" XSPI Driver" --> "User Application":hal_status : HAL_OK or HAL_ERROR

== Process interrupt mode ==

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd_IT()

note right:Reset command

"IRQHandler"<- : Interrupt

"IRQHandler" --> " XSPI Driver" : HAL_XSPI_IRQHandler(&hxspi)

" XSPI Driver"-->"User Application" : HAL_XSPI_CmdCpltCallback()





"User Application"->" XSPI Driver" :  HAL_XSPI_SetFifoThreshold()

" XSPI Driver" --> "User Application" :hal_status : HAL_OK or HAL_ERROR

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

" XSPI Driver" --> "User Application" : HAL_OK or HAL_ERROR



"User Application"->" XSPI Driver" :  HAL_XSPI_Transmit_IT()

"IRQHandler"<- : Interrupt

"IRQHandler" --> " XSPI Driver" : HAL_XSPI_IRQHandler(&hxspi)

" XSPI Driver"-->"User Application" : HAL_XSPI_TxCpltCallback()





"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

" XSPI Driver" --> "User Application" 



"User Application"->" XSPI Driver" :  HAL_XSPI_Receive_IT()

"IRQHandler"<- : Interrupt

"IRQHandler" --> " XSPI Driver" : HAL_XSPI_IRQHandler(&hxspi)

" XSPI Driver"-->"User Application" : HAL_XSPI_RxCpltCallback()



@enduml

Functions called:

User Application Starting a Write/Read in DMA Mode for Regular Memory (Flash)

@startuml



== Initialization ==



"User Application"->"System" : HAL_Init()

"User Application"->"System" : SystemClock_Config()

note right: Configure system clock

"User Application"->" XSPI Driver" : HAL_XSPI_SetConfigIOManager

note right:I/O Manager config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM or HAL_ERROR

"User Application"->" XSPI Driver" : HAL_ XSPI_Init()

note right:  <b> Initialize the XSPI handle and associate an instance.\n <b>XSPI clock is enabled

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->"System" : XSPI HW Initialisation   

note right: ** Initialize GPIO**

"System" --> "User Application"

"User Application"->"System" : HAL_XSPI_SetTxDMA()

note right: Link/store Tx HAL DMA handle into the HAL XSPI handle

"User Application" <-- "System" 

"User Application"->"System" : HAL_XSPI_SetRxDMA()

note right: Link/store Rx HAL DMA handle into the HAL XSPI handle

"User Application" <-- "System" 



== Configuration ==

"User Application"->" XSPI Driver" : HAL_ XSPI_SetConfig

note right: Global configuration

" XSPI Driver" --> "User Application" ::hal_status : HAL_OK or INVALID_PARAM

"User Application"->" XSPI Driver" : HAL_XSPI_OSPI_SetConfigDelay()

note right:Set delay block configuration

" XSPI Driver" --> "User Application":hal_status : HAL_OK or HAL_ERROR

== Process interrupt mode ==

 participant        "DMA Driver"     

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd_IT()

note right:Enable write operation

"IRQHandler"<- : Interrupt

"IRQHandler" --> " XSPI Driver" : HAL_XSPI_IRQHandler(&hxspi)

" XSPI Driver"-->"User Application" : HAL_XSPI_CmdCpltCallback()

"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:Reconfigure XSPI to AutoPolling mode to wait enabling write opertation

" XSPI Driver" --> "User Application" 



"User Application"->" XSPI Driver" :  HAL_XSPI_ExecuteRegularAutoPolling_IT()

"IRQHandler"<- : Interrupt

"IRQHandler" --> " XSPI Driver" : HAL_XSPI_IRQHandler(&hxspi)

" XSPI Driver"-->"User Application" : HAL_XSPI_StatusMatchCallback()





"User Application"->" XSPI Driver" :  HAL_XSPI_SetFifoThreshold()

" XSPI Driver" --> "User Application" :hal_status : HAL_OK or HAL_ERROR



== Process DMA mode ==



"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:ReConfigure write operation

" XSPI Driver" --> "User Application" 







"User Application"->" XSPI Driver" :  HAL_XSPI_Transmit_DMA()

note right: Start DMA channel transfer with interrupt enabled

"IRQHandler"<- : Interrupt



"DMA Driver"<--"IRQHandler":"HAL_DMA_IRQHandler(&hdma)"

"DMA Driver" --> " XSPI Driver" : DMA_Transfer_Complete

" XSPI Driver"-->"User Application" : HAL_XSPI_TxCpltCallback()



"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()





"User Application"->" XSPI Driver" :  HAL_XSPI_ExecuteRegularAutoPolling_IT()

note right: Reconfigure XSPI to AutoPolling mode to Wait end of operation

"IRQHandler"<- : Interrupt

"IRQHandler" --> " XSPI Driver" : HAL_XSPI_IRQHandler(&hxspi)

" XSPI Driver"-->"User Application" : HAL_XSPI_StatusMatchCallback()





"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:ReConfigure Read operation

" XSPI Driver" --> "User Application" 



"User Application"->" XSPI Driver" :  HAL_XSPI_Receive_DMA()

note right: Start DMA channel transfer with interrupt enabled

"IRQHandler"<- : Interrupt





"DMA Driver"<--"IRQHandler":"HAL_DMA_IRQHandler(&hdma)"

"DMA Driver" --> " XSPI Driver" : DMA_Transfer_Complete

" XSPI Driver"-->"User Application" : HAL_XSPI_RxCpltCallback()



@enduml

Functions called:

User Application Starting a Write/Read in DMA Mode for Regular Memory (PSRAM)

@startuml



== Initialization ==



"User Application"->"System" : HAL_Init()

"User Application"->"System" : SystemClock_Config()

note right: Configure system clock

"User Application"->" XSPI Driver" : HAL_XSPI_SetConfigIOManager

note right:I/O Manager config

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM or HAL_ERROR

"User Application"->" XSPI Driver" : HAL_ XSPI_Init()

note right:  <b> Initialize the XSPI handle and associate an instance.\n <b>XSPI clock is enabled

" XSPI Driver" --> "User Application":hal_status : HAL_OK or INVALID_PARAM

"User Application"->"System" : XSPI HW Initialisation   

note right: ** Initialize GPIO**

"System" --> "User Application"

"User Application"->"System" : HAL_XSPI_SetTxDMA()

note right: Link/store Tx HAL DMA handle into the HAL XSPI handle

"User Application" <-- "System" 

"User Application"->"System" : HAL_XSPI_SetRxDMA()

note right: Link/store Rx HAL DMA handle into the HAL XSPI handle

"User Application" <-- "System" 







== Configuration ==



"User Application"->" XSPI Driver" : HAL_ XSPI_SetConfig

note right: Global configuration

" XSPI Driver" --> "User Application" ::hal_status : HAL_OK or INVALID_PARAM

"User Application"->" XSPI Driver" : HAL_XSPI_OSPI_SetConfigDelay()

note right:Set delay block configuration

" XSPI Driver" --> "User Application":hal_status : HAL_OK or HAL_ERROR



== Process DMA mode ==



"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:Configure write operation

" XSPI Driver" --> "User Application" 



"User Application"->" XSPI Driver" :  HAL_XSPI_Transmit_DMA()

note right: Start DMA channel transfer with interrupt enabled

participant        "DMA Driver"       

"IRQHandler"<- : Interrupt

"DMA Driver"<--"IRQHandler":"HAL_DMA_IRQHandler(&hdma)"

"DMA Driver" --> " XSPI Driver" : DMA_Transfer_Complete

" XSPI Driver"-->"User Application" : HAL_XSPI_TxCpltCallback()





"User Application"->" XSPI Driver" :  HAL_XSPI_SendRegularCmd()

note right:ReConfigure Read operation

" XSPI Driver" --> "User Application" 



"User Application"->" XSPI Driver" :  HAL_XSPI_Receive_DMA()



note right: Start DMA channel transfer with interrupt enabled

"IRQHandler"<- : Interrupt

"DMA Driver"<--"IRQHandler":"HAL_DMA_IRQHandler(&hdma)"

"DMA Driver" --> " XSPI Driver" : DMA_Transfer_Complete

" XSPI Driver"-->"User Application" : HAL_XSPI_RxCpltCallback()



@enduml

Functions called: