在这个例程里,列出的所有的复位源,用户可以选择需要的复位源进行测试:
每次复新启动开发板,都显示一下复位源和菜单:
菜单内容如下:
Menu:
* 0 - Reset Status information.
* 1 - User Reset enable.
* 2 - User Reset disable.
* 3 - User Reset interrupt enable.
* 4 - User Reset interrupt disable.
* 5 - Software Reset.
* 6 - Watchdog Reset.
* 7 - NRST assert.
显示复位原因清单如下:
- static void display_reset_reason(void)
- {
- char msg[80];
-
- strcpy(&msg[0], "\r\nReset info : ");
-
- //! [reset_get_status]
- uint32_t info = rstc_get_status(RSTC);
- //! [reset_get_status]
-
- /* Decode the reset reason. */
- switch (info & RSTC_SR_RSTTYP_Msk) {
- case RSTC_GENERAL_RESET:
- strcat(&msg[0], "General Reset,");
- break;
-
- case RSTC_BACKUP_RESET:
- strcat(&msg[0], "Backup Reset,");
- break;
-
- case RSTC_WATCHDOG_RESET:
- strcat(&msg[0], "Watchdog Reset,");
- break;
-
- case RSTC_SOFTWARE_RESET:
- strcat(&msg[0], "Software Reset,");
- break;
-
- case RSTC_USER_RESET:
- strcat(&msg[0], "User Reset,");
- break;
-
- default:
- strcat(&msg[0], "Invalid reset reason!,");
- }
-
- /* NRST level. */
- if (info & RSTC_SR_NRSTL) {
- strcat(&msg[0], " NRST=1,");
- }
- else {
- strcat(&msg[0], " NRST=0,");
- }
- /* User reset status. */
- if (info & RSTC_SR_URSTS) {
- strcat(&msg[0], " User Reset=1\r");
- }
- else {
- strcat(&msg[0], " User Reset=0\r");
- }
- puts(&msg[0]);
- }
主循环检测如下:
|