HAL NOR Use Cases

Initialization and Configuration

@startuml



== Initialization ==

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

note right: **  Configure the Flash prefetch, the time base source and the NVIC **

"System" --> "User Application": hal status : HAL_OK or HAL_ERROR

note right: ** Return **



"User Application"->"System" : SystemClock_Config

note right: ** Configure system clock**

"System" --> "User Application"



"User Application"->"HAL NOR Driver" : HAL_NOR_Init()

note right

  <b>Initialize the NOR handle and associate an instance.

  <b>FMC clock is enabled in HAL_NOR_Init when USE_FMC_CLK_ENABLE_MODEL is set to HAL_CLK_ENABLE_FMC_ONLY.

  <b>Otherwise, it can be enabled outside using HAL RCC API at the application level.

end note



"HAL NOR Driver" --> "User Application" : hal status : HAL_OK or HAL_INVALID_PARAM

note right: ** Return **



"User Application"->"System" : NOR HW Initialization   

note right: ** Initialize GPIO**

"System" --> "User Application"



== Configuration == 



"User Application"->"HAL NOR Driver" : HAL_NOR_SetConfigMemory()

note right: ** Memory configuration **

"HAL NOR Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

note right: ** Return **



"User Application"->"HAL NOR Driver" : HAL_NOR_SetxxxTimings() 

note right: ** One of the 3 Timing configuration API depending on the user case **

"HAL NOR Driver" --> "User Application": hal status : HAL_OK or HAL_INVALID_PARAM

note right: ** Return **









@enduml

Called functions:

Valid Write and Read Operations in NOR Memory

@startuml



== Prerequisite: Initialisation and configuration ==



== Process == 

"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Program()

note right: ** Write data in NOR memory **

"HAL NOR Driver"->"User Application": hal_status : HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return the status of the NOR write operation **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_ReadArray()

note right: ** Read data from NOR memory **

"HAL NOR Driver"->"User Application" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



@enduml

Called functions:

  • HAL_NOR_CFI_xxxx_Program()

  • HAL_NOR_CFI_xxxx_ReadArray()

Invalid Write and Read Operations in NOR Memory

@startuml



== Prerequisite: Initialisation and configuration ==



== Process == 

"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Program()

note right: ** Write data in NOR memory **

"HAL NOR Driver"->"User Application": hal_status : HAL_TIMEOUT or HAL_ERROR

note right: ** NOR program processing encoutred an unrecoverable error **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Reset()

note right: ** Software reset when program or erase was not successfully completed to reset errors **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_ReadArray()

note right: ** Read data from NOR memory after **

"HAL NOR Driver"->"User Application" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **

@enduml

Called functions:

  • HAL_NOR_CFI_xxxx_Program()

  • HAL_NOR_CFI_xxxx_Reset()

  • HAL_NOR_CFI_xxxx_ReadArray()

Read CFI Information from NOR Flash Memory

@startuml



== Prerequisite: Initialisation and configuration ==



== Process == 

"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_ReadDeviceInfo()

note right: ** Read CFI info **

"HAL NOR Driver"->"User Application": hal_status : HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Reset()

note right: ** Software reset to return the device to read mode **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_ReadArray()

note right: ** Read data from NOR memory **

"HAL NOR Driver"->"User Application" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



@enduml

Called functions:

Write in a Locked Block

@startuml



== Prerequisite: Initialisation and configuration ==



== Process == 

"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_LockBlock()

note right: ** The block is locked, no program or erase operation can be performed **

"HAL NOR Driver"->"User Application": hal_status : HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Program()

note right: ** Write data in the locked block **

"HAL NOR Driver"->"User Application" : hal_status: HAL_ERROR

note right: ** Any Program or Erase operations attempted on a locked block will return an error **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Reset()

note right: ** Software reset when program or erase was not successfully completed **





"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxxx_UnLockBlock()

note right: ** Unlock the locked block **

"HAL NOR Driver"->"User Application": hal_status : HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



"User Application"->"HAL NOR Driver" : HAL_NOR_CFI_xxxx_Program()

note right: ** Write data in the unlocked block **

"HAL NOR Driver"->"User Application" : hal_status: HAL_OK or HAL_BUSY

note right: ** The write data in the NOR memory is performed successfully **



@enduml

Called functions:

  • HAL_NOR_CFI_xxxx_LockBlock()

  • HAL_NOR_CFI_xxxx_Program()

  • HAL_NOR_CFI_xxxx_Reset()

  • HAL_NOR_CFI_xxxxx_UnLockBlock()

  • HAL_NOR_CFI_xxxx_Program()

Suspend a Program Operation

@startuml



participant "User Application" as part1

participant "System"           as part2

participant "HAL NOR Driver"   as part3

participant "HAL EXTI Driver"  as part4

participant "EXTI_IRQHandler"  as part5

participant "STM32 HW"         as part6



== Prerequisite: Initialisation and configuration ==



== Process == 

"part1"->"part3" : HAL_NOR_CFI_xxxx_Program()

note right: ** Write data in NOR memory **



"part6" -> "part5" : Interrupt

note right: ** Interrupt the NOR flash programming **



"part5" -> "part4" : HAL_EXTI_IRQHandler()

note right: ** Call the IRQ Handler to manage the interrupt **



"part4" -> "part1" : User callback()

note right: ** Call the callback **

group User callback

"part1"->"part3" : HAL_NOR_CFI_0001_ProgramSuspend()

note right: ** Suspend the programming operation **



"part1"->"part3" : HAL_NOR_CFI_xxxx_ReadArray()

note right: ** Read data from NOR memory **

"part3"->"part1" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



"part1"->"part3" : HAL_NOR_CFI_0001_ProgramResume()

note right: ** Resume the programming operation **



end

"part3"->"part1" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** The callback execution is finished, the HAL_NOR_CFI_xxxx_Program() process is proceeded **



@enduml

Called functions:

Suspend an Erase Operation

@startuml



participant "User Application" as part1

participant "System"           as part2

participant "HAL NOR Driver"   as part3

participant "HAL EXTI Driver"  as part4

participant "EXTI_IRQHandler"  as part5

participant "STM32 HW"         as part6



== Prerequisite: Initialisation and configuration ==



== Process == 

"part1"->"part3" : HAL_NOR_CFI_xxxx_BlockErase()

note right: ** Erase a block in NOR memory **



"part6" -> "part5" : Interrupt

note right: ** Interrupt the NOR flash programming **



"part5" -> "part4" : HAL_EXTI_IRQHandler()

note right: ** Call the IRQ Handler to manage the interrupt **



"part4" -> "part1" : User callback()

note right: ** Call the callback **

group User callback

"part1"->"part3" : HAL_NOR_CFI_0001_EraseSuspend()

note right: ** Suspend the erase operation **



"part1"->"part3" : HAL_NOR_CFI_xxxx_ReadArray()

note right: ** Read data from NOR memory **

"part3"->"part1" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** Return **



"part1"->"part3" : HAL_NOR_CFI_0001_EraseResume()

note right: ** Resume the erase operation **



end

"part3"->"part1" : hal_status: HAL_OK or HAL_BUSY or HAL_INVALID_PARAM

note right: ** The callback execution is finished, the HAL_NOR_CFI_xxxx_BlockErase() process is proceeded **



@enduml

Called functions: