123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include "app_error.h"
- #include "nrf_log.h"
- #include "nrf_log_ctrl.h"
- #include "app_util_platform.h"
- #include "nrf_strerror.h"
- #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
- #include "nrf_sdm.h"
- #endif
- __WEAK void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info)
- {
- __disable_irq();
- NRF_LOG_FINAL_FLUSH();
- #ifndef DEBUG
- NRF_LOG_ERROR("Fatal error");
- #else
- switch (id)
- {
- #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
- case NRF_FAULT_ID_SD_ASSERT:
- NRF_LOG_ERROR("SOFTDEVICE: ASSERTION FAILED");
- break;
- case NRF_FAULT_ID_APP_MEMACC:
- NRF_LOG_ERROR("SOFTDEVICE: INVALID MEMORY ACCESS");
- break;
- #endif
- case NRF_FAULT_ID_SDK_ASSERT:
- {
- assert_info_t * p_info = (assert_info_t *)info;
- NRF_LOG_ERROR("ASSERTION FAILED at %s:%u",
- p_info->p_file_name,
- p_info->line_num);
- break;
- }
- case NRF_FAULT_ID_SDK_ERROR:
- {
- error_info_t * p_info = (error_info_t *)info;
- NRF_LOG_ERROR("ERROR %u [%s] at %s:%u\r\nPC at: 0x%08x",
- p_info->err_code,
- nrf_strerror_get(p_info->err_code),
- p_info->p_file_name,
- p_info->line_num,
- pc);
- NRF_LOG_ERROR("End of error report");
- break;
- }
- default:
- NRF_LOG_ERROR("UNKNOWN FAULT at 0x%08X", pc);
- break;
- }
- #endif
- NRF_BREAKPOINT_COND;
-
- #ifndef DEBUG
- NRF_LOG_WARNING("System reset");
- NVIC_SystemReset();
- #else
- app_error_save_and_stop(id, pc, info);
- #endif
- }
|