This is the documentation for the latest (master) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.



API Reference

group watchdog_interface

Watchdog Interface.

Watchdog Reset Behavior.

Reset behavior after timeout.


No reset


CPU core reset


Global SoC reset



Pause watchdog timer when CPU is in sleep state.


Pause watchdog timer when CPU is halted by the debugger.


Watchdog reset flag bit field mask shift.


Watchdog reset flag bit field mask.


typedef void (*wdt_callback_t)(struct device *dev, int channel_id)

Watchdog callback.

typedef wdt_api_setup

Callback API for setting up watchdog instance. See wdt_setup() for argument descriptions.

typedef wdt_api_disable

Callback API for disabling watchdog instance. See wdt_disable() for argument descriptions.

typedef wdt_api_install_timeout

Callback API for installing new timeout. See wdt_install_timeout() for argument descriptions.

typedef wdt_api_feed

Callback API for feeding specified watchdog timeout. See (wdt_feed) for argument descriptions.


int wdt_setup(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().

  • dev: Pointer to the device structure for the driver instance.

  • options: Configuration options as defined by the WDT_OPT_* constants

Return Value
  • 0: If successful.

  • -ENOTSUP: If any of the set options is not supported.

  • -EBUSY: If watchdog instance has been already setup.

int wdt_disable(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.

  • dev: Pointer to the device structure for the driver instance.

Return Value
  • 0: If successful.

  • -EFAULT: If watchdog instance is not enabled.

  • -EPERM: If watchdog can not be disabled directly by application code.

static int wdt_install_timeout(struct device *dev, const struct wdt_timeout_cfg *cfg)

Install new timeout.

This function must be used before wdt_setup(). Changes applied here have no effects until wdt_setup() is called.

  • dev: Pointer to the device structure for the driver instance.

  • cfg: Pointer to timeout configuration structure.

Return Value
  • 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.

int wdt_feed(struct device *dev, int channel_id)

Feed specified watchdog timeout.

  • dev: Pointer to the device structure for the driver instance.

  • channel_id: Index of the fed channel.

Return Value
  • 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().

  • -EINVAL: If there is no installed timeout for supplied channel.

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.


If specified values can not be precisely set they are always rounded up.

  • min: Lower limit of watchdog feed timeout in milliseconds.

  • max: Upper limit of watchdog feed timeout in milliseconds.

struct wdt_timeout_cfg
#include <watchdog.h>

Watchdog timeout configuration struct.

  • window: Timing parameters of watchdog timeout.

  • callback: Timeout callback. Passing NULL means that no callback will be run.

  • next: Pointer to the next timeout configuration. This pointer is used for watchdogs with staged timeouts functionality. Value must be NULL for single stage timeout.

  • flags: Bit field with following parts:

    reset        [ 0 : 1 ]   - perform specified reset after timeout/callback