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 regulator voltage scaling range

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

group #lightgreen Regulator voltage scaling range management
"part1"->"part2" : HAL_PWR_SetMainRegulatorVoltageScalingRange()
note right: Set regulator voltage scaling range.
activate "part2"
"part2"-->"part1" : hal_status
deactivate "part2"
"part1"->"part2" : HAL_PWR_GetMainRegulatorVoltageScalingRange()
activate "part2"
note right: Get regulator active voltage scaling range.
"part2"-->"part1" : Voltage scaling range configuration
deactivate "part2"
"part1"->"part2" : HAL_PWR_GetMainRegulatorActiveVoltageScalingRange()
activate "part2"
note right: Get regulator active voltage scaling range.
"part2"-->"part1" : Active voltage scaling range
deactivate "part2"
end
@enduml

Called functions:

User application regulator supply

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

group #lightgreen Regulator supply management
"part1"->"part2" : HAL_PWR_SetMainRegulatorSupply()
note right: Set main system supply regulator.
activate "part2"
"part2"-->"part1" : hal_status
deactivate "part2"

"part1"->"part2" : HAL_PWR_GetMainRegulatorSupply()
note right: Get main system supply regulator configuration.
activate "part2"
"part2"-->"part1" : Regulator supply configuration
deactivate "part2"

"part1"->"part2" : HAL_PWR_GetMainRegulatorSupplyStatus()
note right: Get main system supply regulator status.
activate "part2"
"part2"-->"part1" : Regulator supply status
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 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 #lightgreen Programmable Voltage Detector Level management
"part1"->"part2"  : HAL_PWR_SetProgrammableVoltageDetectorLevel()
note right: Set Programmable Voltage Detector Level.
"part1"->"part2"  : HAL_PWR_GetProgrammableVoltageDetectorLevel()
activate part2
"part2"-->"part1" : PVD level
deactivate part2
note right: Get Programmable Voltage Detector Level configuration.
end
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_SetProgrammableVoltageDetectorLevel() - HAL_PWR_GetProgrammableVoltageDetectorLevel() - HAL_PWR_EnableProgrammableVoltageDetector() - HAL_PWR_IsEnabledProgrammableVoltageDetector() - HAL_PWR_DisableProgrammableVoltageDetector() - HAL_PWR_GetProgrammableVoltageDetectorOutput()

User application analog voltage detector

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

group Analog voltage detector
group #lightgreen Analog Voltage Detector Level management
"part1"->"part2"  : HAL_PWR_SetAnalogVoltageDetectorLevel()
note right: Set Analog Voltage Detector Level.
"part1"->"part2"  : HAL_PWR_GetAnalogVoltageDetectorLevel()
activate part2
"part2"-->"part1" : AVD level
note right: Get Analog Voltage Detector Level configuration.
deactivate part2
end
group #lightblue AVD activation
"part1"->"part2" : HAL_PWR_EnableAnalogVoltageDetector()
note right       : Enable AVD.
"part1"->"part2" : HAL_PWR_IsEnabledAnalogVoltageDetector()
activate part2
"part2"-->"part1" : AVD enabled
deactivate part2
"part1"->"part2" : HAL_PWR_DisableAnalogVoltageDetector()
note right       : Disable AVD.
"part1"->"part2" : HAL_PWR_IsEnabledAnalogVoltageDetector()
activate part2
"part2"-->"part1" : AVD disabled
deactivate part2
end
group #LightGoldenRodYellow AVD output check
"part1"->"part2" : HAL_PWR_GetAnalogVoltageDetectorOutput()
activate part2
note right       : Get AVD output.
"part2"-->"part1" : VDDA below or equal/higher than the threshold
deactivate part2
end
end

@enduml

Called functions: - HAL_PWR_SetAnalogVoltageDetectorLevel() - HAL_PWR_GetAnalogVoltageDetectorLevel() - HAL_PWR_EnableAnalogVoltageDetector() - HAL_PWR_IsEnabledAnalogVoltageDetector() - HAL_PWR_DisableAnalogVoltageDetector() - HAL_PWR_GetAnalogVoltageDetectorOutput()

User application memory retention

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

group #lightblue Memory retention management
"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


@enduml

Called functions:

User application UCPD standby mode

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

group #lightblue UCPD Retention in standby mode activation
"part1"->"part2" : HAL_PWR_LP_EnableUCPDRetention()
note right       : Enable UCPD Retention in Standby mode.
"part1"->"part2" : HAL_PWR_LP_IsEnabledUCPDRetention()
activate part2
"part2"-->"part1" : UCPD configuration retention in Standby mode enabled
deactivate part2
"part1"->"part2" : HAL_PWR_LP_DisableUCPDRetention()
note right       : Disable UCPD Retention in Standby mode.
"part1"->"part2" : HAL_PWR_LP_IsEnabledUCPDRetention()
activate part2
"part2"-->"part1" : UCPD configuration retention in Standby mode disabled
deactivate part2
end
@enduml

