Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Watchdog Interface

Watchdog Interface. More...

Data Structures

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

Typedefs

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

Functions

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

Watchdog options

#define WDT_OPT_PAUSE_IN_SLEEP   BIT(0)
 Pause watchdog timer when CPU is in sleep state.
 
#define WDT_OPT_PAUSE_HALTED_BY_DBG   BIT(1)
 Pause watchdog timer when CPU is halted by the debugger.
 

Watchdog behavior flags

#define WDT_FLAG_RESET_NONE   (0 << WDT_FLAG_RESET_SHIFT)
 Reset: none.
 
#define WDT_FLAG_RESET_CPU_CORE   (1 << WDT_FLAG_RESET_SHIFT)
 Reset: CPU core.
 
#define WDT_FLAG_RESET_SOC   (2 << WDT_FLAG_RESET_SHIFT)
 Reset: SoC.
 

Detailed Description

Watchdog Interface.

Since
1.0
Version
1.0.0

Macro Definition Documentation

◆ WDT_FLAG_RESET_CPU_CORE

#define WDT_FLAG_RESET_CPU_CORE   (1 << WDT_FLAG_RESET_SHIFT)

#include <include/zephyr/drivers/watchdog.h>

Reset: CPU core.

◆ WDT_FLAG_RESET_NONE

#define WDT_FLAG_RESET_NONE   (0 << WDT_FLAG_RESET_SHIFT)

#include <include/zephyr/drivers/watchdog.h>

Reset: none.

◆ WDT_FLAG_RESET_SOC

#define WDT_FLAG_RESET_SOC   (2 << WDT_FLAG_RESET_SHIFT)

#include <include/zephyr/drivers/watchdog.h>

Reset: SoC.

◆ WDT_OPT_PAUSE_HALTED_BY_DBG

#define WDT_OPT_PAUSE_HALTED_BY_DBG   BIT(1)

#include <include/zephyr/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/zephyr/drivers/watchdog.h>

Pause watchdog timer when CPU is in sleep state.

Typedef Documentation

◆ wdt_callback_t

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

#include <include/zephyr/drivers/watchdog.h>

Watchdog callback.

Parameters
devWatchdog device instance.
channel_idChannel identifier.

Function Documentation

◆ wdt_disable()

int wdt_disable ( const struct device dev)

#include <include/zephyr/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
devWatchdog device instance.
Return values
0If successful.
-EFAULTIf watchdog instance is not enabled.
-EPERMIf watchdog can not be disabled directly by application code.
-errnoIn case of any other failure.

◆ wdt_feed()

int wdt_feed ( const struct device dev,
int  channel_id 
)

#include <include/zephyr/drivers/watchdog.h>

Feed specified watchdog timeout.

Parameters
devWatchdog device instance.
channel_idChannel index.
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() call.
-EINVALIf there is no installed timeout for supplied channel.
-errnoIn case of any other failure.

◆ wdt_install_timeout()

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

#include <include/zephyr/drivers/watchdog.h>

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
devWatchdog device instance.
[in]cfgTimeout configuration.
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.
-errnoIn case of any other failure.

◆ wdt_setup()

int wdt_setup ( const struct device dev,
uint8_t  options 
)

#include <include/zephyr/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
devWatchdog device instance.
optionsConfiguration options (see WDT_OPT).
Return values
0If successful.
-ENOTSUPIf any of the set options is not supported.
-EBUSYIf watchdog instance has been already setup.
-errnoIn case of any other failure.