Watchdog
Overview
API Reference
- group watchdog_interface
Watchdog Interface.
Watchdog options
-
WDT_OPT_PAUSE_IN_SLEEP
Pause watchdog timer when CPU is in sleep state.
-
WDT_OPT_PAUSE_HALTED_BY_DBG
Pause watchdog timer when CPU is halted by the debugger.
Watchdog behavior flags
-
WDT_FLAG_RESET_NONE
Reset: none
-
WDT_FLAG_RESET_CPU_CORE
Reset: CPU core
-
WDT_FLAG_RESET_SOC
Reset: SoC
Typedefs
Functions
-
int wdt_setup(const struct device *dev, uint8_t options)
Set up watchdog instance.
This function is used for configuring global watchdog settings that affect all timeouts. It should be called after installing timeouts. After successful return, all installed timeouts are valid and must be serviced periodically by calling wdt_feed().
- Parameters
dev – Watchdog device instance.
options – Configuration options (see WDT_OPT).
- Return values
0 – If successful.
-ENOTSUP – If any of the set options is not supported.
-EBUSY – If watchdog instance has been already setup.
-errno – In case of any other failure.
-
int wdt_disable(const struct device *dev)
Disable watchdog instance.
This function disables the watchdog instance and automatically uninstalls all timeouts. To set up a new watchdog, install timeouts and call wdt_setup() again. Not all watchdogs can be restarted after they are disabled.
- Parameters
dev – Watchdog device instance.
- Return values
0 – If successful.
-EFAULT – If watchdog instance is not enabled.
-EPERM – If watchdog can not be disabled directly by application code.
-errno – In case of any other failure.
-
static inline int wdt_install_timeout(const struct device *dev, const struct wdt_timeout_cfg *cfg)
Install a new timeout.
Note
This function must be used before wdt_setup(). Changes applied here have no effects until wdt_setup() is called.
- Parameters
dev – Watchdog device instance.
cfg – [in] Timeout configuration.
- Return values
channel_id – If successful, a non-negative value indicating the index of the channel to which the timeout was assigned. This value is supposed to be used as the parameter in calls to wdt_feed().
-EBUSY – If timeout can not be installed while watchdog has already been setup.
-ENOMEM – If no more timeouts can be installed.
-ENOTSUP – If any of the set flags is not supported.
-EINVAL – If any of the window timeout value is out of possible range. This value is also returned if watchdog supports only one timeout value for all timeouts and the supplied timeout window differs from windows for alarms installed so far.
-errno – In case of any other failure.
-
int wdt_feed(const struct device *dev, int channel_id)
Feed specified watchdog timeout.
- Parameters
dev – Watchdog device instance.
channel_id – Channel index.
- Return values
0 – If successful.
-EAGAIN – If completing the feed operation would stall the caller, for example due to an in-progress watchdog operation such as a previous wdt_feed() call.
-EINVAL – If there is no installed timeout for supplied channel.
-errno – In case of any other failure.
-
struct wdt_window
- #include <watchdog.h>
Watchdog timeout window.
Each installed timeout needs feeding within the specified time window, otherwise the watchdog will trigger. If the watchdog instance does not support window timeouts then min value must be equal to 0.
Note
If specified values can not be precisely set they are always rounded up.
-
struct wdt_timeout_cfg
- #include <watchdog.h>
Watchdog timeout configuration.
Public Members
-
struct wdt_window window
Timing parameters of watchdog timeout.
-
wdt_callback_t callback
Timeout callback (can be
NULL
).
-
struct wdt_timeout_cfg *next
Pointer to the next timeout configuration.
This field is only available if
CONFIG_WDT_MULTISTAGE
is enabled (watchdogs with staged timeouts functionality). Value must beNULL
for single stage timeout.
-
struct wdt_window window
-
WDT_OPT_PAUSE_IN_SLEEP