HAL PWR Use Cases

User application Wake-up pin

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group Wake-up management

group #lightgreen Wake-up pin management
"part1"->"part2" : HAL_PWR_LP_SetConfigWakeupPin()
note right: Set wake-up polarity \nSet wake-up pull.
activate "part2"
"part2"-->"part1": hal_status
deactivate "part2"
"part1"->"part2" : HAL_PWR_LP_GetConfigWakeupPin()
note right: Get wake-up polarity \nGet wake-up pull.
activate "part2"
"part2"-->"part1": Wakeup pin configuration
deactivate "part2"
end

group #lightblue Wake-up pin activation
"part1"->"part2" : HAL_PWR_LP_EnableWakeupPin()
note right: Enable wake-up pin.
"part1"->"part2"  : HAL_PWR_LP_IsEnabledWakeupPin()
activate "part2"
"part2"-->"part1" : Wake-up pins enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_LP_DisableWakeupPin()
note right: Disable wake-up pin.
"part1"->"part2"  : HAL_PWR_LP_IsEnabledWakeupPin()
activate "part2"
"part2"-->"part1" : Wake-up pins disabled
deactivate "part2"
end
end
@enduml

Called functions:

User application RTC domain write protection

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group #lightblue RTC domain write protection activation
"part1"->"part2" : HAL_PWR_EnableRTCDomainWriteProtection()
"part1"->"part2" : HAL_PWR_IsEnabledRTCDomainWriteProtection()
activate "part2"
note right: Enable RTC write protection.
"part2"-->"part1" : RTC write protection enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_DisableRTCDomainWriteProtection()
"part1"->"part2" : HAL_PWR_IsEnabledRTCDomainWriteProtection()
activate "part2"
note right: Disable RTC write protection.
"part2"-->"part1" : RTC write protection disabled
deactivate "part2"
end
@enduml

Called functions:

User application enter to sleep mode

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group #lightblue Enter Sleep mode
"part1"->"part2"  : HAL_PWR_ClearCorePendingEvent()
note right: Clear Core pending event.
"part1"->"part2"  : HAL_PWR_EnterSleepMode()
note right: WFE or WFI request.
end
@enduml

Called functions:

User application enter to stop mode

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

activate part1
group #lightblue Enter Stop modes
"part1"->"part2"  : HAL_PWR_ClearCorePendingEvent()
note right: Clear Core pending event.
"part1"->"part2"  : HAL_PWR_EnterStopMode()
note right: Enter in Stop x mode\nWFE or WFI request.
deactivate part1
activate part2
...
end
@enduml

Called functions:

User application enter to standby mode

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

activate part1
group #lightblue Enter Standby mode
"part1"->"part2"  : HAL_PWR_LP_CleanWakeupSource(uint32_t wakeup_source)
note right: Clean wake-up source flags.
"part1"->"part2"  : HAL_PWR_EnterStandbyMode()
deactivate part1
activate part2
...
end
@enduml

Called functions:

User application core entering in deep sleep mode

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group #lightgreen Core sleep mode management
"part1"->"part2"  : HAL_PWR_SetCoreSleepMode()
note right: Set core sleep mode.
"part1"->"part2"  : HAL_PWR_GetCoreSleepMode()
"part2"-->"part1"  : Core sleep mode state
note right: Get core sleep mode configuration.
end
@enduml

Called functions:

User application core sleep on exit

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group #lightblue Core sleep on exit activation
"part1"->"part2" : HAL_PWR_EnableCoreSleepOnExit()
note right: Enable sleep on exit.
"part1"->"part2" : HAL_PWR_IsEnabledCoreSleepOnExit()
activate "part2"
"part2"-->"part1" : Core Sleep on Exit enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_DisableCoreSleepOnExit()
note right: Disable sleep on exit.
"part1"->"part2" : HAL_PWR_IsEnabledCoreSleepOnExit()
activate "part2"
"part2"-->"part1" : Core Sleep on Exit disabled
deactivate "part2"
end

@enduml

Called functions:

User application core send event on pending

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group #lightblue Core send event on pending activation
"part1"->"part2"  : HAL_PWR_EnableCoreSendEventOnPending()
note right       : Enable core send event on pending.
"part1"->"part2"  : HAL_PWR_IsEnabledCoreSendEventOnPending()
activate "part2"
"part2"-->"part1" : Core send event on pending enabled
deactivate "part2"

