forked from EmbeddedTeam/app_photomagnetic
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.
34 lines
731 B
C++
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
|