HAL FLASH Use Cases

User application program in polling mode

@startuml
hide footbox
participant "User Application" as part1
participant "System"           as part2
participant "FLASH IO Driver"  as part3
participant "FLASH ITF Driver" as part4

group #LimeGreen Initialization
   part1->part2 : HAL_Init()
   part1->part2 : System clock configuration
   note right: The FLASH latency is updated according to bus frequency within clock configuration
   part1->part3 : HAL_FLASH_Init()
   note right: The FLASH Clock is enabled optionally when the\nUSE_HAL_FLASH_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO
end

group #LimeGreen FLASH ITF Unlock
   part1->part4 : HAL_FLASH_ITF_Unlock()
end

group #FBF8B4 FLASH Configuration (optional)
      part1->part3 : HAL_FLASH_SetProgrammingMode()
end

group #LimeGreen FLASH Program operation
   part1->part3 : HAL_FLASH_ProgramByAddr()
end

group #LimeGreen FLASH ITF Lock
   part1->part4 : HAL_FLASH_ITF_Lock()
end

group #LimeGreen FLASH De-initialization
   part1->part3 : HAL_FLASH_DeInit()
end
@enduml

Called functions:

User application program in interrupt mode

@startuml
hide footbox
participant "User Application" as part1
participant "System"           as part2
participant "FLASH IO Driver"  as part3
participant "FLASH ITF Driver" as part4
participant "CORTEX Driver"    as part5
participant "NVIC"             as part6
participant "HW"               as part7

group #LimeGreen Initialization
   part1->part2 : HAL_Init()
   part1->part2 : System clock configuration
   note right: The FLASH latency is updated according to bus frequency within clock configuration
   part1->part3 : HAL_FLASH_Init()
   note right: The FLASH Clock is enabled optionally when the\nUSE_HAL_FLASH_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO
   part1->part5 : HAL_CORTEX_NVIC_SetPriority()
   part1->part5 : HAL_CORTEX_NVIC_EnableIRQ()
end

group #LimeGreen FLASH ITF Unlock
   part1->part4 : HAL_FLASH_ITF_Unlock()
end

group #FBF8B4 FLASH Configuration (optional)
      part1->part3 : HAL_FLASH_SetProgrammingMode()
end

group #LimeGreen FLASH Program operation
   part1->part3 : HAL_FLASH_ProgramByAddr_IT()
   part7->part6 : Interrupt
   part6->part3 : HAL_FLASH_IRQHandler()
   part3->part1 : HAL_FLASH_ProgramCpltCallback()
end

group #LimeGreen FLASH ITF Lock
   part1->part4 : HAL_FLASH_ITF_Lock()
end

group #LimeGreen FLASH De-initialization
   part1->part3 : HAL_FLASH_DeInit()
end
@enduml

Called functions:

User application erase in polling mode

@startuml
hide footbox
participant "User Application" as part1
participant "System"           as part2
participant "FLASH IO Driver"     as part3
participant "FLASH ITF Driver" as part4
group #LimeGreen Initialization
   part1->part2 : HAL_Init()
   part1->part2 : System clock configuration
   note right: The FLASH latency is updated according to bus frequency within clock configuration
   part1->part3 : HAL_FLASH_Init()
   note right: The FLASH Clock is enabled optionally when the\nUSE_HAL_FLASH_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO
end

group #LimeGreen FLASH ITF Unlock
   part1->part4 : HAL_FLASH_ITF_Unlock()
end

group #LimeGreen FLASH Erase operation
   group Choose an API according to context
      part1->part3 : HAL_FLASH_EraseByAddr()
      part1->part3 : HAL_FLASH_ErasePage()
      part1->part3 : HAL_FLASH_EraseBank()
      part1->part3 : HAL_FLASH_MassErase()
   end
end

group #LimeGreen FLASH ITF Lock
   part1->part4 : HAL_FLASH_ITF_Lock()
end

group #LimeGreen FLASH De-initialization
   part1->part3 : HAL_FLASH_DeInit()
