samd21: Enable watchdog

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2018-11-26 18:58:20 -05:00
parent afa58de014
commit 0af0bc946e
1 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,26 @@
DECL_CONSTANT(MCU, "samd21g");
/****************************************************************
* watchdog handler
****************************************************************/
void
watchdog_reset(void)
{
WDT->CLEAR.reg = 0xa5;
}
DECL_TASK(watchdog_reset);
void
watchdog_init(void)
{
WDT->CONFIG.reg = WDT_CONFIG_PER_16K; // 500ms timeout
WDT->CTRL.reg = WDT_CTRL_ENABLE;
}
DECL_INIT(watchdog_init);
/****************************************************************
* misc functions
****************************************************************/