3.2.28 DIAG_WDT
The DIAG_WDT module is designed to verify the correct functionality of the Watchdog (WDT) through a set of C function calls.
The DIAG_WDT software test API is mapped to the following safety mechanisms:
| Function | Diagnostic Mechanism | Use Case | Elapse Time (μs)~ |
|---|---|---|---|
| DIAG_WDT_Disable() | WDT_DISABLE | POST / OnDemand | 2520.29 |
| DIAG_WDT_Enable() | WDT_ENABLE | POST / OnDemand | 3964.89 |
| DIAG_WDT_Interrupts() | WDT_INTERRUPTS | POST | 6.15 |
| DIAG_WDT_SFRReset() | SFR_RESET | POST | 32.42 |
| DIAG_WDT_SFRWriteRead() | SFR_WRITE_READ | POST / OnDemand | 30.77 |
| DIAG_WDT_SimpleStartup() |
WDT_SIMPLE_STARTUP | POST | 4507.41 |
#define WDT_MAX_WAIT_LOOPS 0x10
#define NUM_OF_WDTs 1
typedef enum
{
DIAG_WDT_STATE_1,
DIAG_WDT_STATE_2,
DIAG_WDT_STATE_3,
DIAG_WDT_STATE_4,
DIAG_WDT_PASSED,
} DIAG_WDT_STATE;
typedef enum
{
DIAG_WDT_SS_PRE_RESET,
DIAG_WDT_SS_POST_RESET,
DIAG_WDT_SS_FAILED,
}DIAG_WDT_SS_STATES;
typedef enum
{
DIAG_WDT_WS_PRE_RESET,
DIAG_WDT_WS_POST_TOO_EARLY,
DIAG_WDT_WS_POST_TOO_LATE,
DIAG_WDT_WS_FAILED,
}DIAG_WDT_WS_STATES;
typedef enum
{
DIAG_WDT_TD_PRE_RESET,
DIAG_WDT_TD_POST_RESET,
DIAG_WDT_TD_FAILED,
}DIAG_WDT_TD_STATES;
typedef enum diag_wdt_nums
{
DIAG_WDT_NUM = 0,
DIAG_WDT_MAX
}DIAG_WDT_NUMBERS;
typedef enum diag_wdt_periphs
{
DIAG_WDT_PERIPH = 1<<DIAG_WDT_NUM,
}DIAG_WDT_PERIPHS;
#define DIAG_WDT_PERIPHS_CHECK_VALUE DIAG_WDT_PERIPH
extern DIAG_WDT_SS_STATES __attribute__((section(".persist"))) wdt_ss_state; // WDT simple startup states
extern DIAG_WDT_WS_STATES __attribute__((section(".persist"))) wdt_ws_state; // WDT window startup states
extern DIAG_WDT_TD_STATES __attribute__((section(".persist"))) wdt_td_state; // WDT tmr disable startup states
extern uint8_t __attribute__((section(".persist"))) wdt_state; // WDT states
Configuring the Diagnostic
DIAG_WDT does not require additional configuration.
Run-time Pre-requisites
DIAG_WDT_SFRRead should be executed before DIAG_WDT_SFRWriteRead
DIAG_WDT_SFRWriteRead should not be executed during OnDemand if the WDT peripheral is enabled.
DIAG_WDT_SimpleStartup should be executed in two passes to get a accurante result
Using the Diagnostic
The DIAG_WDT_SimpleStartup() API implements an internal state machine.
Note: Refer Suggested Application Architecture section to establish the appropriate application design.
#include "definitions.h"
DIAG_TEST_STATUS DIAG_WDT_SFRPost( void )
{
DIAG_TEST_STATUS result;
result = DIAG_WDT_SFRReset(NULL,0,false);
if( result == DIAG_TEST_PASSED )
{
result = DIAG_WDT_SFRWriteRead(NULL,0,false);
}
return result;
}
DIAG_TEST_STATUS DIAG_WDT_Post( void )
{
DIAG_TEST_STATUS result;
// Check if all dependencies have been tested
PAC_PeripheralProtectSetup(PAC_PERIPHERAL_WDT, PAC_PROTECTION_CLEAR);
result = DIAG_WDT_SimpleStartup();
if (result == DIAG_TEST_PASSED)
{
result = DIAG_WDT_Interrupts();
}
WDT_Disable();
PAC_PeripheralProtectSetup(PAC_PERIPHERAL_WDT, PAC_PROTECTION_SET);
return result;
}
