Zephyr Project API 3.7.0
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
8#ifndef ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
9#define ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_
10
20#include <zephyr/types.h>
21#include <zephyr/sys/util.h>
22#include <zephyr/device.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
35#define WDT_OPT_PAUSE_IN_SLEEP BIT(0)
36
38#define WDT_OPT_PAUSE_HALTED_BY_DBG BIT(1)
39
50#define WDT_FLAG_RESET_SHIFT (0)
52#define WDT_FLAG_RESET_MASK (0x3 << WDT_FLAG_RESET_SHIFT)
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)
61
80
87typedef void (*wdt_callback_t)(const struct device *dev, int channel_id);
88
95#if defined(CONFIG_WDT_MULTISTAGE) || defined(__DOXYGEN__)
104#endif
107};
108
115typedef int (*wdt_api_setup)(const struct device *dev, uint8_t options);
116
121typedef int (*wdt_api_disable)(const struct device *dev);
122
127typedef int (*wdt_api_install_timeout)(const struct device *dev,
128 const struct wdt_timeout_cfg *cfg);
129
134typedef int (*wdt_api_feed)(const struct device *dev, int channel_id);
135
136__subsystem struct wdt_driver_api {
137 wdt_api_setup setup;
138 wdt_api_disable disable;
139 wdt_api_install_timeout install_timeout;
140 wdt_api_feed feed;
141};
162__syscall int wdt_setup(const struct device *dev, uint8_t options);
163
164static inline int z_impl_wdt_setup(const struct device *dev, uint8_t options)
165{
166 const struct wdt_driver_api *api =
167 (const struct wdt_driver_api *)dev->api;
168
169 return api->setup(dev, options);
170}
171
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
240__syscall int wdt_feed(const struct device *dev, int channel_id);
241
242static inline int z_impl_wdt_feed(const struct device *dev, int channel_id)
243{
244 const struct wdt_driver_api *api =
245 (const struct wdt_driver_api *)dev->api;
246
247 return api->feed(dev, channel_id);
248}
249
250#ifdef __cplusplus
251}
252#endif
253
256#include <zephyr/syscalls/watchdog.h>
257
258#endif /* ZEPHYR_INCLUDE_DRIVERS_WATCHDOG_H_ */
void(* wdt_callback_t)(const struct device *dev, int channel_id)
Watchdog callback.
Definition watchdog.h:87
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: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.
__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:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409
Watchdog timeout configuration.
Definition watchdog.h:90
wdt_callback_t callback
Timeout callback (can be NULL).
Definition watchdog.h:94
struct wdt_timeout_cfg * next
Pointer to the next timeout configuration.
Definition watchdog.h:103
uint8_t flags
Flags (see WDT_FLAGS).
Definition watchdog.h:106
struct wdt_window window
Timing parameters of watchdog timeout.
Definition watchdog.h:92
Watchdog timeout window.
Definition watchdog.h:74
uint32_t max
Upper limit of watchdog feed timeout in milliseconds.
Definition watchdog.h:78
uint32_t min
Lower limit of watchdog feed timeout in milliseconds.
Definition watchdog.h:76
Misc utilities.