Andrew Boyson / lpc1768

Dependents:   test-lpc1768 oldheating gps motorhome ... more

Revision:
49:d056e2c5c4ee
Child:
50:e90c6aaa2645
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/reset/reset.c	Wed May 08 12:13:37 2019 +0000
@@ -0,0 +1,45 @@
+#include <stdio.h>
+#include <string.h>
+
+#include "rsid.h"
+#include "restart.h"
+#include "watchdog.h"
+#include "led.h"
+#include "mstimer.h"
+
+bool ResetAccepted = false;
+
+bool ResetWasPushButton()
+{
+    return RsidExtr && RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON;
+}
+
+void ResetInit()
+{
+        RsidInit();
+     RestartInit();
+    WatchdogInit();
+}
+void ResetMain()
+{
+    //Feed the watchdog
+    WatchdogMain();
+    
+    //Flash an led
+    bool doFlash = true;
+    if (ResetAccepted) doFlash = false;
+    if (RsidExtr)
+    {
+        if (RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON  ) doFlash = false;
+        if (RestartGetLastCause() == RESTART_CAUSE_SOFTWARE_RESET) doFlash = false;
+    }
+    static uint32_t ledFlashTimer = 0;
+    if (doFlash)
+    {
+        if (MsTimerRepetitive(&ledFlashTimer, 100)) Led4Tgl();
+    }
+    else
+    {
+        Led4Set(false);
+    }
+}