S32 SDK

Detailed Description

Watchdog Timer Peripheral Driver.

How to use the WDOG driver in your application

In order to be able to use the Watchdog in your application, the first thing to do is initializing it with the desired configuration. This is done by calling the WDOG_DRV_Init function. One of the arguments passed to this function is the configuration which will be used for the Watchdog, specified by the wdog_user_config_t structure.

The wdog_user_config_t structure allows you to configure the following:

Please note that if the updates are disabled the Watchdog cannot be later modified without forcing a reset (this implies that further calls of the WDOG_DRV_Init, WDOG_DRV_Deinit or WDOG_DRV_SetInt functions will lead to a reset).

As mentioned before, a timeout interrupt may be enabled by specifying it at the module initialization. The WDOG_DRV_Init only allows enabling/disabling the interrupt, and it does not set up the ISR to be used for the interrupt request. In order to set up a function to be called after a reset-triggering event (and also enable/disable the interrupt), the WDOG_DRV_SetInt function may be used. Please note that, due to the 128 bus clocks delay before the reset, a limited amount of job can be done in the ISR.

Example:

wdog_user_config_t userConfigPtr = {
WDOG_LPO_CLOCK, /* Use the LPO clock as source */
{ false, false, false }, /* WDOG not functional in Wait/Debug/Stop mode */
true, /* Enable further updates of the WDOG configuration */
false, /* Timeout interrupt disabled */
true, /* Window mode enabled */
0x100, /* Window value */
0x400, /* Timeout value */
false /* Prescaler disabled */
};
WDOG_DRV_Init(0, &userConfigPtr);
/* Enable the timeout interrupt and set the ISR */
WDOG_DRV_SetInt(0, true, wdogIntHandler);
while (1) {
/* Do something that takes between 0x100 and 0x400 clock cycles */
/* Refresh the counter */
}

Variables

WDOG_Type *const g_wdogBase [WDOG_INSTANCE_COUNT]
 Table of base addresses for WDOG instances. More...
 
const IRQn_Type g_wdogIrqId [WDOG_INSTANCE_COUNT]
 Table to save WDOG IRQ enum numbers defined in CMSIS header file. More...
 

WDOG Driver API

status_t WDOG_DRV_Init (uint32_t instance, const wdog_user_config_t *userConfigPtr)
 Initializes the WDOG driver. More...
 
void WDOG_DRV_Deinit (uint32_t instance)
 De-initializes the WDOG driver. More...
 
void WDOG_DRV_GetConfig (uint32_t instance, wdog_user_config_t *config)
 Gets the current configuration of the WDOG. More...
 
status_t WDOG_DRV_SetInt (uint32_t instance, bool enable, void(*handler)(void))
 Enables/Disables the WDOG timeout interrupt and sets a function to be called when a timeout interrupt is received, before reset. More...
 
void WDOG_DRV_Trigger (uint32_t instance)
 Refreshes the WDOG counter. More...
 

Function Documentation

void WDOG_DRV_Deinit ( uint32_t  instance)

De-initializes the WDOG driver.

Parameters
[in]instanceWDOG peripheral instance number

Definition at line 146 of file wdog_driver.c.

void WDOG_DRV_GetConfig ( uint32_t  instance,
wdog_user_config_t config 
)

Gets the current configuration of the WDOG.

Parameters
[in]instanceWDOG peripheral instance number
[out]configthe current configuration

Definition at line 208 of file wdog_driver.c.

status_t WDOG_DRV_Init ( uint32_t  instance,
const wdog_user_config_t userConfigPtr 
)

Initializes the WDOG driver.

Parameters
[in]instanceWDOG peripheral instance number
[in]userConfigPtrpointer to the WDOG user configuration structure
Returns
operation status
  • STATUS_SUCCESS: Operation was successful.
  • STATUS_ERROR: Operation failed. Possible causes: previous clock source or the one specified in the configuration structure is disabled; WDOG configuration updates are not allowed.

Definition at line 106 of file wdog_driver.c.

status_t WDOG_DRV_SetInt ( uint32_t  instance,
bool  enable,
void(*)(void)  handler 
)

Enables/Disables the WDOG timeout interrupt and sets a function to be called when a timeout interrupt is received, before reset.

Parameters
[in]instanceWDOG peripheral instance number
[in]enableenable/disable interrupt
[in]handlertimeout interrupt handler
Returns
operation status
  • STATUS_SUCCESS: Operation was successful.
  • STATUS_ERROR: Operation failed. Possible causes: failed to install handler; WDOG configuration updates not allowed.

Definition at line 227 of file wdog_driver.c.

void WDOG_DRV_Trigger ( uint32_t  instance)

Refreshes the WDOG counter.

Parameters
[in]instanceWDOG peripheral instance number

Definition at line 269 of file wdog_driver.c.

Variable Documentation

WDOG_Type* const g_wdogBase[WDOG_INSTANCE_COUNT]

Table of base addresses for WDOG instances.

Definition at line 55 of file wdog_driver.c.

const IRQn_Type g_wdogIrqId[WDOG_INSTANCE_COUNT]

Table to save WDOG IRQ enum numbers defined in CMSIS header file.

Definition at line 58 of file wdog_driver.c.