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
reset/reset.c@50:e90c6aaa2645, 2019-05-09 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu May 09 07:48:38 2019 +0000
- Revision:
- 50:e90c6aaa2645
- Parent:
- 49:d056e2c5c4ee
Updated the restart module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewboyson | 50:e90c6aaa2645 | 1 | #include <stdint.h> |
andrewboyson | 49:d056e2c5c4ee | 2 | #include <stdio.h> |
andrewboyson | 49:d056e2c5c4ee | 3 | #include <string.h> |
andrewboyson | 49:d056e2c5c4ee | 4 | |
andrewboyson | 49:d056e2c5c4ee | 5 | #include "rsid.h" |
andrewboyson | 49:d056e2c5c4ee | 6 | #include "restart.h" |
andrewboyson | 49:d056e2c5c4ee | 7 | #include "watchdog.h" |
andrewboyson | 49:d056e2c5c4ee | 8 | #include "led.h" |
andrewboyson | 49:d056e2c5c4ee | 9 | #include "mstimer.h" |
andrewboyson | 49:d056e2c5c4ee | 10 | |
andrewboyson | 49:d056e2c5c4ee | 11 | bool ResetAccepted = false; |
andrewboyson | 49:d056e2c5c4ee | 12 | |
andrewboyson | 49:d056e2c5c4ee | 13 | bool ResetWasPushButton() |
andrewboyson | 49:d056e2c5c4ee | 14 | { |
andrewboyson | 49:d056e2c5c4ee | 15 | return RsidExtr && RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON; |
andrewboyson | 49:d056e2c5c4ee | 16 | } |
andrewboyson | 50:e90c6aaa2645 | 17 | bool ResetHasAlarm() |
andrewboyson | 50:e90c6aaa2645 | 18 | { |
andrewboyson | 50:e90c6aaa2645 | 19 | if (ResetAccepted) return false; |
andrewboyson | 50:e90c6aaa2645 | 20 | if (RsidExtr) |
andrewboyson | 50:e90c6aaa2645 | 21 | { |
andrewboyson | 50:e90c6aaa2645 | 22 | if (RestartGetLastCause() == RESTART_CAUSE_RESET_BUTTON ) return false; |
andrewboyson | 50:e90c6aaa2645 | 23 | if (RestartGetLastCause() == RESTART_CAUSE_SOFTWARE_RESET) return false; |
andrewboyson | 50:e90c6aaa2645 | 24 | } |
andrewboyson | 50:e90c6aaa2645 | 25 | return true; |
andrewboyson | 50:e90c6aaa2645 | 26 | } |
andrewboyson | 49:d056e2c5c4ee | 27 | void ResetInit() |
andrewboyson | 49:d056e2c5c4ee | 28 | { |
andrewboyson | 49:d056e2c5c4ee | 29 | RsidInit(); |
andrewboyson | 49:d056e2c5c4ee | 30 | RestartInit(); |
andrewboyson | 49:d056e2c5c4ee | 31 | WatchdogInit(); |
andrewboyson | 49:d056e2c5c4ee | 32 | } |
andrewboyson | 49:d056e2c5c4ee | 33 | void ResetMain() |
andrewboyson | 49:d056e2c5c4ee | 34 | { |
andrewboyson | 49:d056e2c5c4ee | 35 | //Feed the watchdog |
andrewboyson | 49:d056e2c5c4ee | 36 | WatchdogMain(); |
andrewboyson | 49:d056e2c5c4ee | 37 | |
andrewboyson | 49:d056e2c5c4ee | 38 | //Flash an led |
andrewboyson | 49:d056e2c5c4ee | 39 | static uint32_t ledFlashTimer = 0; |
andrewboyson | 50:e90c6aaa2645 | 40 | if (ResetHasAlarm()) |
andrewboyson | 49:d056e2c5c4ee | 41 | { |
andrewboyson | 49:d056e2c5c4ee | 42 | if (MsTimerRepetitive(&ledFlashTimer, 100)) Led4Tgl(); |
andrewboyson | 49:d056e2c5c4ee | 43 | } |
andrewboyson | 49:d056e2c5c4ee | 44 | else |
andrewboyson | 49:d056e2c5c4ee | 45 | { |
andrewboyson | 49:d056e2c5c4ee | 46 | Led4Set(false); |
andrewboyson | 49:d056e2c5c4ee | 47 | } |
andrewboyson | 49:d056e2c5c4ee | 48 | } |