mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-08-14 02:17:39 +00:00
improved runtime error handling
This commit is contained in:
@@ -22,4 +22,25 @@
|
||||
#ifndef __DEBUG_H__
|
||||
#define __DEBUG_H__
|
||||
|
||||
#include <ch.h>
|
||||
|
||||
extern uint32_t __process_stack_base__;
|
||||
extern uint32_t __process_stack_end__;
|
||||
#define CRT0_STACKS_FILL_PATTERN 0x55555555
|
||||
|
||||
inline uint32_t get_free_stack_space(){
|
||||
uint32_t *p;
|
||||
for (p = &__process_stack_base__; *p == CRT0_STACKS_FILL_PATTERN && p < &__process_stack_end__; p++);
|
||||
auto stack_space_left = p - &__process_stack_base__;
|
||||
|
||||
return stack_space_left;
|
||||
}
|
||||
|
||||
#define HALT_IF_DEBUGGING() \
|
||||
do { \
|
||||
if ((*(volatile uint32_t *)0xE000EDF0) & (1 << 0)) { \
|
||||
__asm__ __volatile__("bkpt 1"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#endif/*__DEBUG_H__*/
|
||||
|
Reference in New Issue
Block a user