Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
watchdog.h
Go to the documentation of this file.
1
16#ifndef INFUSE_SDK_DRIVERS_WATCHDOG_H_
17#define INFUSE_SDK_DRIVERS_WATCHDOG_H_
18
19#include <zephyr/kernel.h>
20#include <zephyr/device.h>
21#include <zephyr/toolchain.h>
22
23#include <zephyr/drivers/watchdog.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
36#define INFUSE_WATCHDOG_DEV DEVICE_DT_GET(DT_ALIAS(watchdog0))
37
39#define INFUSE_WATCHDOG_FEED_PERIOD \
40 K_MSEC(CONFIG_INFUSE_WATCHDOG_PERIOD_MS - CONFIG_INFUSE_WATCHDOG_FEED_EARLY_MS)
41
43#define _INFUSE_WATCHDOG_CB \
44 COND_CODE_1(CONFIG_HAS_WDT_NO_CALLBACKS, (NULL), (infuse_watchdog_expired))
45
47#define INFUSE_WATCHDOG_DEFAULT_TIMEOUT_CFG \
48 (struct wdt_timeout_cfg) \
49 { \
50 .window = \
51 { \
52 .min = 0, \
53 .max = CONFIG_INFUSE_WATCHDOG_PERIOD_MS, \
54 }, \
55 .flags = WDT_FLAG_RESET_SOC, .callback = _INFUSE_WATCHDOG_CB, \
56 }
57
58#if defined(CONFIG_INFUSE_WATCHDOG) || defined(__DOXYGEN__)
59
68#define INFUSE_WATCHDOG_REGISTER_SYS_INIT(name, dependency, chan_name, period_name) \
69 static k_timeout_t period_name = K_FOREVER; \
70 static int chan_name; \
71 static int name##_register(void) \
72 { \
73 (void)period_name; \
74 chan_name = \
75 IS_ENABLED(dependency) ? infuse_watchdog_install(&period_name) : -ENODEV; \
76 return 0; \
77 } \
78 SYS_INIT(name##_register, POST_KERNEL, 0);
79
88void infuse_watchdog_warning(const struct device *dev, int channel_id);
89
101void infuse_watchdog_expired(const struct device *dev, int channel_id);
102
108int infuse_watchdog_install(k_timeout_t *feed_period);
109
121void infuse_watchdog_thread_register(int wdog_channel, k_tid_t thread);
122
144int infuse_watchdog_thread_state_lookup(int wdog_channel, uint32_t *info1, uint32_t *info2);
145
152
158void infuse_watchdog_feed(int wdog_channel);
159
168
169#else
170
171#define INFUSE_WATCHDOG_REGISTER_SYS_INIT(name, dependency, chan_name, period_name) \
172 static k_timeout_t period_name = K_FOREVER; \
173 static int chan_name = 0
174
175static inline int infuse_watchdog_install(k_timeout_t *feed_period)
176{
177 ARG_UNUSED(feed_period);
178
179 return 0;
180}
181
182static inline void infuse_watchdog_thread_register(int wdog_channel, k_tid_t thread)
183{
184}
185
186static inline int infuse_watchdog_thread_state_lookup(int wdog_channel, uint32_t *info1,
187 uint32_t *info2)
188{
189 ARG_UNUSED(wdog_channel);
190 ARG_UNUSED(info1);
191 ARG_UNUSED(info2);
192
193 return -EINVAL;
194}
195
196static inline int infuse_watchdog_start(void)
197{
198 return 0;
199}
200
201static inline void infuse_watchdog_feed(int wdog_channel)
202{
203 ARG_UNUSED(wdog_channel);
204}
205
206static inline void infuse_watchdog_feed_all(void)
207{
208}
209
210#endif /* defined(CONFIG_INFUSE_WATCHDOG) || defined(__DOXYGEN__) */
211
216#ifdef __cplusplus
217}
218#endif
219
220#endif /* INFUSE_SDK_DRIVERS_WATCHDOG_H_ */
void infuse_watchdog_feed(int wdog_channel)
Feed an Infuse watchdog channel.
void infuse_watchdog_warning(const struct device *dev, int channel_id)
Function that is called just prior to watchdog expiry.
int infuse_watchdog_start(void)
Start the Infuse watchdog.
int infuse_watchdog_install(k_timeout_t *feed_period)
Install an Infuse watchdog channel.
int infuse_watchdog_thread_state_lookup(int wdog_channel, uint32_t *info1, uint32_t *info2)
Determine state of the thread responsible for watchdog channel.
void infuse_watchdog_feed_all(void)
Feed all Infuse watchdog channels.
void infuse_watchdog_thread_register(int wdog_channel, k_tid_t thread)
Register a watchdog channel against a thread.
void infuse_watchdog_expired(const struct device *dev, int channel_id)
Function that is called on watchdog expiry.