Watchdog Manager#
Watchdog Manager Service.
The Watchdog Manager provides a software watchdog system that allows monitoring multiple periodic code execution streams. It manages a hardware watchdog peripheral (typically WDOG1) and provides multiple virtual software watchdogs that can be created, fed, enabled, and disabled independently.
The hardware watchdog is only fed when all enabled software watchdogs have been fed, ensuring that if any monitored code path fails to execute periodically, the system will reset.
Key features:
Multiple software watchdogs (up to 32)
Dynamic creation and deletion of software watchdogs
Individual enable/disable control
Stops counting in all sleep modes (EM1/EM2/EM3)
Debug support to identify which watchdog caused a reset
Usage:
Call sl_watchdog_manager_init() early in initialization
Create software watchdogs with sl_watchdog_manager_create()
Call sl_watchdog_manager_start() when ready to enable protection
Regularly feed each software watchdog with sl_watchdog_manager_feed()
Typedefs#
Handle for software watchdog instances (bit position 0-31, max 32 watchdogs).
Functions#
Initializes watchdog manager.
Starts watchdog manager.
Creates a software watchdog.
Deletes a software watchdog.
Feeds a software watchdog.
Disables a software watchdog.
Checks if a software watchdog is enabled.
Enables a software watchdog.
Forces a hardware watchdog feed regardless of software watchdogs.
Retrieves the software watchdog that caused a reset.
Macros#
UID reserved for the platform default watchdog (do not use for application watchdogs).
Typedef Documentation#
sl_watchdog_handle_t#
typedef uint32_t sl_watchdog_handle_t
Handle for software watchdog instances (bit position 0-31, max 32 watchdogs).
Valid values: 0 to 31, where each position corresponds to one watchdog instance.
Function Documentation#
sl_watchdog_manager_init#
void sl_watchdog_manager_init (void )
Initializes watchdog manager.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
This function must be called before any other watchdog manager function. It initializes the internal state and configures the hardware watchdog peripheral, but does not start it yet.
Note
When returning from this function, the hardware watchdog will not be started yet. Call sl_watchdog_manager_start() to start it.
This function is typically called automatically via system initialization hooks.
sl_watchdog_manager_start#
void sl_watchdog_manager_start (void )
Starts watchdog manager.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
This function starts the hardware watchdog timer. After calling this function, the software watchdogs must be fed regularly to prevent a system reset.
Note
Calling this function will start the hardware watchdog. By default, this is called late in initialization, but can be called earlier to protect the initialization phase.
This function is typically called automatically via system initialization hooks.
sl_watchdog_manager_create#
sl_status_t sl_watchdog_manager_create (sl_watchdog_handle_t * handle, uint32_t watchdog_uid)
Creates a software watchdog.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [out] | handle | Pointer to receive the handle to the created software watchdog. Must not be NULL. |
| uint32_t | [in] | watchdog_uid | Software watchdog unique identifier for debugging. Use values 256-0xFFFFFFFE for application watchdogs. 0-255 are reserved for customer use, 0xFFFFFFFF is reserved for platform default watchdog. |
Creates a new software watchdog instance and returns a handle to it. The watchdog is created in the enabled state and must be fed regularly to prevent a system reset.
The watchdog_uid parameter provides a unique identifier for debugging purposes. If a reset occurs due to watchdog expiration, this UID can help identify which watchdog was not fed.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NULL_POINTER if handle is NULL.
SL_STATUS_NO_MORE_RESOURCE if maximum number of watchdogs (32) has been reached.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
sl_watchdog_manager_delete#
sl_status_t sl_watchdog_manager_delete (sl_watchdog_handle_t * handle)
Deletes a software watchdog.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [in] | handle | Pointer to the handle of the software watchdog to delete. Must not be NULL. The handle will be set to an invalid value (e.g. UINT32_MAX) after deletion. |
Deletes a software watchdog instance and frees its handle for reuse. After deletion, the handle is no longer valid and should not be used.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NULL_POINTER if handle is NULL.
SL_STATUS_INVALID_HANDLE if the handle is invalid or already deleted.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
sl_watchdog_manager_feed#
sl_status_t sl_watchdog_manager_feed (sl_watchdog_handle_t * handle)
Feeds a software watchdog.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [in] | handle | Pointer to the handle of the software watchdog to feed. Must not be NULL. |
Marks the software watchdog as fed for the current period. When all enabled software watchdogs have been fed, the hardware watchdog is automatically fed.
This function should be called periodically from the code path being monitored. The period must be shorter than the configured hardware watchdog timeout.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NULL_POINTER if handle is NULL.
SL_STATUS_INVALID_HANDLE if the handle is invalid.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
sl_watchdog_manager_disable#
sl_status_t sl_watchdog_manager_disable (sl_watchdog_handle_t * handle)
Disables a software watchdog.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [in] | handle | Pointer to the handle of the software watchdog to disable. Must not be NULL. |
Disables a software watchdog. A disabled watchdog does not need to be fed to prevent a system reset. The watchdog remains allocated and can be re-enabled later with sl_watchdog_manager_enable().
This is useful for temporarily disabling monitoring of a code path, for example during calibration or other long operations.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NULL_POINTER if handle is NULL.
SL_STATUS_INVALID_HANDLE if the handle is invalid.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
Note
A disabled software watchdog doesn't need to be fed to prevent a system reset.
sl_watchdog_manager_is_enabled#
sl_status_t sl_watchdog_manager_is_enabled (sl_watchdog_handle_t * handle, bool * is_enabled)
Checks if a software watchdog is enabled.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [in] | handle | Pointer to the handle of the software watchdog to query. Must not be NULL. |
| bool * | [out] | is_enabled | Pointer to variable that will receive the state of the software watchdog. True if enabled, false if disabled. Must not be NULL. |
Queries whether a software watchdog is currently enabled or disabled.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NULL_POINTER if handle or is_enabled is NULL.
SL_STATUS_INVALID_HANDLE if the handle is invalid.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
sl_watchdog_manager_enable#
sl_status_t sl_watchdog_manager_enable (sl_watchdog_handle_t * handle)
Enables a software watchdog.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [in] | handle | Pointer to the handle of the software watchdog to enable. Must not be NULL. |
Enables a previously disabled software watchdog. Once enabled, the watchdog must be fed regularly to prevent a system reset.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NULL_POINTER if handle is NULL.
SL_STATUS_INVALID_HANDLE if the handle is invalid.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
sl_watchdog_manager_force_feed#
sl_status_t sl_watchdog_manager_force_feed (void )
Forces a hardware watchdog feed regardless of software watchdogs.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| void | N/A |
Forces an immediate feed of the hardware watchdog, bypassing the normal check that all enabled software watchdogs have been fed.
This is useful during initialization when software watchdogs may not all be created yet, or during long operations where normal feeding is not possible.
Returns
SL_STATUS_OK if successful.
SL_STATUS_NOT_INITIALIZED if sl_watchdog_manager_init() has not been called.
Note
Force feeding the watchdog can be useful during initialization or during long operations. Use with caution as it bypasses the normal watchdog protection mechanism.
sl_watchdog_manager_retrieve_faulty#
sl_status_t sl_watchdog_manager_retrieve_faulty (sl_watchdog_handle_t * handle)
Retrieves the software watchdog that caused a reset.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| sl_watchdog_handle_t * | [out] | handle | Pointer to variable that will receive the handle of the first faulty watchdog. Must not be NULL. |
After a reset caused by watchdog expiration, this function can be called to retrieve the handle of the first software watchdog that was not fed.
This function uses no_init variables to preserve state across resets. It must be called before sl_watchdog_manager_init() to retrieve the information from the previous reset.
The function works by comparing the faulty handle from the previous reset with newly created watchdogs. When a match is found during sl_watchdog_manager_create(), a debug message is logged with the watchdog UID.
Returns
SL_STATUS_OK if successful and a faulty watchdog was found.
SL_STATUS_NULL_POINTER if handle is NULL.
SL_STATUS_NOT_AVAILABLE if the reset was not caused by a watchdog.
SL_STATUS_INVALID_STATE if this function is called after sl_watchdog_manager_init().
Note
This function MUST be called before sl_watchdog_manager_init() to retrieve information from the previous reset.
Due to dynamic handle allocation, false positives may occur if handles are reused across resets. This is acceptable for debugging purposes.