Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: test-lpc1768 oldheating gps motorhome ... more
Diff: reset/reset.c
- Revision:
- 49:d056e2c5c4ee
- Child:
- 50:e90c6aaa2645
diff -r 9784768cdc6c -r d056e2c5c4ee reset/reset.c --- /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); + } +}