/* * Copyright (c) 2016 Travis Geiselbrecht * * Use of this source code is governed by a MIT-style * license that can be found in the LICENSE file or at * https://opensource.org/licenses/MIT */ #include #include #include #include #include #include #include #include #include #if WITH_LIB_CONSOLE #include #endif void platform_halt(platform_halt_action suggested_action, platform_halt_reason reason) { #if ENABLE_PANIC_SHELL if (reason == HALT_REASON_SW_PANIC) { dprintf(ALWAYS, "CRASH: starting debug shell... (reason = %d)\n", reason); arch_disable_ints(); panic_shell_start(); } #endif // ENABLE_PANIC_SHELL switch (suggested_action) { default: case HALT_ACTION_SHUTDOWN: case HALT_ACTION_HALT: dprintf(ALWAYS, "HALT: spinning forever... (reason = %d)\n", reason); arch_disable_ints(); for (;;) arch_idle(); break; case HALT_ACTION_REBOOT: dprintf(INFO, "REBOOT\n"); arch_disable_ints(); for (;;) { NVIC_SystemReset(); } break; } dprintf(ALWAYS, "HALT: spinning forever... (reason = %d)\n", reason); arch_disable_ints(); for (;;); }