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
15
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
35
37#define INFUSE_WATCHDOG_DEV DEVICE_DT_GET(DT_ALIAS(watchdog0))
38
40#define INFUSE_WATCHDOG_FEED_PERIOD \
41 K_MSEC(CONFIG_INFUSE_WATCHDOG_PERIOD_MS - CONFIG_INFUSE_WATCHDOG_FEED_EARLY_MS)
42
44#define _INFUSE_WATCHDOG_CB \
45 COND_CODE_1(CONFIG_HAS_WDT_NO_CALLBACKS, (NULL), (infuse_watchdog_expired))
46
48#define INFUSE_WATCHDOG_DEFAULT_TIMEOUT_CFG \
49 (struct wdt_timeout_cfg) \
50 { \
51 .window = \
52 { \
53 .min = 0, \
54 .max = CONFIG_INFUSE_WATCHDOG_PERIOD_MS, \
55 }, \
56 .flags = WDT_FLAG_RESET_SOC, .callback = _INFUSE_WATCHDOG_CB, \
57 }
58
59#if defined(CONFIG_INFUSE_WATCHDOG) || defined(__DOXYGEN__)
60
69#define INFUSE_WATCHDOG_REGISTER_SYS_INIT(name, dependency, chan_name, period_name) \
70 static k_timeout_t period_name = K_FOREVER; \
71 static int chan_name; \
72 static int name##_register(void) \
73 { \
74 (void)period_name; \
75 chan_name = \
76 IS_ENABLED(dependency) ? infuse_watchdog_install(&period_name) : -ENODEV; \
77 return 0; \
78 } \
79 SYS_INIT(name##_register, POST_KERNEL, 0);
80
89void infuse_watchdog_warning(const struct device *dev, int channel_id);
90
102void infuse_watchdog_expired(const struct device *dev, int channel_id);
103
109int infuse_watchdog_install(k_timeout_t *feed_period);
110
122void infuse_watchdog_thread_register(int wdog_channel, k_tid_t thread);
123
145int infuse_watchdog_thread_state_lookup(int wdog_channel, uint32_t *info1, uint32_t *info2);
146
153
159void infuse_watchdog_feed(int wdog_channel);
160
169
170#else
171
172#define INFUSE_WATCHDOG_REGISTER_SYS_INIT(name, dependency, chan_name, period_name) \
173 static k_timeout_t period_name = K_FOREVER; \
174 static int chan_name = 0
175
176static inline int infuse_watchdog_install(k_timeout_t *feed_period)
177{
178 ARG_UNUSED(feed_period);
179
180 return 0;
181}
182
183static inline void infuse_watchdog_thread_register(int wdog_channel, k_tid_t thread)
184{
185}
186
187static inline int infuse_watchdog_thread_state_lookup(int wdog_channel, uint32_t *info1,
188 uint32_t *info2)
189{
190 ARG_UNUSED(wdog_channel);
191 ARG_UNUSED(info1);
192 ARG_UNUSED(info2);
193
194 return -EINVAL;
195}
196
197static inline int infuse_watchdog_start(void)
198{
199 return 0;
200}
201
202static inline void infuse_watchdog_feed(int wdog_channel)
203{
204 ARG_UNUSED(wdog_channel);
205}
206
207static inline void infuse_watchdog_feed_all(void)
208{
209}
210
211#endif /* defined(CONFIG_INFUSE_WATCHDOG) || defined(__DOXYGEN__) */
212
216
217#ifdef __cplusplus
218}
219#endif
220
221#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.