Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Watchdog Interface

Watchdog Interface. More...

Data Structures

struct  wdt_window
 Watchdog timeout window. More...
 
struct  wdt_timeout_cfg
 Watchdog timeout configuration struct. More...
 

Macros

#define WDT_OPT_PAUSE_IN_SLEEP   BIT(0)
 Pause watchdog timer when CPU is in sleep state. More...
 
#define WDT_OPT_PAUSE_HALTED_BY_DBG   BIT(1)
 Pause watchdog timer when CPU is halted by the debugger. More...
 
#define WDT_FLAG_RESET_SHIFT   (0)
 Watchdog reset flag bit field mask shift. More...
 
#define WDT_FLAG_RESET_MASK   (0x3 << WDT_FLAG_RESET_SHIFT)
 Watchdog reset flag bit field mask. More...
 

Typedefs

typedef void(* wdt_callback_t) (const struct device *dev, int channel_id)
 
typedef int(* wdt_api_setup) (const struct device *dev, uint8_t options)
 Callback API for setting up watchdog instance. See wdt_setup() for argument descriptions. More...
 
typedef int(* wdt_api_disable) (const struct device *dev)
 Callback API for disabling watchdog instance. See wdt_disable() for argument descriptions. More...
 
typedef int(* wdt_api_install_timeout) (const struct device *dev, const struct wdt_timeout_cfg *cfg)
 Callback API for installing new timeout. See wdt_install_timeout() for argument descriptions. More...
 
typedef int(* wdt_api_feed) (const struct device *dev, int channel_id)
 Callback API for feeding specified watchdog timeout. See (wdt_feed) for argument descriptions. More...
 

Functions

int wdt_setup (const struct device *dev, uint8_t options)
 Set up watchdog instance. More...
 
int wdt_disable (const struct device *dev)
 Disable watchdog instance. More...
 
static int wdt_install_timeout (const struct device *dev, const struct wdt_timeout_cfg *cfg)
 Install new timeout. More...
 
int wdt_feed (const struct device *dev, int channel_id)
 Feed specified watchdog timeout. More...
 

Watchdog Reset Behavior.

Reset behavior after timeout.

#define WDT_FLAG_RESET_NONE   (0 << WDT_FLAG_RESET_SHIFT)
 
#define WDT_FLAG_RESET_CPU_CORE   (1 << WDT_FLAG_RESET_SHIFT)
 
#define WDT_FLAG_RESET_SOC   (2 << WDT_FLAG_RESET_SHIFT)
 

Detailed Description

Watchdog Interface.

Macro Definition Documentation

◆ WDT_FLAG_RESET_CPU_CORE

#define WDT_FLAG_RESET_CPU_CORE   (1 << WDT_FLAG_RESET_SHIFT)

#include <include/drivers/watchdog.h>

CPU core reset

◆ WDT_FLAG_RESET_MASK

#define WDT_FLAG_RESET_MASK   (0x3 << WDT_FLAG_RESET_SHIFT)

#include <include/drivers/watchdog.h>

Watchdog reset flag bit field mask.

◆ WDT_FLAG_RESET_NONE

#define WDT_FLAG_RESET_NONE   (0 << WDT_FLAG_RESET_SHIFT)

#include <include/drivers/watchdog.h>

No reset

◆ WDT_FLAG_RESET_SHIFT

#define WDT_FLAG_RESET_SHIFT   (0)

#include <include/drivers/watchdog.h>

Watchdog reset flag bit field mask shift.

◆ WDT_FLAG_RESET_SOC

#define WDT_FLAG_RESET_SOC   (2 << WDT_FLAG_RESET_SHIFT)

#include <include/drivers/watchdog.h>

Global SoC reset

◆ WDT_OPT_PAUSE_HALTED_BY_DBG

#define WDT_OPT_PAUSE_HALTED_BY_DBG   BIT(1)

#include <include/drivers/watchdog.h>

Pause watchdog timer when CPU is halted by the debugger.

◆ WDT_OPT_PAUSE_IN_SLEEP

#define WDT_OPT_PAUSE_IN_SLEEP   BIT(0)

#include <include/drivers/watchdog.h>

Pause watchdog timer when CPU is in sleep state.

Typedef Documentation

◆ wdt_api_disable

wdt_api_disable

#include <include/drivers/watchdog.h>

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

◆ wdt_api_feed

wdt_api_feed

#include <include/drivers/watchdog.h>

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

◆ wdt_api_install_timeout

wdt_api_install_timeout

#include <include/drivers/watchdog.h>

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

◆ wdt_api_setup

wdt_api_setup

#include <include/drivers/watchdog.h>

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

◆ wdt_callback_t

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

#include <include/drivers/watchdog.h>

Watchdog callback.

Function Documentation

◆ wdt_disable()

int wdt_disable ( const struct device dev)

#include <include/drivers/watchdog.h>

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
devPointer to the device structure for the driver instance.
Return values
0If successful.
-EFAULTIf watchdog instance is not enabled.
-EPERMIf watchdog can not be disabled directly by application code.

◆ wdt_feed()

int wdt_feed ( const struct device dev,
int  channel_id 
)

#include <include/drivers/watchdog.h>

Feed specified watchdog timeout.

Parameters
devPointer to the device structure for the driver instance.
channel_idIndex of the fed channel.
Return values
0If successful.
-EAGAINIf completing the feed operation would stall the caller, for example due to an in-progress watchdog operation such as a previous wdt_feed().
-EINVALIf there is no installed timeout for supplied channel.

◆ wdt_install_timeout()

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

#include <include/drivers/watchdog.h>

Install new timeout.

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

Parameters
devPointer to the device structure for the driver instance.
cfgPointer to timeout configuration structure.
Return values
channel_idIf 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().
-EBUSYIf timeout can not be installed while watchdog has already been setup.
-ENOMEMIf no more timeouts can be installed.
-ENOTSUPIf any of the set flags is not supported.
-EINVALIf 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.

◆ wdt_setup()

int wdt_setup ( const struct device dev,
uint8_t  options 
)

#include <include/drivers/watchdog.h>

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
devPointer to the device structure for the driver instance.
optionsConfiguration options as defined by the WDT_OPT_* constants
Return values
0If successful.
-ENOTSUPIf any of the set options is not supported.
-EBUSYIf watchdog instance has been already setup.