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/restart.c
- Revision:
- 50:e90c6aaa2645
- Parent:
- 49:d056e2c5c4ee
diff -r d056e2c5c4ee -r e90c6aaa2645 reset/restart.c
--- a/reset/restart.c Wed May 08 12:13:37 2019 +0000
+++ b/reset/restart.c Thu May 09 07:48:38 2019 +0000
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <string.h>
#include "restart.h"
+#include "restart-this.h"
#include "semihost.h"
#define PERSIST (*((volatile unsigned *) 0x20083FFC)) //Make sure the startup scatter leaves a 4 byte space at this address
@@ -46,27 +47,26 @@
//If no routine overwrites the cause then we know it must be the push button.
PERSIST = MAGIC << 24 | RESTART_CAUSE_RESET_BUTTON << 20;
}
-
-void RestartCauseToString(int value, int size, char* text)
+const char* RestartGetCauseString()
{
- switch (value)
+ switch (lastCause)
{
- case RESTART_CAUSE_RESET_BUTTON: strncpy(text, "Reset button" , size); break;
- case RESTART_CAUSE_SOFTWARE_RESET: strncpy(text, "Software reset" , size); break;
- case RESTART_CAUSE_HARD_FAULT: strncpy(text, "Hard fault" , size); break;
- case RESTART_CAUSE_DEFAULT_HANDLER: strncpy(text, "Default handler" , size); break;
- case RESTART_CAUSE_INVALID_DATA: strncpy(text, "Invalid magic number", size); break;
- default: snprintf(text, size, "%d", value ); break;
+ case RESTART_CAUSE_RESET_BUTTON: return "Reset button" ;
+ case RESTART_CAUSE_SOFTWARE_RESET: return "Software reset" ;
+ case RESTART_CAUSE_HARD_FAULT: return "Hard fault" ;
+ case RESTART_CAUSE_DEFAULT_HANDLER: return "Default handler";
+ case RESTART_CAUSE_INVALID_DATA: return "Invalid" ;
+ default: return "Unknown" ;
}
}
-void RestartZoneToString(int value, int size, char* text)
+const char* RestartGetZoneString()
{
- switch (value)
+ switch (lastZone)
{
- case RESTART_ZONE_NONE: strncpy(text, "None" , size); break;
- case RESTART_ZONE_INIT: strncpy(text, "Init" , size); break;
- case RESTART_ZONE_NET: strncpy(text, "Net" , size); break;
- case RESTART_ZONE_CLOCK: strncpy(text, "Clock" , size); break;
- default: snprintf(text, size, "%d", value); break;
+ case RESTART_ZONE_NONE: return "None" ;
+ case RESTART_ZONE_INIT: return "Init" ;
+ case RESTART_ZONE_NET: return "Net" ;
+ case RESTART_ZONE_CLOCK: return "Clock";
+ default: return RestartThisGetZoneString();
}
}