aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMin Xu <min.xu@min-info.net>2014-10-25 22:08:04 +0200
committerHarald Welte <laforge@gnumonks.org>2014-10-25 22:08:04 +0200
commit72fdf67455ad0d8c2e5f4ab378bef0641719b2d3 (patch)
tree60e7f2f17d04b27ef40a658881f61fee3cb924c0
parent873461b41a4a4d4655e84d68377db37baec9a09d (diff)
improve handling of spurious IRQsminxu-fixes
rather than printing directly from the interrupt handler, just increment the number and print it from the main loop function instead.
-rw-r--r--firmware/src/simtrace/main_simtrace.c27
1 files changed, 21 insertions, 6 deletions
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();
}