Zephyr API Documentation 4.4.0-rc2
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 const struct wdt_driver_api *api =
187 (const struct wdt_driver_api *)dev->api;
188
189 return api->setup(dev, options);
190}
191
206__syscall int wdt_disable(const struct device *dev);
207
208static inline int z_impl_wdt_disable(const struct device *dev)
209{
210 const struct wdt_driver_api *api =
211 (const struct wdt_driver_api *)dev->api;
212
213 return api->disable(dev);
214}
215
238static inline int wdt_install_timeout(const struct device *dev,
239 const struct wdt_timeout_cfg *cfg)
240{
241 const struct wdt_driver_api *api =
242 (const struct wdt_driver_api *) dev->api;
243
244 return api->install_timeout(dev, cfg);
245}
246
260__syscall int wdt_feed(const struct device *dev, int channel_id);
261
262static inline int z_impl_wdt_feed(const struct device *dev, int channel_id)
263{
264 const struct wdt_driver_api *api =
265 (const struct wdt_driver_api *)dev->api;
266
267 return api->feed(dev, channel_id);
268}
269
270#ifdef __cplusplus
271}
272#endif
273
275
276#include <zephyr/syscalls/watchdog.h>
277
278#endif /* ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_ */
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:238
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
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
<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.