test_led_strip/include/watchdog.hpp
zhangyisong 0e5d15c814 Refactor app to use static classes and event-driven callbacks
Restructure Led as a template on the DT spec, add a generic
signal/slot mechanism for host status, and cache Infrared sensor
samples via trigger callbacks. Add new init modules for LED, temp,
and watchdog, and build them into the main app.
2026-08-03 22:12:31 +08:00

34 lines
731 B
C++

#ifndef __ZPP_WATCHDOG_HPP
#define __ZPP_WATCHDOG_HPP
#include <zephyr/drivers/watchdog.h>
#include <zpp/assert.hpp>
#include <zpp/timer.hpp>
namespace ther {
class WatchDogConfig {
public:
WatchDogConfig() {
if (!device_is_ready(m_wdt)) {
__ASSERT_NO_MSG(0);
}
chan_id = wdt_install_timeout(m_wdt, &cfg);
if (auto err = wdt_setup(m_wdt, WDT_OPT_PAUSE_HALTED_BY_DBG); err < 0) {
__ASSERT_NO_MSG(0);
}
}
auto Feed() { wdt_feed(m_wdt, chan_id); }
private:
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 ther
#endif