From c27af361feeca0e7cbfa51f5589b09d0c110e9c9 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 8 Mar 2018 12:17:58 -0500 Subject: graphing perfection --- src/stm32l4xx_it.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/stm32l4xx_it.c') diff --git a/src/stm32l4xx_it.c b/src/stm32l4xx_it.c index e54a192..228dc67 100644 --- a/src/stm32l4xx_it.c +++ b/src/stm32l4xx_it.c @@ -12,12 +12,16 @@ void serial_puts(const char *s) void perror(const char *s) { - //extern task_t *current; + extern uint32_t heap_used; serial_puts(s); - //char buf[200]; - //snprintf(buf, 200, "xPSR: %x\r\nPC: %x\r\nLR: %x\r\n", current->sp[0], - // current->sp[1], current->sp[2]); - //serial_puts(buf); + + static char buf[200]; + uint32_t *psp; + asm("mrs %0, psp" : "=r"(psp)); + + snprintf(buf, 200, "\r\nPC: %x\r\nLR: %x\r\nmemused: %db\r\n", + psp[6], psp[5], heap_used); + serial_puts(buf); } __attribute__ ((naked)) -- cgit v1.2.3