16#ifndef INFUSE_SDK_DRIVERS_WATCHDOG_H_
17#define INFUSE_SDK_DRIVERS_WATCHDOG_H_
19#include <zephyr/kernel.h>
20#include <zephyr/device.h>
21#include <zephyr/toolchain.h>
23#include <zephyr/drivers/watchdog.h>
37#define INFUSE_WATCHDOG_DEV DEVICE_DT_GET(DT_ALIAS(watchdog0))
40#define INFUSE_WATCHDOG_FEED_PERIOD \
41 K_MSEC(CONFIG_INFUSE_WATCHDOG_PERIOD_MS - CONFIG_INFUSE_WATCHDOG_FEED_EARLY_MS)
44#define _INFUSE_WATCHDOG_CB \
45 COND_CODE_1(CONFIG_HAS_WDT_NO_CALLBACKS, (NULL), (infuse_watchdog_expired))
48#define INFUSE_WATCHDOG_DEFAULT_TIMEOUT_CFG \
49 (struct wdt_timeout_cfg) \
54 .max = CONFIG_INFUSE_WATCHDOG_PERIOD_MS, \
56 .flags = WDT_FLAG_RESET_SOC, .callback = _INFUSE_WATCHDOG_CB, \
59#if defined(CONFIG_INFUSE_WATCHDOG) || defined(__DOXYGEN__)
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) \
76 IS_ENABLED(dependency) ? infuse_watchdog_install(&period_name) : -ENODEV; \
79 SYS_INIT(name##_register, POST_KERNEL, 0);
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
178 ARG_UNUSED(feed_period);
190 ARG_UNUSED(wdog_channel);
204 ARG_UNUSED(wdog_channel);
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.