Called functions:

User application Battery charging control

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

group Battery charging
group #lightgreen Battery charging management
"part1"->"part2" : HAL_PWR_SetConfigBatteryCharging()
activate "part2"
note right: Set battery charging resistor config.
"part1"->"part2" : HAL_PWR_GetConfigBatteryCharging()
"part2"-->"part1": Battery charging resistor value
note right: Get battery charging resistor config.
deactivate "part2"
end
group #lightblue Battery charging activation
"part1"->"part2" : HAL_PWR_EnableBatteryCharging()
activate "part2"
"part1"->"part2"  : HAL_PWR_IsEnabledBatteryCharging()
note right: Enable Battery charging.
"part2"-->"part1" : Battery charging enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_DisableBatteryCharging()
activate "part2"
"part1"->"part2"  : HAL_PWR_IsEnabledBatteryCharging()
note right: Disable Battery charging.
"part2"-->"part1" : Battery charging disabled
deactivate "part2"
end
end
@enduml

Called functions:

User application dead battery

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

group #lightblue Dead battery activation
"part1"->"part2" : HAL_PWR_LP_EnableUCPDDeadBattery()
note right       : Enable dead battery behavior.
"part1"->"part2" : HAL_PWR_LP_IsEnabledUCPDDeadBattery()
activate part2
"part2"-->"part1": UCPD Dead Battery mode enabled
deactivate part2
"part1"->"part2" : HAL_PWR_LP_DisableUCPDDeadBattery()
note right       : Disable dead battery behavior.
"part1"->"part2" : HAL_PWR_LP_IsEnabledUCPDDeadBattery()
activate part2
"part2"-->"part1": UCPD Dead Battery mode disabled
deactivate part2
end

@enduml

Called functions:

User application Power GPIO pull for peripheral

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

group PWR GPIO peripheral pull
group #lightgreen Power GPIO management
"part1"->"part2" : HAL_PWR_LP_SetConfigPeriphGPIOPull()
note right:Set PWR GPIO pull for peripheral in standby\nand shutdown mode.
"part1"->"part2" : HAL_PWR_LP_GetConfigPeriphGPIOPull()
activate "part2"
"part2"-->"part1": PWR GPIO peripheral pull configuration
note right:Get PWR GPIO peripheral pull config.
deactivate "part2"
end

group #lightblue PWR GPIO pull activation
"part1"->"part2" : HAL_PWR_LP_EnableGPIOPull()
note right: Enable PWR GPIO pull.
"part1"->"part2"  : HAL_PWR_LP_IsEnabledGPIOPull()
activate "part2"
"part2"-->"part1" : PWR GPIO pull enabled
deactivate "part2"
"part1"->"part2" : HAL_PWR_LP_DisableGPIOPull()
note right: Disable PWR GPIO pull.
"part1"->"part2"  : HAL_PWR_LP_IsEnabledGPIOPull()
activate "part2"
"part2"-->"part1" : PWR GPIO pull disabled
deactivate "part2"
end
end
@enduml

Called functions:

User application Stop wake-up on handler mode

@startuml
hide footbox


participant "User Application" as part1
participant "System"           as part2
participant "PWR Driver"       as part3
participant "NVIC"             as part4
participant "HW"               as part5

group #Yellow Initialization
    part1->part2 : HAL_Init()
    part1->part2 : Configure system clock(s)
end

group #lightgray Low power wakeup management
    group #SkyBlue Wakeup configurations
        part1->part3 : HAL_PWR_LP_SetConfigWakeupPin()
        activate "part3"
        "part3"-->"part1" : hal_status_t
        note right : - Set wakeup pin(s) polarity \n- Set wakeup pin(s) pull.
        deactivate "part3"
        part1->part3 : HAL_PWR_LP_EnableWakeupPin()
        note right : - Enable wakeup pin(s).
    end

    group #lightSalmon Enter low power Stop mode
        part1->part3 : HAL_PWR_EnterStopMode()
            note right : - Enter Stop mode.
    end

    group #SkyBlue Wakeup interrupt handler
        part4<-part5 : Interrupt
        activate part4
        part4->part3 : HAL_PWR_WakeupPin_IRQHandler()
        deactivate part4
        activate part3
            note right : - Clear wakeup flag(s) \n- Call user callback.
        part3->part1 : HAL_PWR_WakeupPinCallback()
        deactivate part3
    end
end
@enduml

Called functions: - HAL_PWR_LP_SetConfigWakeupPin() - HAL_PWR_LP_EnableWakeupPin() - HAL_PWR_EnterStopMode() - HAL_PWR_WakeupPinCallback()