WATCHDOG
The WATCHDOG driver provides API for safety diagnostic which can detect a runaway CPU and generate either a reset or NMI (non-maskable interrupt) response. It generates resets or NMIs after a programmable period, or if no correct key sequence was written to the RTIWDKEY register.
Features Supported
Supports Watchdog interrupt mode.
Supports digital windowed Watchdog feature.
SysConfig Features
Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
Selection of Watchdog instances.
Option to select Watchdog Window size.
Option to select Watchdog expiry time in millisecond.
Features NOT Supported
Important Usage Guidelines
Important Usage Guildelines
Example Usage
Include the below file to access the APIs
Include
#include <drivers/watchdog.h>
Instance Open Example
Watchdog_Params params;
Watchdog_paramsInit(¶ms);
params.resetMode = Watchdog_RESET_ON;
gWatchdogHandle = Watchdog_open(CONFIG_WDT0, ¶ms);
if (!gWatchdogHandle) {
DebugP_assert(FALSE);
}
Instance Close Example
Watchdog_close(gWatchdogHandle);
Watchdog Service Example
Watchdog_clear(gWatchdogHandle);
Migration Guide 11.01 to 11.02 - AM62A
Note
This section highlights API changes from 11.01 to 11.02 SDK for AM62A.
Return type change for Watchdog_setReaction and Watchdog_setWindowSize
Watchdog_setReactionandWatchdog_setWindowSizereturn type changed fromvoidtoint32_t.Both functions now return
SystemP_SUCCESSon success,SystemP_FAILUREif handle is NULL.Update callers to handle the return value.
Migration Guide 11.02 to 12.00
Note
This section highlights API changes from 11.02 to 12.00 SDK.
Return type change for Watchdog_setReaction and Watchdog_setWindowSize
Watchdog_setReactionandWatchdog_setWindowSizereturn type changed fromvoidtoint32_t.Both functions now return
SystemP_SUCCESSon success,SystemP_FAILUREif handle is NULL.Update callers to handle the return value.
Examples and Demos
API Reference
This file contains the prototype of WDT driver APIs.
Defines
-
WATCHDOG_CLEAR_STATUS
macro to clear the status.
Typedefs
-
typedef struct Watchdog_Config_s *Watchdog_Handle
Watchdog Handle.
-
typedef void (*Watchdog_Callback)(Watchdog_Handle handle, void *callbackFxnArgs)
Watchdog callback pointer.
This is the typedef for the function pointer that will allow a callback function to be specified in the Watchdog_Params structure. The function will take Watchdog_Handle of the Watchdog and user argument as arguments.
Enums
-
enum Watchdog_DebugMode
Watchdog debug stall settings.
This enumeration defines the debug stall modes for the Watchdog. On some targets, the Watchdog timer will continue to count down while a debugging session is halted. To avoid unwanted resets, the Watchdog can be set to stall while the processor is stopped by the debugger.
Values:
-
enumerator Watchdog_DEBUG_STALL_ON
Watchdog will be stalled at breakpoints
-
enumerator Watchdog_DEBUG_STALL_OFF
Watchdog will keep running at breakpoints
-
enumerator Watchdog_DEBUG_STALL_ON
-
enum Watchdog_ResetMode
Watchdog reset mode settings.
This enumeration defines the reset modes for the Watchdog. The Watchdog can be configured to either generate a reset upon timeout or simply produce a periodic interrupt.
Values:
-
enumerator Watchdog_RESET_OFF
Timeouts generate NMI interrupt only
-
enumerator Watchdog_RESET_ON
Generates reset after timeout
-
enumerator Watchdog_RESET_OFF
-
enum Watchdog_WindowSize
Watchdog Window Size settings.
This enumeration defines the size of the digital watchdog window size.
Values:
-
enumerator Watchdog_WINDOW_100_PERCENT
Window size is 100%
-
enumerator Watchdog_WINDOW_50_PERCENT
Window size is 50%
-
enumerator Watchdog_WINDOW_25_PERCENT
Window size is 25%
-
enumerator Watchdog_WINDOW_12_5_PERCENT
Window size is 12.5%
-
enumerator Watchdog_WINDOW_6_25_PERCENT
Window size is 6.25%
-
enumerator Watchdog_WINDOW_3_125_PERCENT
Window size is 3.125%
-
enumerator Watchdog_WINDOW_100_PERCENT
Functions
-
void Watchdog_setReaction(Watchdog_Handle handle, uint32_t dwwdReaction)
Set DWWD reaction.
Note
DWWD need to be serviced if Reaction is changed when DWWD is enabled and Window is Open,to take immediate effect. If not serviced, DWWD will generated previously configured Reaction irrespective of current configuration.
If DWWD is enabled and Window is Close then any change in Reaction will take immediate effect. DWWD need not to be serviced in this case.
- Parameters:
handle – Watchdog Handle
dwwdReaction – DWWD reaction for violation/expiration. Values given by macro
-
uint32_t Watchdog_getWindowSize(Watchdog_Handle handle)
Get DWWD Window Size.
- Parameters:
handle – Watchdog Handle
- Returns:
Watchdog Window size.
-
void Watchdog_setWindowSize(Watchdog_Handle handle, uint32_t dwwdWindowSize)
Set DWWD Window Size.
Note
DWWD need to be serviced if Window Size is changed when DWWD is enabled and Window is Open,to take immediate effect. If not serviced, DWWD Window Size will not be changed irrespective of current configuration.
If DWWD is enabled and Window is Close then any change in Window Size will take immediate effect. DWWD need not to be serviced in this case.
- Parameters:
handle – Watchdog Handle
dwwdWindowSize – DWWD Window Size. Values given by macro
-
bool Watchdog_isClosedWindow(Watchdog_Handle handle)
The function checks for Closed Window.
- Parameters:
handle – Watchdog Handle
- Returns:
closed window status.
-
void Watchdog_clear(Watchdog_Handle handle)
The function clears the Watchdog to prevent a reset signal from being generated if the module is in Watchdog_RESET_ON reset mode.
- Parameters:
handle – Watchdog Handle
-
void Watchdog_close(Watchdog_Handle handle)
The function closes a Watchdog peripheral specified by the Watchdog handle. It stops (holds) the Watchdog counting on applicable platforms.
- Parameters:
handle – Watchdog Handle
-
void Watchdog_init(void)
The functions initializes the Watchdog module.
-
void Watchdog_deinit(void)
The functions de-initializes the Watchdog module.
-
Watchdog_Handle Watchdog_open(uint8_t index, Watchdog_Params *params)
Opens a Watchdog object with the index and parameters specified, and returns a Watchdog_Handle.
- Parameters:
index – Logical peripheral number for the Watchdog indexed into the Watchdog_Config table
params – Pointer to an parameter block, if NULL it will use default values.
- Returns:
A Watchdog_Handle on success or a NULL on an error or if it has been opened already.
-
void Watchdog_paramsInit(Watchdog_Params *params)
Function to set default values of Watchdog_Params in params.
- Parameters:
params – [IN] pointer to the structure to be initialized
-
struct Watchdog_HwAttrs
- #include <watchdog_rti.h>
Watchdog Driver HW configuration.
The structure is used to store the hardware specific configuration which is passed to each driver instance
-
struct Watchdog_Params
- #include <watchdog_rti.h>
Watchdog Parameters.
Watchdog parameters are used with the Watchdog_open() call. Default values for these parameters are set using Watchdog_Params_init().
Public Members
-
Watchdog_Callback callbackFxn
Pointer to callback. Valid when resetMode = Watchdog_RESET_OFF.
-
void *callbackFxnArgs
User argument for callback function
-
Watchdog_ResetMode resetMode
Mode to enable resets.
-
Watchdog_DebugMode debugStallMode
Mode to stall watchdog at breakpoints.
-
Watchdog_WindowSize windowSize
Windowed watchdog window size.
-
uint32_t expirationTime
Expiration time in millisecond (ms).
-
Watchdog_Callback callbackFxn
-
struct Watchdog_Config
- #include <watchdog_rti.h>
Watchdog Global configuration.
The Watchdog_Config structure contains a set of pointers used to characterize the Watchdog driver implementation.
This structure needs to be defined before calling Watchdog_init() and it must not be changed thereafter.
See also
-
struct Watchdog_MCB
- #include <watchdog_rti.h>
Watchdog Driver Master Control Block.
The structure is used to hold all the pertinent information with respect to the Watchdog Driver.
Public Members
-
Watchdog_DriverState state
Watchdog driver internal state.
-
Watchdog_Params params
Watchdog Parameters which were used to initialize the driver instance.
-
uint32_t interruptsRxed
Number of interrupts received. Valid only when resetMode = Watchdog_RESET_OFF.
-
uint32_t watchdogCleared
Number of times watchdog was serviced.
-
Watchdog_DriverState state