From abb01b9c60d929ffa1bf9940ff524bed23e37c3f Mon Sep 17 00:00:00 2001
From: Jeff Gough <j@jeffreygough.com>
Date: Wed, 21 Aug 2019 20:52:11 +0200
Subject: [PATCH] Enable WDT reset, approx 1s reset time

---
 epicardium/modules/hardware.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/epicardium/modules/hardware.c b/epicardium/modules/hardware.c
index 5cb95dc2..a8ae2ed9 100644
--- a/epicardium/modules/hardware.c
+++ b/epicardium/modules/hardware.c
@@ -20,6 +20,7 @@
 #include "rtc.h"
 #include "spi.h"
 #include "trng.h"
+#include "wdt.h"
 
 /*
  * Early init is called at the very beginning and is meant for modules which
@@ -28,6 +29,15 @@
  */
 int hardware_early_init(void)
 {
+	/*
+	 * Watchdog timer
+	 */
+	sys_cfg_wdt_t wdt_cfg = NULL;
+	WDT_Init(MXC_WDT0, wdt_cfg);
+	WDT_Enable(MXC_WDT0, 1);
+	WDT_SetResetPeriod(MXC_WDT0, WDT_PERIOD_2_18);
+	WDT_EnableReset(MXC_WDT0, 1);
+
 	/*
 	 * I2C bus for onboard peripherals (ie. PMIC, BMA400, BHI160, BME680,
 	 * ...)
-- 
GitLab