panic in debug mode if sleep methods are called in an exception handler (unless PICO_ALLOW_SLEEP_IN_EXCEPTION is set)

This commit is contained in:
graham sanderson
2021-02-17 14:54:46 -06:00
parent 6b2c249961
commit aca685ceae
4 changed files with 12 additions and 4 deletions

View File

@ -13,7 +13,6 @@
#include "pico/assert.h"
extern void __unhandled_user_irq(void);
extern uint __get_current_exception(void);
static inline irq_handler_t *get_vtable(void) {
return (irq_handler_t *) scb_hw->vtor;

View File

@ -163,6 +163,12 @@ return a;
#define __check_type_compatible(type_a, type_b) static_assert(__builtin_types_compatible_p(type_a, type_b), __STRING(type_a) " is not compatible with " __STRING(type_b));
/**
* Get the current exception level on this core
* \return the exception number if the CPU is handling an exception, or 0 otherwise
*/
extern uint __get_current_exception(void);
#ifdef __cplusplus
}
#endif

View File

@ -124,9 +124,7 @@ void runtime_init(void) {
#endif
#ifndef NDEBUG
uint32_t xpsr;
__asm volatile ("mrs %0, XPSR" : "=r" (xpsr)::);
if (xpsr & 0xffu) {
if (__get_current_exception()) {
// crap; started in exception handler
__asm ("bkpt #0");
}