#ifdef __cplusplus
extern "C" {
#endif
void WDT_IRQHandler(void) {
WatchDog::instance().handleIRQ();
}
#ifdef __cplusplus
}
#endif
void WatchDog::handleIRQ() {
uint32_t wdt_status = Chip_WWDT_GetStatus(_reg);
// warning interrupt
if (wdt_status & WWDT_WDMOD_WDINT) {
if(_warning_fnc != NULL) {
_warning_fnc();
}
Chip_WWDT_ClearStatusFlag(_reg, WWDT_WDMOD_WDINT);
}
// timeout interrupt
if (wdt_status & WWDT_WDMOD_WDTOF) {
if(_timeout_fnc != NULL) {
_timeout_fnc();
}
Chip_WWDT_ClearStatusFlag(_reg, WWDT_WDMOD_WDTOF);
}
}
|
void wdt_wrn_irq() {
Debug::instance() << "WDT warning " << gbl_sw.elapsedMS() << endl;
}
void wdt_rst_irq() {
Debug::instance() << "WDT timeout " << gbl_sw.elapsedMS() << endl;
}
|
WatchDog& wdt = WatchDog::instance();
wdt.init();
wdt.setTimeOutFunction(wdt_rst_irq);
wdt.setTimeOutMode(WDT_TO_Interrupt);
wdt.setTimeOutMS(5000);
// wdt.setWarningUS(50000);
// wdt.setWarningFunction(wdt_wrn_irq);
if(wdt.start()) {
Debug::instance() << "WDT started" << endl;
}
|
WatchDog& wdt = WatchDog::instance();
wdt.init();
wdt.setTimeOutMode(WDT_TO_Interrupt);
wdt.setTimeOutMS(5000);
wdt.setTimeOutFunction(wdt_rst_irq);
wdt.setWarningUS(50000);
wdt.setWarningFunction(wdt_wrn_irq);
if(wdt.start()) {
Debug::instance() << "WDT started" << endl;
}
|
WDT started WDT warning 4711 WDT timeout 4713 |
WDT started WDT warning 4710 |