Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
watchdog.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Nordic Semiconductor ASA
3 * Copyright (c) 2015 Intel Corporation
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13#ifndef ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
14#define ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
15
23#include <zephyr/types.h>
24#include <sys/util.h>
25#include <device.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
34#define WDT_OPT_PAUSE_IN_SLEEP BIT(0)
35
39#define WDT_OPT_PAUSE_HALTED_BY_DBG BIT(1)
40
44#define WDT_FLAG_RESET_SHIFT (0)
48#define WDT_FLAG_RESET_MASK (0x3 << WDT_FLAG_RESET_SHIFT)
49
56#define WDT_FLAG_RESET_NONE (0 << WDT_FLAG_RESET_SHIFT)
58#define WDT_FLAG_RESET_CPU_CORE (1 << WDT_FLAG_RESET_SHIFT)
60#define WDT_FLAG_RESET_SOC (2 << WDT_FLAG_RESET_SHIFT)
78struct wdt_window {
81};
82
84typedef void (*wdt_callback_t)(const struct device *dev, int channel_id);
85
102#ifdef CONFIG_WDT_MULTISTAGE
103 struct wdt_timeout_cfg *next;
104#endif
106};
107
113typedef int (*wdt_api_setup)(const struct device *dev, uint8_t options);
114
120typedef int (*wdt_api_disable)(const struct device *dev);
121
127typedef int (*wdt_api_install_timeout)(const struct device *dev,
128 const struct wdt_timeout_cfg *cfg);
129
135typedef int (*wdt_api_feed)(const struct device *dev, int channel_id);
136
138__subsystem struct wdt_driver_api {
139 wdt_api_setup setup;
140 wdt_api_disable disable;
141 wdt_api_install_timeout install_timeout;
142 wdt_api_feed feed;
143};
163__syscall int wdt_setup(const struct device *dev, uint8_t options);
164
165static inline int z_impl_wdt_setup(const struct device *dev, uint8_t options)
166{
167 const struct wdt_driver_api *api =
168 (const struct wdt_driver_api *)dev->api;
169
170 return api->setup(dev, options);
171}
172
186__syscall int wdt_disable(const struct device *dev);
187
188static inline int z_impl_wdt_disable(const struct device *dev)
189{
190 const struct wdt_driver_api *api =
191 (const struct wdt_driver_api *)dev->api;
192
193 return api->disable(dev);
194}
195
218static inline int wdt_install_timeout(const struct device *dev,
219 const struct wdt_timeout_cfg *cfg)
220{
221 const struct wdt_driver_api *api =
222 (const struct wdt_driver_api *) dev->api;
223
224 return api->install_timeout(dev, cfg);
225}
226
239__syscall int wdt_feed(const struct device *dev, int channel_id);
240
241static inline int z_impl_wdt_feed(const struct device *dev, int channel_id)
242{
243 const struct wdt_driver_api *api =
244 (const struct wdt_driver_api *)dev->api;
245
246 return api->feed(dev, channel_id);
247}
248
249#ifdef __cplusplus
250}
251#endif
252
257#include <syscalls/watchdog.h>
258
259#endif /* _ZEPHYR_WATCHDOG_H__ */
void
Definition: eswifi_shell.c:15
void(* wdt_callback_t)(const struct device *dev, int channel_id)
Definition: watchdog.h:84
int(* wdt_api_disable)(const struct device *dev)
Callback API for disabling watchdog instance. See wdt_disable() for argument descriptions.
Definition: watchdog.h:120
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 new timeout.
Definition: watchdog.h:218
int wdt_setup(const struct device *dev, uint8_t options)
Set up watchdog instance.
int wdt_feed(const struct device *dev, int channel_id)
Feed specified watchdog timeout.
int(* wdt_api_feed)(const struct device *dev, int channel_id)
Callback API for feeding specified watchdog timeout. See (wdt_feed) for argument descriptions.
Definition: watchdog.h:135
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.
Definition: watchdog.h:127
int(* wdt_api_setup)(const struct device *dev, uint8_t options)
Callback API for setting up watchdog instance. See wdt_setup() for argument descriptions.
Definition: watchdog.h:113
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
Watchdog timeout configuration struct.
Definition: watchdog.h:99
wdt_callback_t callback
Definition: watchdog.h:101
uint8_t flags
Definition: watchdog.h:105
struct wdt_window window
Definition: watchdog.h:100
Watchdog timeout window.
Definition: watchdog.h:78
uint32_t max
Definition: watchdog.h:80
uint32_t min
Definition: watchdog.h:79
Misc utilities.