feat: add watchdog

This commit is contained in:
zys
2026-03-04 15:01:15 +08:00
parent 2c22d68494
commit 7b17066575
3 changed files with 17 additions and 10 deletions
+12 -7
View File
@@ -2,25 +2,30 @@
#define __ZPP_WATCHDOG_HPP
#include <zephyr/drivers/watchdog.h>
#include <zpp/assert.hpp>
#include <zpp/timer.hpp>
namespace app {
class WatchDogConfig {
public:
#if 0
WatchDogConfig() {
if (!device_is_ready(m_wtd)) {
if (!device_is_ready(m_wdt)) {
__ASSERT_NO_MSG(0);
}
wdt_install_timeout(m_wtd, &wdt_timeout_cfg);
chan_id = wdt_install_timeout(m_wdt, &cfg);
if (auto err = wdt_setup(m_wtd, WDT_OPT_PAUSE_HALTED_BY_DBG); err < 0) {
if (auto err = wdt_setup(m_wdt, WDT_OPT_PAUSE_HALTED_BY_DBG); err < 0) {
__ASSERT_NO_MSG(0);
}
wdt_timeout_cfg cfg;
}
auto Feed() { wdt_feed(m_wdt, chan_id); }
private:
const device *m_wtd{DEVICE_DT_GET(DT_ALIAS(watchdog0))};
#endif
const device *m_wdt{DEVICE_DT_GET(DT_ALIAS(watchdog0))};
static constexpr wdt_timeout_cfg cfg{
.window{0, 1000},
.callback = nullptr,
.flags = WDT_FLAG_RESET_SOC,
};
int chan_id;
};
} // namespace app