diff --git a/application.c b/application.c index a4b06a2..c7bb9d6 100644 --- a/application.c +++ b/application.c @@ -328,6 +328,32 @@ void main(void) usb_cdcacm_setup(); // setup USB CDC ACM (for printing) printf("\nwelcome to the CuVoodoo STM32F1 example application\n"); // print welcome message +#if DEBUG + // show reset cause + if (RCC_CSR & (RCC_CSR_LPWRRSTF | RCC_CSR_WWDGRSTF | RCC_CSR_IWDGRSTF | RCC_CSR_SFTRSTF | RCC_CSR_PORRSTF | RCC_CSR_PINRSTF)) { + puts("reset cause(s):"); + if (RCC_CSR & RCC_CSR_LPWRRSTF) { + puts(" low-power"); + } + if (RCC_CSR & RCC_CSR_WWDGRSTF) { + puts(" window-watchdog"); + } + if (RCC_CSR & RCC_CSR_IWDGRSTF) { + puts(" independent-watchdog"); + } + if (RCC_CSR & RCC_CSR_SFTRSTF) { + puts(" software"); + } + if (RCC_CSR & RCC_CSR_PORRSTF) { + puts(" POR/PDR"); + } + if (RCC_CSR & RCC_CSR_PINRSTF) { + puts(" pin"); + } + putc('\n'); + RCC_CSR |= RCC_CSR_RMVF; // clear reset flags + } +#endif #if !(DEBUG) // show watchdog information printf("setup watchdog: %.2fs", WATCHDOG_PERIOD / 1000.0);