"part1"->"part2"  : HAL_PWR_DisableCoreSendEventOnPending()
note right       : Disable core send event on pending.
"part1"->"part2"  : HAL_PWR_IsEnabledCoreSendEventOnPending()
activate "part2"
"part2"-->"part1" : Core send event on pending disabled
deactivate "part2"
end
@enduml

Called functions:

User application programmable voltage detector

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group Programmable voltage detector
group #lightblue PVD activation
"part1"->"part2" : HAL_PWR_EnableProgrammableVoltageDetector()
note right       : Enable PVD.
"part1"->"part2" : HAL_PWR_IsEnabledProgrammableVoltageDetector()
activate part2
"part2"-->"part1" : PVD enabled
deactivate part2
"part1"->"part2" : HAL_PWR_DisableProgrammableVoltageDetector()
note right       : Disable PVD.
"part1"->"part2" : HAL_PWR_IsEnabledProgrammableVoltageDetector()
activate part2
"part2"-->"part1" : PVD disabled
deactivate part2
end
group #LightGoldenRodYellow PVD output check
"part1"->"part2" : HAL_PWR_GetProgrammableVoltageDetectorOutput()
activate part2
note right       : Get PVD output.
"part2"-->"part1" : VDD below or equal/higher than the threshold
deactivate part2
end
end

@enduml

Called functions: - HAL_PWR_EnableProgrammableVoltageDetector() - HAL_PWR_IsEnabledProgrammableVoltageDetector() - HAL_PWR_DisableProgrammableVoltageDetector() - HAL_PWR_GetProgrammableVoltageDetectorOutput()

User application memory retention

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group Memory retention management
group #lightblue Memory retention on non-paginated SRAMs
"part1"->"part2" : HAL_PWR_LP_EnableMemoryRetention()
activate part2
"part2"-->"part1" : HAL_OK
deactivate part2
note right       : Enable memory retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryRetention()
activate part2
"part2"-->"part1" : Memory retention enabled
deactivate part2
"part1"->"part2" : HAL_PWR_LP_DisableMemoryRetention()
activate part2
"part2"-->"part1" : HAL_OK
deactivate part2
note right       : Disable memory retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryRetention()
activate part2
"part2"-->"part1" : Memory retention disabled
deactivate part2
end

group #lightsalmon Memory retention on paginated SRAMs
"part1"->"part2" : HAL_PWR_LP_EnableMemoryRetention()
activate part2
"part2"-->"part1" : HAL_ERROR
deactivate part2
note right       : API incompatible with paginated SRAMs, always returns HAL_ERROR.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryRetention()
activate part2
"part2"-->"part1" : Memory retention disabled
note right       : Always returns disabled for paginated SRAMs.
deactivate part2
"part1"->"part2" : HAL_PWR_LP_DisableMemoryRetention()
activate part2
"part2"-->"part1" : HAL_ERROR
deactivate part2
note right       : API incompatible with paginated SRAMs, always returns HAL_ERROR.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryRetention()
activate part2
"part2"-->"part1" : Memory retention disabled
note right       : Always returns disabled for paginated SRAMs.
deactivate part2
end
end

@enduml

Called functions:

User application memory page retention

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group Paginated memory retention management

group #lightblue Paginated memory
"part1"->"part2" : HAL_PWR_LP_EnableMemoryPageRetention()
activate part2
"part2"-->"part1" : HAL_OK
deactivate part2
note right       : Enable memory page(s) retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryPageRetention()
activate part2
"part2"-->"part1" : Memory page retention enabled.
deactivate part2
"part1"->"part2" : HAL_PWR_LP_DisableMemoryPageRetention()
activate part2
"part2"-->"part1" : HAL_OK
deactivate part2
note right       : Disable memory page(s) retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryPageRetention()
activate part2
"part2"-->"part1" : Memory page retention enabled.
deactivate part2
end

group #LightGreen Paginated memory with out-of-range page index request
"part1"->"part2" : HAL_PWR_LP_EnableMemoryPageRetention()
activate part2
"part2"-->"part1" : HAL_OK
deactivate part2
note right       : Enable memory page(s) retention with valid indexes and ignore out-of-range indexes.
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryPageRetention()
activate part2
"part2"-->"part1" : Memory page retention disabled
deactivate part2
note right       : Out-of-range page indexes are ignored, so the API returns disabled.
"part1"->"part2" : HAL_PWR_LP_DisableMemoryPageRetention()
activate part2
"part2"-->"part1" : HAL_OK
deactivate part2
note right       : Disable memory page(s) retention with valid indexes and ignore out-of-range indexes.
end

