From b6caca4b64a73d8d3ab4ce6b51cea71b8f1a54b0 Mon Sep 17 00:00:00 2001 From: Min Xu Date: Sat, 25 Oct 2014 22:08:04 +0200 Subject: improve handling of spurious IRQs rather than printing directly from the interrupt handler, just increment the number and print it from the main loop function instead. --- firmware/src/simtrace/main_simtrace.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'firmware/src/simtrace/main_simtrace.c') diff --git a/firmware/src/simtrace/main_simtrace.c b/firmware/src/simtrace/main_simtrace.c index b84525f..8069349 100644 --- a/firmware/src/simtrace/main_simtrace.c +++ b/firmware/src/simtrace/main_simtrace.c @@ -134,16 +134,30 @@ static int simtrace_usb_in(struct req_ctx *rctx) req_ctx_set_state(rctx, RCTX_STATE_FREE); break; } + return 0; } -void custom_spurious_handler(unsigned previous_pc) +static volatile unsigned spuirq_pc, spuirq_count = 0; + +static void check_spurious_irq() +{ + static unsigned last_count = 0; + if (last_count != spuirq_count) { + DEBUGPCR("SPURRIOUS IRQ %i [Old PC = %08X]", spuirq_count, spuirq_pc); + last_count = spuirq_count; + } +} + +static void custom_spurious_handler(unsigned previous_pc) { - char dbg_buf[100]; - sprintf(dbg_buf, "SPURRIOUS IRQ [Old PC = %08X]\n\r", previous_pc); - AT91F_DBGU_Frame(dbg_buf); + unsigned flags; + local_irq_save(flags); + spuirq_pc = previous_pc; + spuirq_count++; + local_irq_restore(flags); } -void custom_spurious_entry(void) +static void custom_spurious_entry(void) { register unsigned *previous_pc asm("r0"); asm("ADD R1, SP, #16; LDR R0, [R1]"); @@ -247,10 +261,11 @@ void _main_func(void) if ((loopLow & 0xFFFF) == 0) { DEBUGPCR("Heart beat %08X", loopHigh++); } - if ((loopLow & 0x3FF) == 0) { + if ((loopLow & 0x3F) == 0) { iso_uart_idleflush(); } loopLow++; iso_uart_report_errors(); + check_spurious_irq(); } -- cgit v1.2.3