Driver API for RSWDT (plib_rswdt.h)
More...
|
| void | RSWDT_Configure (uint16_t wdv, uint32_t mode) |
| | Configures the RSWDT with specified timeout and mode options. This function writes to RSWDT_MR which is a write-once register, so all settings must be configured together in a single RSWDT_Configure() call.
|
| |
| void | RSWDT_Restart (void) |
| | Clears (restarts) the Reinforced Safety Watchdog Timer. Resets the RSWDT counter by writing to RSWDT_CR with the correct password. This function can be called at any time to kick the watchdog.
|
| |
| void | RSWDT_SetCallbackHandler (RSWDT_CALLBACK_HANDLER callback) |
| | Registers the callback handler to be invoked from the RSWDT ISR.
|
| |
| bool | RSWDT_UnderflowIsSet (void) |
| | Checks if watchdog underflow has occurred (WDUNF). Watchdog Underflow is cleared on read.
|
| |
| bool | RSWDT_IsEnabled (void) |
| | Checks if the RSWDT is enabled.
|
| |
Driver API for RSWDT (plib_rswdt.h)
Usage Example
The following example demonstrates typical usage of the RSWDT peripheral:
#include <stdint.h>
#include <stdbool.h>
volatile bool rswdt_underflow_triggered = false;
static void RSWDT_FaultCallback(uint32_t status)
{
if ((status & RSWDT_SR_WDUNF_Msk) != 0U)
{
rswdt_underflow_triggered = true;
}
}
int32_t configure_rswdt(void)
{
const uint16_t rswdt_timeout_period_value = 0x800U;
RSWDT_MR_WDRSTEN_Msk | RSWDT_MR_WDFIEN_Msk | RSWDT_MR_WDDBGHLT_Msk);
return 0;
}
void RSWDT_Configure(uint16_t wdv, uint32_t mode)
Configures the RSWDT with specified timeout and mode options. This function writes to RSWDT_MR which ...
void RSWDT_Restart(void)
Clears (restarts) the Reinforced Safety Watchdog Timer. Resets the RSWDT counter by writing to RSWDT_...
void RSWDT_SetCallbackHandler(RSWDT_CALLBACK_HANDLER callback)
Registers the callback handler to be invoked from the RSWDT ISR.
◆ RSWDT_CALLBACK_HANDLER
| typedef void(* RSWDT_CALLBACK_HANDLER) (uint32_t status) |
Function pointer type for RSWDT callback.
- Parameters
-
| status | The RSWDT_SR register value indicating the interrupt source. Bit 0 (WDUNF): Watchdog Underflow occurred. |
◆ RSWDT_Configure()
| void RSWDT_Configure |
( |
uint16_t | wdv, |
|
|
uint32_t | mode ) |
Configures the RSWDT with specified timeout and mode options. This function writes to RSWDT_MR which is a write-once register, so all settings must be configured together in a single RSWDT_Configure() call.
- Parameters
-
| wdv | Watchdog Counter Value (12-bit, 0-4095). Defines the timeout period. |
| mode | Bitwise OR of the following RSWDT_MR_*_Msk mode options:
- RSWDT_MR_WDDIS_Msk - Disable watchdog
- RSWDT_MR_WDRSTEN_Msk - Enable watchdog reset
- RSWDT_MR_WDFIEN_Msk - Enable watchdog interrupt
- RSWDT_MR_WDIDLEHLT_Msk - Halt watchdog in idle mode
- RSWDT_MR_WDDBGHLT_Msk - Halt watchdog in debug mode
|
◆ RSWDT_IsEnabled()
| bool RSWDT_IsEnabled |
( |
void | | ) |
|
Checks if the RSWDT is enabled.
- Returns
- true if the RSWDT is enabled (WDDIS = 0), false if disabled.
◆ RSWDT_Restart()
| void RSWDT_Restart |
( |
void | | ) |
|
Clears (restarts) the Reinforced Safety Watchdog Timer. Resets the RSWDT counter by writing to RSWDT_CR with the correct password. This function can be called at any time to kick the watchdog.
◆ RSWDT_SetCallbackHandler()
Registers the callback handler to be invoked from the RSWDT ISR.
- Parameters
-
| callback | Pointer to the callback function. This function sets a user-defined function that will be called when a RSWDT fault (underflow) interrupt occurs. The callback receives the RSWDT_SR status value as an argument. |
◆ RSWDT_UnderflowIsSet()
| bool RSWDT_UnderflowIsSet |
( |
void | | ) |
|
Checks if watchdog underflow has occurred (WDUNF). Watchdog Underflow is cleared on read.
- Returns
- true if underflow flag is set, false otherwise.
- Note
- Reading RSWDT_SR clears the WDUNF flag.