HAL WWDG use cases

User Application Starting a Driver

@startuml



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

"System" --> "User Application"

"User Application"->"System" : Configure system clock

"System" --> "User Application"

"User Application"->"Driver WWDG" : HAL_WWDG_Init()



alt if USE_HAL_WWDG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

"Driver WWDG"->"System": Enable the WWDG clock

"System" --> "Driver WWDG"

end



"Driver WWDG" --> "User Application"

"User Application"->"Driver WWDG" : HAL_WWDG_Start()

"Driver WWDG"->"System": HAL_RCC_GetPCLK1Freq()

"System" --> "Driver WWDG"

"Driver WWDG" --> "User Application"

@enduml

Functions called:

WWDG Refresh Correctly

@startuml



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



"System" --> "User Application"



"User Application"->"Driver WWDG" : HAL_WWDG_Init()



alt if USE_HAL_WWDG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

"Driver WWDG"->"System": Enable the WWDG clock

"System" --> "Driver WWDG"

end

"Driver WWDG" --> "User Application"



"User Application" -> "Driver WWDG" : HAL_WWDG_Start

"Driver WWDG"->"System": HAL_RCC_GetPCLK1Freq()

"System" --> "Driver WWDG"

"Driver WWDG" --> "User Application"



group Loop [Can be repeated]



"Driver WWDG" -> "Driver WWDG" : WWDG down-counter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()



rnote over "Driver WWDG"

<color #green>Refresh done when the down-counter

<color #green>value is inside the window

endrnote



rnote over "Driver WWDG"

<color #green>Operation ended successfully

endrnote



end



@enduml

Functions called:

WWDG Cannot Refresh

@startuml



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

"System" --> "User Application"



"User Application"->"Driver WWDG" : HAL_WWDG_Init()



alt if USE_HAL_WWDG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

"Driver WWDG"->"System": Enable the WWDG clock

"System" --> "Driver WWDG"

end

"Driver WWDG" --> "User Application"





"User Application" -> "Driver WWDG" : HAL_WWDG_Start

"Driver WWDG"->"System": HAL_RCC_GetPCLK1Freq()

"System" --> "Driver WWDG"

"Driver WWDG" --> "User Application"



alt WWDG not expired

group Loop [Can be repeated]



"Driver WWDG" -> "Driver WWDG" : WWDG down-counter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()



rnote over "Driver WWDG"

<color #green>Refresh done when the down-counter

<color #green>value is inside the window

endrnote



rnote over "Driver WWDG"

<color #green> Operation ended successfully

endrnote



end



else WWDG expired

"Driver WWDG" -> "Driver WWDG" : WWDG down-counter

