HAL WWDG Functions

Initialization and Start functions

group WWDG_Exported_Functions_Group1

This subsection provides a set of functions allowing to initialize and start the WWDG peripheral:

  • Call the function HAL_WWDG_Init() to initialize the WWDG handle and associate an instance.

  • Call the function HAL_WWDG_Start() to start the WWDG according to the parameters provided by the user.

Functions

hal_status_t HAL_WWDG_Init ( hal_wwdg_handle_t * hwwdg , hal_wwdg_t instance )

Initialize the WWDG according to the associated handle.

Warning

In case of starting WWDG in Hardware mode, make sure that USE_HAL_WWDG_HARDWARE_START is aligned with the WWDG_SW option byte.

Parameters :
  • hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

  • instance – WWDG instance.

Return values :
  • HAL_OK – HAL operation completed successfully.

  • HAL_INVALID_PARAM – HAL invalid parameter.

hal_status_t HAL_WWDG_Start ( hal_wwdg_handle_t * hwwdg , uint32_t min_time , uint32_t max_time , uint32_t ewi_status )

Start the WWDG. Before exiting the function, the watchdog counter is refreshed to have a correct time base.

Note

The default time unit is milliseconds if not specified through USE_HAL_WWDG_TIME_UNIT define.

Warning

The max_time and min_time are used to define the reload and the window values, the unit for these parameters depends on the switch USE_HAL_WWDG_TIME_UNIT.

Warning

The ewi_status must be set to zero when Early Wakeup Interrupt feature is not used.

Parameters :
  • hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

  • min_time – Minimum time value before refreshing is allowed.

  • max_time – Maximum time value before a WWDG reset.

  • ewi_status – Early Wakeup Interrupt activation.

Return values :

HAL_OK – HAL operation completed successfully.

IO operation function

group WWDG_Exported_Functions_Group2

This subsection provides a function to manage the refresh of the WWDG counter:

  • Call the function HAL_WWDG_Refresh() to reload WWDG counter with value defined in the reload register.

Functions

hal_status_t HAL_WWDG_Refresh ( hal_wwdg_handle_t * hwwdg )

Refresh the WWDG counter.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

Return values :

HAL_OK – HAL operation completed successfully.

State function

group WWDG_Exported_Functions_Group3

This subsection provides a function to retrieve the state value:

Functions

hal_wwdg_state_t HAL_WWDG_GetState ( const hal_wwdg_handle_t * hwwdg )

Return the WWDG handle state.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

Return values :
  • HAL_WWDG_STATE_RESET – WWDG driver not initialized and not started.

  • HAL_WWDG_STATE_IDLE – WWDG driver initialized and not started.

  • HAL_WWDG_STATE_ACTIVE – WWDG driver initialized and started.

Set/Get item functions

group WWDG_Exported_Functions_Group4

This subsection provides a set of functions to set/retrieve configuration items separately for the WWDG driver:

Note

The prescaler is calculated from maximum time once in the HAL_WWDG_Start() function, to avoid a change of prescaler, we did not introduce a function to set the maximum time because it can modify the prescaler and thus require to recalculate the Window. To modify the maximum time, the user must proceed with the HAL_WWDG_Start() function.

Functions

uint32_t HAL_WWDG_GetMaxTime ( const hal_wwdg_handle_t * hwwdg )

Get the maximum time value according to the handle instance registers.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

Return values :

uint32_t – Current maximum time value.

uint32_t HAL_WWDG_GetStep_us ( const hal_wwdg_handle_t * hwwdg )

Get the WWDG counter period in microseconds.

Note

HAL_WWDG_GetStep_us is given as information to allow the user to calculate max_time, min_time to avoid rounded values.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

Return values :

uint32_t – Current counter period value in us.

hal_status_t HAL_WWDG_SetMinTime ( hal_wwdg_handle_t * hwwdg , uint32_t min_time )

Set the Window time value.

Warning

User must refresh the WWDG counter before calling this function.

Parameters :
  • hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

  • min_time – Minimum time value before refreshing is allowed.

Return values :

HAL_OK – HAL operation completed successfully.

uint32_t HAL_WWDG_GetMinTime ( const hal_wwdg_handle_t * hwwdg )

Get the Window time value according to the handler instance registers.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

Return values :

uint32_t – Current Window time value.

IRQ Handler/Callbacks/Register Callbacks functions

group WWDG_Exported_Functions_Group5

This subsection provides a set of functions allowing to register the WWDG process and callbacks:

There are two ways to use callbacks:

Override weak callback function: Call the function

HAL_WWDG_EarlyWakeupCallback()

to indicate that an early interrupt is pending.

Or register callbacks user: Call the function

HAL_WWDG_RegisterEarlyWakeupCallback() to register the Early Wakeup Callback.

Functions

void HAL_WWDG_IRQHandler ( hal_wwdg_handle_t * hwwdg )

Handle WWDG interrupt request.

Note

The Early Wakeup Interrupt (EWI) can be used if specific safety operations or data logging must be performed before the actual reset is generated. The EWI interrupt is enabled by calling HAL_WWDG_Start() function with an ewi_status equals to 1. When the downcounter reaches the value 0x40, an EWI interrupt is generated and the corresponding Interrupt Service Routine (ISR) can be used to trigger specific actions (such as communications or data logging), before resetting the device.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

void HAL_WWDG_EarlyWakeupCallback ( hal_wwdg_handle_t * hwwdg )

WWDG Early Wakeup callback.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

hal_status_t HAL_WWDG_RegisterEarlyWakeupCallback ( hal_wwdg_handle_t * hwwdg , hal_wwdg_cb_t p_callback )

Register the user WWDG Early Wakeup Callback.

Parameters :
  • hwwdg – Pointer to a hal_wwdg_handle_t structure that contains the configuration information for the specified WWDG module.

  • p_callback – pointer to the hal_wwdg_cb_t Callback function

Return values :
  • HAL_OK – HAL operation completed successfully.

  • HAL_INVALID_PARAM – HAL invalid parameter.

User Data Function

group WWDG_Exported_Functions_Group6

This subsection provides functions allowing to set user specific data to a WWDG instance:

Functions

void HAL_WWDG_SetUserData ( hal_wwdg_handle_t * hwwdg , const void * p_user_data )

Store User Data pointer into the handle.

Parameters :
  • hwwdg – Pointer to a hal_wwdg_handle_t structure which contains the WWDG instance.

  • p_user_data – Pointer to the user data.

const void * HAL_WWDG_GetUserData ( const hal_wwdg_handle_t * hwwdg )

Retrieve User Data pointer from the handle.

Parameters :

hwwdg – Pointer to a hal_wwdg_handle_t structure which contains the WWDG instance.

Return values :

Pointer – to the user data.