From 114072c5873f58064f59613abeb2bf4d46312808 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 8 Jan 2012 15:12:21 +0100 Subject: read reset reason --- usb-dfu-experiment/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'usb-dfu-experiment') diff --git a/usb-dfu-experiment/main.c b/usb-dfu-experiment/main.c index 81f7e89..31c2c4f 100644 --- a/usb-dfu-experiment/main.c +++ b/usb-dfu-experiment/main.c @@ -54,6 +54,8 @@ #include +#include + #include #include #include @@ -395,9 +397,14 @@ void dfu_drv_updstatus(void) extern void USBD_IrqHandler(void); +static const char *rst_type_strs[8] = { + "General", "Backup", "Watchdog", "Softare", "User", "5", "6", "7" +}; + int main(void) { volatile uint8_t usbConn = 0; + unsigned long rst_type; TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK); @@ -405,6 +412,9 @@ int main(void) printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); + rst_type = (RSTC_GetStatus() >> 8) & 0x7; + printf("-- Reset type: %s --\n\r", rst_type_strs[rst_type]); + chipid_to_usbserial(); /* If they are present, configure Vbus & Wake-up pins */ -- cgit v1.2.3