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>
36#define INFUSE_WATCHDOG_DEV DEVICE_DT_GET(DT_ALIAS(watchdog0))
39#define INFUSE_WATCHDOG_FEED_PERIOD \
40 K_MSEC(CONFIG_INFUSE_WATCHDOG_PERIOD_MS - CONFIG_INFUSE_WATCHDOG_FEED_EARLY_MS)
43#define _INFUSE_WATCHDOG_CB \
44 COND_CODE_1(CONFIG_HAS_WDT_NO_CALLBACKS, (NULL), (infuse_watchdog_expired))
47#define INFUSE_WATCHDOG_DEFAULT_TIMEOUT_CFG \
48 (struct wdt_timeout_cfg) \
53 .max = CONFIG_INFUSE_WATCHDOG_PERIOD_MS, \
55 .flags = WDT_FLAG_RESET_SOC, .callback = _INFUSE_WATCHDOG_CB, \
58#if defined(CONFIG_INFUSE_WATCHDOG) || defined(__DOXYGEN__)
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) \
75 IS_ENABLED(dependency) ? infuse_watchdog_install(&period_name) : -ENODEV; \
78 SYS_INIT(name##_register, POST_KERNEL, 0);
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
177 ARG_UNUSED(feed_period);
189 ARG_UNUSED(wdog_channel);
203 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.