Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
8#ifndef ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
9#define ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
10
18#include <zephyr/types.h>
19#include <zephyr/sys/util.h>
20#include <zephyr/device.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
33#define WDT_OPT_PAUSE_IN_SLEEP BIT(0)
34
36#define WDT_OPT_PAUSE_HALTED_BY_DBG BIT(1)
37
48#define WDT_FLAG_RESET_SHIFT (0)
50#define WDT_FLAG_RESET_MASK (0x3 << WDT_FLAG_RESET_SHIFT)
54#define WDT_FLAG_RESET_NONE (0 << WDT_FLAG_RESET_SHIFT)
56#define WDT_FLAG_RESET_CPU_CORE (1 << WDT_FLAG_RESET_SHIFT)
58#define WDT_FLAG_RESET_SOC (2 << WDT_FLAG_RESET_SHIFT)
59
72struct wdt_window {
77};
78
85typedef void (*wdt_callback_t)(const struct device *dev, int channel_id);
86
93#if defined(CONFIG_WDT_MULTISTAGE) || defined(__DOXYGEN__)
102#endif
105};
106
113typedef int (*wdt_api_setup)(const struct device *dev, uint8_t options);
114
119typedef int (*wdt_api_disable)(const struct device *dev);
120
125typedef int (*wdt_api_install_timeout)(const struct device *dev,
126 const struct wdt_timeout_cfg *cfg);
127
132typedef int (*wdt_api_feed)(const struct device *dev, int channel_id);
133
134__subsystem struct wdt_driver_api {
135 wdt_api_setup setup;
136 wdt_api_disable disable;
137 wdt_api_install_timeout install_timeout;
138 wdt_api_feed feed;
139};
160__syscall int wdt_setup(const struct device *dev, uint8_t options);
161
162static inline int z_impl_wdt_setup(const struct device *dev, uint8_t options)
163{
164 const struct wdt_driver_api *api =
165 (const struct wdt_driver_api *)dev->api;
166
167 return api->setup(dev, options);
168}
169
184__syscall int wdt_disable(const struct device *dev);
185
186static inline int z_impl_wdt_disable(const struct device *dev)
187{
188 const struct wdt_driver_api *api =
189 (const struct wdt_driver_api *)dev->api;
190
191 return api->disable(dev);
192}
193
216static inline int wdt_install_timeout(const struct device *dev,
217 const struct wdt_timeout_cfg *cfg)
218{
219 const struct wdt_driver_api *api =
220 (const struct wdt_driver_api *) dev->api;
221
222 return api->install_timeout(dev, cfg);
223}
224
238__syscall int wdt_feed(const struct device *dev, int channel_id);
239
240static inline int z_impl_wdt_feed(const struct device *dev, int channel_id)
241{
242 const struct wdt_driver_api *api =
243 (const struct wdt_driver_api *)dev->api;
244
245 return api->feed(dev, channel_id);
246}
247
248#ifdef __cplusplus
249}
250#endif
251
254#include <syscalls/watchdog.h>
255
256#endif /* ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_ */
void(* wdt_callback_t)(const struct device *dev, int channel_id)
Watchdog callback.
Definition: watchdog.h:85
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:216
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:381
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:387
Watchdog timeout configuration.
Definition: watchdog.h:88
wdt_callback_t callback
Timeout callback (can be NULL).
Definition: watchdog.h:92
struct wdt_timeout_cfg * next
Pointer to the next timeout configuration.
Definition: watchdog.h:101
uint8_t flags
Flags (see WDT_FLAGS).
Definition: watchdog.h:104
struct wdt_window window
Timing parameters of watchdog timeout.
Definition: watchdog.h:90
Watchdog timeout window.
Definition: watchdog.h:72
uint32_t max
Upper limit of watchdog feed timeout in milliseconds.
Definition: watchdog.h:76
uint32_t min
Lower limit of watchdog feed timeout in milliseconds.
Definition: watchdog.h:74
Misc utilities.