"Driver WWDG" -[#red]> "System" : <color #red> WWDG reset </color>



rnote over "Driver WWDG"

<color #red>Following a malfunction due to software

<color #red>or hardware failures, the WWDG

<color #red>can not refresh.

<color #red>RESET signal is generated when the down-counter

<color #red>value becomes lower than 0x40

endrnote



else Reload outside the window



"Driver WWDG" -> "Driver WWDG" : WWDG down-counter

"Driver WWDG" -[#red]> "System" : <color #red> WWDG reset </color>



rnote over "Driver WWDG"

<color #red>RESET signal is generated when reload operation is

<color #red>performed outside the limited window.

endrnote



end



@enduml

Functions called:

Early Wakeup Interrupt Option is Activated

@startuml



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

"System" --> "User Application"



"User Application" -> "NVIC" : Enable NVIC

"NVIC" --> "User Application"



"User Application"->"Driver WWDG" : HAL_WWDG_Init()



alt if USE_HAL_WWDG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

"Driver WWDG"->"System": Enable the WWDG clock

"System" --> "Driver WWDG"

end

"Driver WWDG" --> "User Application"



rnote over "User Application"

The user can choose

Option 1 or Option 2 or nothing.

endrnote



group Option 1 [USE REGISTER CALLBACKS]

"User Application" ->  "Driver WWDG" : HAL_WWDG_RegisterEarlyWakeupCallback\n(User_WWDG_EarlyWakeUpCallback)

"Driver WWDG" --> "User Application" : return HAL_OK

end





"User Application" -> "Driver WWDG" : HAL_WWDG_Start

"Driver WWDG"->"System": HAL_RCC_GetPCLK1Freq()

"System" --> "Driver WWDG"

"Driver WWDG" --> "User Application"



alt WWDG not expired

group Loop [Can be repeated]



"Driver WWDG" -> "Driver WWDG" : WWDG downcounter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()



rnote over "Driver WWDG"

<color #green>Refresh done when the down-counter

<color #green>value is inside the window

endrnote



rnote over "Driver WWDG"

<color #green> Operation ended successfully

endrnote



end



else WWDG expired



rnote over "Driver WWDG"

<color #red>When the down-counter is equal to 0x40

endrnote



"WWDG_IRQHandler" <[#Blue]- "NVIC" : WWDG Early Wakeup interrupt



rnote over "Driver WWDG"

EWIF: Watchdog early interrupt flag = 1

endrnote





"WWDG_IRQHandler" -[#Blue]> "Driver WWDG" : HAL_WWDG_IRQHandler()



activate "Driver WWDG" #Blue



rnote over "Driver WWDG"

EWIF: Watchdog early interrupt flag = 0

endrnote



group Option 1 [USE REGISTER CALLBACKS]

"Driver WWDG" -[#Blue]> "User Application" :User_WWDG_EarlyWakeUpCallback

"User Application" -[#Blue]-> "Driver WWDG"

end

group Option 2 [USE OVERRIDEN WEAK CALLBACKS]

"Driver WWDG" -[#Blue]> "User Application" : HAL_WWDG_EarlyWakeupCallback()

"User Application" -[#Blue]-> "Driver WWDG"

deactivate "Driver WWDG"

end



"Driver WWDG" -> "Driver WWDG" : WWDG downcounter

"Driver WWDG" -[#red]> "System" : <color #red> WWDG reset </color>



end



@enduml

Functions called:

Use Case for Max Time Adjustment

@startuml



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

"System" --> "User Application"



"User Application"->"Driver WWDG" : HAL_WWDG_Init()



alt if USE_HAL_WWDG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

"Driver WWDG"->"System": Enable the WWDG clock

"System" --> "Driver WWDG"

end

"Driver WWDG" --> "User Application"



rnote over "User Application"

for PCLK = $MAX_FREQ$ MHz and Time unit is in milliseconds

User chooses 78 ms as max time.

endrnote



"User Application" -> "Driver WWDG" : HAL_WWDG_Start

"Driver WWDG"->"System": HAL_RCC_GetPCLK1Freq()

"System" --> "Driver WWDG"

"Driver WWDG" --> "User Application"



group Loop [Can be repeated]



"Driver WWDG" -> "Driver WWDG" : WWDG downcounter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()

end



rnote over "User Application"

To know the max time assured by the WWDG driver

user can call HAL_WWDG_GetMaxTime() function.

endrnote



"User Application"->"Driver WWDG" : HAL_WWDG_GetMaxTime()

"Driver WWDG" -> "User Application" : 75 ms



rnote over "User Application"

To adjust the max time

user can call HAL_WWDG_GetStep_us() function

in order to khnow the step.

endrnote



"User Application"->"Driver WWDG" : HAL_WWDG_GetStep_us()

"Driver WWDG" -> "User Application" : 1 ms



rnote over "User Application"

For a step = 1 ms, the maximum assured time is

75 ms instead of 78 ms with an offset of 3 ms,

User can then propose 75 ms for more efficiency.

endrnote





"User Application" -> "Driver WWDG" : HAL_WWDG_Start

"Driver WWDG" --> "User Application"



group Loop [Can be repeated]



"Driver WWDG" ->x "Driver WWDG" : WWDG downcounter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()

end



@enduml

Functions called:

Use Case for Min Time Adjustment

@startuml



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

"System" --> "User Application"



"User Application"->"Driver WWDG" : HAL_WWDG_Init()



alt if USE_HAL_WWDG_CLK_ENABLE_MODEL > HAL_CLK_ENABLE_NO

"Driver WWDG"->"System": Enable the WWDG clock

"System" --> "Driver WWDG"

end

"Driver WWDG" --> "User Application"



rnote over "User Application"

for PCLK = $MAX_FREQ$ MHz and Time unit is in milliseconds.

User chooses 50ms as min time.

endrnote



"User Application" -> "Driver WWDG" : HAL_WWDG_Start

"Driver WWDG"->"System": HAL_RCC_GetPCLK1Freq()

"System" --> "Driver WWDG"

"Driver WWDG" --> "User Application"



group Loop [Can be repeated]



"Driver WWDG" ->x "Driver WWDG" : WWDG down-counter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()

end



rnote over "User Application"

To modify the min time assured by the WWDG driver,

user can call HAL_WWDG_SetMinTime() function.

endrnote



"User Application"->"Driver WWDG" : HAL_WWDG_SetMinTime(): 30ms



rnote over "User Application"

At any time of the application, user can check the configured

min time by calling HAL_WWDG_GetMinTime() function.

endrnote



"User Application" -> "Driver WWDG" : HAL_WWDG_GetMinTime()

"Driver WWDG" --> "User Application"

"Driver WWDG" -> "User Application" : 30ms



group Loop [Can be repeated]



"Driver WWDG" ->x "Driver WWDG" : WWDG down-counter

"User Application" -> "Driver WWDG" : HAL_WWDG_Refresh()

end



@enduml

Functions called: