Andrew Boyson / lpc1768

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

Committer:
andrewboyson
Date:
Wed May 08 12:13:37 2019 +0000
Revision:
49:d056e2c5c4ee
Child:
50:e90c6aaa2645
Sorted out reset module to properly read the RSID register

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 49:d056e2c5c4ee 1 #include <stdio.h>
andrewboyson 49:d056e2c5c4ee 2 #include <string.h>
andrewboyson 49:d056e2c5c4ee 3
andrewboyson 49:d056e2c5c4ee 4 #include "rsid.h"
andrewboyson 49:d056e2c5c4ee 5 #include "restart.h"
andrewboyson 49:d056e2c5c4ee 6 #include "watchdog.h"
andrewboyson 49:d056e2c5c4ee 7 #include "led.h"
andrewboyson 49:d056e2c5c4ee 8 #include "mstimer.h"
andrewboyson 49:d056e2c5c4ee 9
andrewboyson 49:d056e2c5c4ee 10 bool ResetAccepted = false;
andrewboyson 49:d056e2c5c4ee 11
andrewboyson 49:d056e2c5c4ee 12 bool ResetWasPushButton()
andrewboyson 49:d056e2c5c4ee 13 {
andrewboyson 49:d056e2c5c4ee 14 return RsidExtr && RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON;
andrewboyson 49:d056e2c5c4ee 15 }
andrewboyson 49:d056e2c5c4ee 16
andrewboyson 49:d056e2c5c4ee 17 void ResetInit()
andrewboyson 49:d056e2c5c4ee 18 {
andrewboyson 49:d056e2c5c4ee 19 RsidInit();
andrewboyson 49:d056e2c5c4ee 20 RestartInit();
andrewboyson 49:d056e2c5c4ee 21 WatchdogInit();
andrewboyson 49:d056e2c5c4ee 22 }
andrewboyson 49:d056e2c5c4ee 23 void ResetMain()
andrewboyson 49:d056e2c5c4ee 24 {
andrewboyson 49:d056e2c5c4ee 25 //Feed the watchdog
andrewboyson 49:d056e2c5c4ee 26 WatchdogMain();
andrewboyson 49:d056e2c5c4ee 27
andrewboyson 49:d056e2c5c4ee 28 //Flash an led
andrewboyson 49:d056e2c5c4ee 29 bool doFlash = true;
andrewboyson 49:d056e2c5c4ee 30 if (ResetAccepted) doFlash = false;
andrewboyson 49:d056e2c5c4ee 31 if (RsidExtr)
andrewboyson 49:d056e2c5c4ee 32 {
andrewboyson 49:d056e2c5c4ee 33 if (RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON ) doFlash = false;
andrewboyson 49:d056e2c5c4ee 34 if (RestartGetLastCause() == RESTART_CAUSE_SOFTWARE_RESET) doFlash = false;
andrewboyson 49:d056e2c5c4ee 35 }
andrewboyson 49:d056e2c5c4ee 36 static uint32_t ledFlashTimer = 0;
andrewboyson 49:d056e2c5c4ee 37 if (doFlash)
andrewboyson 49:d056e2c5c4ee 38 {
andrewboyson 49:d056e2c5c4ee 39 if (MsTimerRepetitive(&ledFlashTimer, 100)) Led4Tgl();
andrewboyson 49:d056e2c5c4ee 40 }
andrewboyson 49:d056e2c5c4ee 41 else
andrewboyson 49:d056e2c5c4ee 42 {
andrewboyson 49:d056e2c5c4ee 43 Led4Set(false);
andrewboyson 49:d056e2c5c4ee 44 }
andrewboyson 49:d056e2c5c4ee 45 }