end
@enduml

Called functions:

User application erase in interrupt mode

@startuml
hide footbox
participant "User Application" as part1
participant "System"           as part2
participant "FLASH IO Driver"  as part3
participant "FLASH ITF Driver" as part4
participant "CORTEX Driver"    as part5
participant "NVIC"             as part6
participant "HW"               as part7

group #LimeGreen Initialization
   part1->part2 : HAL_Init()
   part1->part2 : System clock configuration
   note right: The FLASH latency is updated according to bus frequency within clock configuration
   part1->part3 : HAL_FLASH_Init()
   note right: The FLASH Clock is enabled optionally when the\nUSE_HAL_FLASH_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO
   part1->part5 : HAL_CORTEX_NVIC_SetPriority()
   part1->part5 : HAL_CORTEX_NVIC_EnableIRQ()
end

group #LimeGreen FLASH ITF Unlock
   part1->part4 : HAL_FLASH_ITF_Unlock()
end

group #LimeGreen FLASH Erase operation
   group #LimeGreen Choose an API according to context
      part1->part3 : HAL_FLASH_EraseByAddr_IT()
      part1->part3 : HAL_FLASH_ErasePage_IT()
      part1->part3 : HAL_FLASH_EraseBank_IT()
      part1->part3 : HAL_FLASH_MassErase_IT()
   end
   part7->part6 : Interrupt
   part6->part3 : HAL_FLASH_IRQHandler()
   group #LimeGreen Choose a Callback API according to context
      part3->part1 : HAL_FLASH_EraseByAddrCpltCallback()
      part3->part1 : HAL_FLASH_ErasePageCpltCallback()
      part3->part1 : HAL_FLASH_EraseBankCpltCallback()
      part3->part1 : HAL_FLASH_MassEraseCpltCallback()
   end
end

group #LimeGreen FLASH ITF Lock
   part1->part4 : HAL_FLASH_ITF_Lock()
end

group #LimeGreen FLASH De-initialization
   part1->part3 : HAL_FLASH_DeInit()
end
@enduml

Called functions:

User application option-bytes configuration

@startuml
hide footbox
participant "User Application" as part1
participant "System"           as part2
participant "FLASH IO Driver"  as part3
participant "FLASH ITF Driver" as part4

group #LimeGreen Initialization
   part1->part2 : HAL_Init()
   part1->part2 : System clock configuration
   note right: The FLASH latency is updated according to bus frequency within clock configuration
end

group #LimeGreen FLASH ITF option-bytes Unlock
   part1->part4 : HAL_FLASH_ITF_OB_Unlock()
end

group #LimeGreen FLASH ITF option-bytes Configuration
      part1->part4 : HAL_FLASH_ITF_OB_SetIWDGMode()
end

group #LimeGreen FLASH ITF option-bytes Programming
      part1->part4 : HAL_FLASH_ITF_OB_Program()
end

group #LimeGreen FLASH ITF option-bytes Lock
   part1->part4 : HAL_FLASH_ITF_OB_Lock()
end

group #FBF8B4 System Reset (optional)
   part1->part2: HAL_CORTEX_NVIC_SystemReset()
   note right: Only required for a few OBs, and recommended for all other OBs
end

@enduml

Called functions:

User application interface control configuration

@startuml
hide footbox
participant "User Application" as part1
participant "System"           as part2
participant "FLASH ITF Driver" as part4

group #LimeGreen Initialization
   part1->part2 : HAL_Init()
   part1->part2 : System clock configuration
   note right: The FLASH latency is updated according to bus frequency within clock configuration
end

group #LimeGreen FLASH ITF Unlock
   part1->part4 : HAL_FLASH_ITF_Unlock()
end

group #LimeGreen FLASH ITF Control Configuration
      part1->part4 : HAL_FLASH_ITF_SetLatency()
end

group #LimeGreen FLASH ITF Lock
   part1->part4 : HAL_FLASH_ITF_Lock()
end

@enduml

Called functions: