Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
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
14#ifndef ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
15#define ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
16
25
26#include <zephyr/types.h>
27#include <zephyr/sys/util.h>
28#include <zephyr/device.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
39
41#define WDT_OPT_PAUSE_IN_SLEEP BIT(0)
42
44#define WDT_OPT_PAUSE_HALTED_BY_DBG BIT(1)
45
47
53
56#define WDT_FLAG_RESET_SHIFT (0)
58#define WDT_FLAG_RESET_MASK (0x3 << WDT_FLAG_RESET_SHIFT)
60
62#define WDT_FLAG_RESET_NONE (0 << WDT_FLAG_RESET_SHIFT)
64#define WDT_FLAG_RESET_CPU_CORE (1 << WDT_FLAG_RESET_SHIFT)
66#define WDT_FLAG_RESET_SOC (2 << WDT_FLAG_RESET_SHIFT)
67
69
86
93typedef void (*wdt_callback_t)(const struct device *dev, int channel_id);
94
101#if defined(CONFIG_WDT_MULTISTAGE) || defined(__DOXYGEN__)
110#endif
113};
114
120
126typedef int (*wdt_api_setup)(const struct device *dev, uint8_t options);
127
133typedef int (*wdt_api_disable)(const struct device *dev);
134
140typedef int (*wdt_api_install_timeout)(const struct device *dev,
141 const struct wdt_timeout_cfg *cfg);
142
148typedef int (*wdt_api_feed)(const struct device *dev, int channel_id);
149
163
165
182__syscall int wdt_setup(const struct device *dev, uint8_t options);
183
184static inline int z_impl_wdt_setup(const struct device *dev, uint8_t options)
185{
186 return DEVICE_API_GET(wdt, dev)->setup(dev, options);
187}
188
203__syscall int wdt_disable(const struct device *dev);
204
205static inline int z_impl_wdt_disable(const struct device *dev)
206{
207 return DEVICE_API_GET(wdt, dev)->disable(dev);
208}
209
232static inline int wdt_install_timeout(const struct device *dev,
233 const struct wdt_timeout_cfg *cfg)
234{
235 return DEVICE_API_GET(wdt, dev)->install_timeout(dev, cfg);
236}
237
251__syscall int wdt_feed(const struct device *dev, int channel_id);
252
253static inline int z_impl_wdt_feed(const struct device *dev, int channel_id)
254{
255 return DEVICE_API_GET(wdt, dev)->feed(dev, channel_id);
256}
257
258#ifdef __cplusplus
259}
260#endif
261
263
264#include <zephyr/syscalls/watchdog.h>
265
266#endif /* ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
int(* wdt_api_feed)(const struct device *dev, int channel_id)
Callback API to feed a specified watchdog timeout.
Definition watchdog.h:148
int(* wdt_api_install_timeout)(const struct device *dev, const struct wdt_timeout_cfg *cfg)
Callback API to install a new timeout.
Definition watchdog.h:140
int(* wdt_api_setup)(const struct device *dev, uint8_t options)
Callback API to set up a watchdog instance.
Definition watchdog.h:126
int(* wdt_api_disable)(const struct device *dev)
Callback API to disable a watchdog instance.
Definition watchdog.h:133
void(* wdt_callback_t)(const struct device *dev, int channel_id)
Watchdog callback.
Definition watchdog.h:93
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.
Definition watchdog.h:232
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.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> Watchdog driver operations
Definition watchdog.h:153
wdt_api_install_timeout install_timeout
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition watchdog.h:159
wdt_api_setup setup
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition watchdog.h:155
wdt_api_feed feed
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition watchdog.h:161
wdt_api_disable disable
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition watchdog.h:157
Watchdog timeout configuration.
Definition watchdog.h:96
wdt_callback_t callback
Timeout callback (can be NULL).
Definition watchdog.h:100
struct wdt_timeout_cfg * next
Pointer to the next timeout configuration.
Definition watchdog.h:109
uint8_t flags
Flags (see WDT_FLAGS).
Definition watchdog.h:112
struct wdt_window window
Timing parameters of watchdog timeout.
Definition watchdog.h:98
Watchdog timeout window.
Definition watchdog.h:80
uint32_t max
Upper limit of watchdog feed timeout in milliseconds.
Definition watchdog.h:84
uint32_t min
Lower limit of watchdog feed timeout in milliseconds.
Definition watchdog.h:82
Misc utilities.