API Reference
Normative
The watchdog driver API contract. A conformant driver MUST provide these types and functions with the behavior described. Function and type signatures are extracted from the driver headers with Doxygen/Breathe. Keywords per Requirement Keywords; behavioral rules in Wdg — Requirements; error codes in Errors.
Data types at a glance
Type |
Kind |
Purpose |
|---|---|---|
struct |
Root configuration structure (build-time; |
|
enum |
Watchdog mode (OFF / NORMAL / ALTERNATIVE). |
API at a glance
Function |
Group |
Purpose |
|---|---|---|
Initialization |
Initialize the driver and watchdog HW in the default mode. |
|
Mode and timeout |
Switch the watchdog mode. |
|
Mode and timeout |
Refresh the reset timeout. |
|
Mode and timeout |
Trigger the HW periodically (logical strategy only). |
Expected interfaces at a glance
Integration interfaces the integrator MUST provide where applicable (CHI-WDG-MUST-06); all are documented in the general reference. Interface names are configurable via the driver configuration.
Function |
Kind |
Purpose |
|---|---|---|
Common (optional) |
Reports development errors with a log level. |
|
|
Common (optional) |
Bracket sections requiring exclusive access — see critical sections. |
For an external watchdog the driver may additionally depend on a bus interface driver (e.g. SPI or I2C) it is configured to control the hardware through.
Data types
-
struct Wdg_ConfigType
Configuration structure type.
Configuration variants are selected at build time; Wdg_Init currently takes NULL_PTR.
Available via: Wdg.h
-
enum Wdg_ModeType
Mode type of watchdog hardware.
Values:
-
enumerator WDG_MODE_OFF = 0x00
Watchdog hardware is disabled (switched off)
-
enumerator WDG_MODE_NORMAL = 0x01
Watchdog hardware is in normal mode. Typically used during application running.
-
enumerator WDG_MODE_ALTERNATIVE = 0x02
Watchdog hardware is in alternative mode. Typically used during startup or standby sequence.
-
enumerator WDG_MODE_OFF = 0x00
Available via: WdgIf_DriverTypes.h
Initialization
-
void Wdg_Init(const Wdg_ConfigType *configPtr)
Initializes the module.
- Sync/Async:
Synchronous
- Reentrancy:
Non Reentrant
- Service ID [hex]:
0x00
- Development error(s):
WDG_DEVERR_DRIVER_STATE WdgDrv is initialized already
WDG_DEVERR_PARAM_POINTER configPtr argument is not NULL pointer
- Parameters:
configPtr – [in] Pointer to the configuration structure. This parameter is intended for future extensions to support runtime-selectable configuration variants, which allow the selection and initialization of specific variants during runtime. As this functionality is not currently supported, a NULL_PTR SHALL be provided.
- Returns:
None.
When to call: once, before any other watchdog function. configPtr MUST be NULL_PTR.
Effect: initialises the driver and watchdog hardware, applying the configured default mode
and initial timeout. Errors: see Errors. Available via: Wdg.h
Mode and timeout
-
Std_ReturnType Wdg_SetMode(Wdg_ModeType mode)
Switches the watchdog into the specified mode.
- Sync/Async:
Synchronous
- Reentrancy:
Non Reentrant
- Service ID [hex]:
0x01
- Development error(s):
WDG_DEVERR_DRIVER_STATE WdgDrv is not initialized
WDG_DEVERR_PARAM_MODE The given mode is not supported
- Parameters:
mode – [in] Watchdog mode to be switched to
- Return values:
E_OK – Other than development error
E_NOT_OK – In case of development error.
- Returns:
Std_ReturnType.
Effect: switches the watchdog to mode, applies its hardware settings, and resets the
timeout to the mode’s default. Returns: E_OK if accepted, else E_NOT_OK (development
error). For the logical strategy, if the previous timeout has already expired the mode is not
changed. Errors: see Errors. Available via: Wdg.h
-
void Wdg_UpdateTimeout(uint16 timeout)
Specifies how long watchdog reset is suspended. Watchdog reset gets delayed till the new timeout has been expired.
- Sync/Async:
Synchronous
- Reentrancy:
Non Reentrant
- Service ID [hex]:
0x03
- Development error(s):
WDG_DEVERR_DRIVER_STATE WdgDrv is not initialized
WDG_DEVERR_PARAM_TIMEOUT Given timeout value is over than supported maximum timeout value in the configuration and current mode.
- Parameters:
timeout – [in] Timeout value (milliseconds) for watchdog hardware timeout.
- Returns:
None.
Effect: delays the watchdog reset until timeout milliseconds elapse (bounded by the
configured maximum_timeout). timeout = 0 requests an (almost) immediate reset. For the
logical strategy, an already-expired previous timeout is not overwritten. Errors: see
Errors. Available via: Wdg.h
-
void Wdg_FeedHw(void)
Trigger watchdog hardware. Intended to be called from periodic timer handler. This interface is only required for “logical timeout management”. “Direct timeout management” does not use this interface.
- Sync/Async:
Synchronous
- Reentrancy:
Non Reentrant
- Service ID [hex]:
0x05
- Development error(s):
WDG_DEVERR_DRIVER_STATE WdgDrv is not initialized
- Parameters:
None –
- Returns:
None.
When to call: periodically, from the upper layer’s timer handler — logical strategy
only (the direct strategy does not use it). It decrements the logical timeout by the call
interval and re-triggers the hardware only while the timeout has not expired. Setting up the
timer is the upper layer’s responsibility. Errors: see Errors. Available via:
Wdg.h