group #lightsalmon Non-paginated memory
"part1"->"part2" : HAL_PWR_LP_EnableMemoryPageRetention()
activate part2
"part2"-->"part1" : HAL_ERROR
note right       : API incompatible with non-paginated SRAMs, always returns HAL_ERROR.
deactivate part2
"part1"->"part2" : HAL_PWR_LP_IsEnabledMemoryPageRetention()
activate part2
"part2"-->"part1" : Memory page retention disabled
note right      : Always returns disabled for non-paginated SRAMs.
deactivate part2
"part1"->"part2" : HAL_PWR_LP_DisableMemoryPageRetention()
activate part2
"part2"-->"part1" : HAL_ERROR
note right       : API incompatible with non-paginated SRAMs, always returns HAL_ERROR.
deactivate part2
end
end
@enduml

Called functions:

User application Power IO Retention

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group PWR GPIO retention
group #lightgreen JTAG IO retention
"part1"->"part2" : HAL_PWR_LP_EnableIORetention(HAL_PWR_IO_RETENTION_JTAGIO)
note right: Enable JTAG IO Retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledIORetention(HAL_PWR_IO_RETENTION_JTAGIO)
activate "part2"
"part2"-->"part1": JTAG IO retention enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_LP_DisableIORetention(HAL_PWR_IO_RETENTION_JTAGIO)
note right: Disable JTAG IO Retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledIORetention(HAL_PWR_IO_RETENTION_JTAGIO)
activate "part2"
"part2"-->"part1": JTAG IO retention disabled
deactivate "part2"
end

group #lightblue GPIO Retention
"part1"->"part2" : HAL_PWR_LP_EnableIORetention(HAL_PWR_IO_RETENTION_GPIO)
note right: Enable GPIO Retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledIORetention(HAL_PWR_IO_RETENTION_GPIO)
activate "part2"
"part2"-->"part1": GPIO retention enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_LP_DisableIORetention(HAL_PWR_IO_RETENTION_GPIO)
note right: Disable GPIO Retention.
"part1"->"part2" : HAL_PWR_LP_IsEnabledIORetention(HAL_PWR_IO_RETENTION_GPIO)
activate "part2"
"part2"-->"part1": GPIO retention disabled
deactivate "part2"
end
end
@enduml

Called functions:

User application privilege configuration

@startuml
hide footbox
participant "User Application" as part1
participant "PWR Driver" as part2

group Privilege attribute

group #lightsalmon Set privilege attribute when the CPU is not in privileged mode
"part1"->"part2" : HAL_PWR_SetPrivAttr(HAL_PWR_ITEM_..., HAL_PWR_PRIV)
activate "part2"
"part2"-->"part1": HAL_ERROR
note right: Set PWR item privilege attribute is not allowed\nwhen CPU is not in privilege mode.
deactivate "part2"
end

group #lightgreen Set privilege attribute to PRIV when the CPU is in privileged mode
"part1"->"part2" : HAL_PWR_SetPrivAttr(HAL_PWR_ITEM_..., HAL_PWR_PRIV)
note right: Set PWR item privilege attribute.
activate "part2"
"part2"-->"part1": HAL_OK
deactivate "part2"
"part1"->"part2" : HAL_PWR_GetPrivAttr(HAL_PWR_ITEM_...)
note right: Get PWR item privilege attribute.
activate "part2"
"part2"-->"part1": HAL_PWR_PRIV
deactivate "part2"
end

group #lightblue Set privilege attribute to NPRIV when the CPU is in privileged mode
"part1"->"part2" : HAL_PWR_SetPrivAttr(HAL_PWR_ITEM_..., HAL_PWR_NPRIV)
note right: Set PWR item privilege attribute.
activate "part2"
"part2"-->"part1": HAL_OK
deactivate "part2"

"part1"->"part2" : HAL_PWR_GetPrivAttr(HAL_PWR_ITEM_...)
note right: Get PWR item privilege attribute.
activate "part2"
"part2"-->"part1": HAL_PWR_NPRIV
deactivate "part2"
end

end
@enduml

Called functions: - HAL_PWR_SetPrivAttr() - HAL_PWR_GetPrivAttr()