2015-02-09 18:27:42 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 INRIA
|
2015-02-17 13:16:40 +01:00
|
|
|
* Copyright (C) 2015 Eistec AB
|
2016-04-18 18:34:48 +02:00
|
|
|
* Copyright (C) 2016 OTA keys
|
2015-02-09 18:27:42 +01:00
|
|
|
*
|
2015-02-17 13:16:40 +01:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser General
|
|
|
|
* Public License v2.1. See the file LICENSE in the top level directory for more
|
|
|
|
* details.
|
2015-02-09 18:27:42 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-06-01 12:25:00 +02:00
|
|
|
* @ingroup cpu_cortexm_common
|
2015-02-09 18:27:42 +01:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Crash handling functions implementation for ARM Cortex-based MCUs
|
|
|
|
*
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
2015-09-20 13:47:39 +02:00
|
|
|
* @author Joakim Nohlgård <joakim.nohlgard@eistec.se>
|
2016-04-18 18:34:48 +02:00
|
|
|
* @author Toon Stegen <toon.stegen@altran.com>
|
2015-02-09 18:27:42 +01:00
|
|
|
*/
|
|
|
|
|
2024-07-17 16:18:19 +02:00
|
|
|
#include <stdio.h>
|
2015-02-09 18:27:42 +01:00
|
|
|
#include "cpu.h"
|
2016-04-18 18:34:48 +02:00
|
|
|
|
|
|
|
#ifdef DEVELHELP
|
|
|
|
static void print_ipsr(void)
|
|
|
|
{
|
|
|
|
uint32_t ipsr = __get_IPSR() & IPSR_ISR_Msk;
|
2024-04-24 13:20:59 +02:00
|
|
|
|
|
|
|
if (ipsr) {
|
2016-04-18 18:34:48 +02:00
|
|
|
/* if you get here, you might have forgotten to implement the isr
|
|
|
|
* for the printed interrupt number */
|
2024-07-17 16:18:19 +02:00
|
|
|
printf("Inside isr %d\n", ((int)ipsr) - 16);
|
2016-04-18 18:34:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-02-09 18:27:42 +01:00
|
|
|
|
2015-05-09 18:12:18 +02:00
|
|
|
void panic_arch(void)
|
2015-02-09 18:27:42 +01:00
|
|
|
{
|
2015-09-12 12:43:15 +02:00
|
|
|
#ifdef DEVELHELP
|
2016-04-18 18:34:48 +02:00
|
|
|
print_ipsr();
|
2024-04-23 20:23:28 +02:00
|
|
|
/* CM0+ has a C_DEBUGEN bit but it is NOT accessible by CPU (only by debugger) */
|
|
|
|
#ifdef CoreDebug_DHCSR_C_DEBUGEN_Msk
|
|
|
|
if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) {
|
|
|
|
/* if Debug session is running, tell the debugger to break here.
|
|
|
|
Skip it otherwise as this instruction will cause either a fault
|
|
|
|
escalation to hardfault or a CPU lockup */
|
|
|
|
__asm__("bkpt #0");
|
|
|
|
}
|
|
|
|
#endif /* CoreDebug_DHCSR_C_DEBUGEN_Msk */
|
|
|
|
|
2015-02-09 18:27:42 +01:00
|
|
|
#endif
|
|
|
|
}
|