CMSIS-Driver_PIC32CZ-CA70  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
RSWDT Interface

Driver API for RSWDT (plib_rswdt.h) More...

Typedefs

typedef void(* RSWDT_CALLBACK_HANDLER) (uint32_t status)
 Function pointer type for RSWDT callback.
 

Functions

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.
 

Description

Driver API for RSWDT (plib_rswdt.h)

Usage Example

The following example demonstrates typical usage of the RSWDT peripheral:

#include "plib_rswdt.h"
#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;
/* Register callback handler for RSWDT fault */
RSWDT_SetCallbackHandler(&RSWDT_FaultCallback);
/* Configure RSWDT with all settings in one call (write-once register)
* - Timeout: 0x800 (~8 seconds at 32kHz)
* - Reset on fault: enabled
* - Fault interrupt: enabled
* - Idle halt: disabled (keep running in idle)
* - Debug halt: enabled (stop during debug)
*/
RSWDT_Configure(rswdt_timeout_period_value,
RSWDT_MR_WDRSTEN_Msk | RSWDT_MR_WDFIEN_Msk | RSWDT_MR_WDDBGHLT_Msk);
/* Initial kick to start timeout period */
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.

Typedef Documentation

◆ RSWDT_CALLBACK_HANDLER

typedef void(* RSWDT_CALLBACK_HANDLER) (uint32_t status)

Function pointer type for RSWDT callback.

Parameters
statusThe RSWDT_SR register value indicating the interrupt source. Bit 0 (WDUNF): Watchdog Underflow occurred.

Function Documentation

◆ 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
wdvWatchdog Counter Value (12-bit, 0-4095). Defines the timeout period.
modeBitwise 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()

void RSWDT_SetCallbackHandler ( RSWDT_CALLBACK_HANDLER callback)

Registers the callback handler to be invoked from the RSWDT ISR.

Parameters
callbackPointer 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.