From e06c186f805a2ebe285b08992f01c0deb59bf21e Mon Sep 17 00:00:00 2001 From: marton bognar Date: Thu, 17 Oct 2019 23:18:03 +0200 Subject: [PATCH] Only run sancus-step initialization once --- include/sancus_support/sancus_step.h | 12 ++++++------ src/sancus-step/sancus_step.c | 6 +++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/include/sancus_support/sancus_step.h b/include/sancus_support/sancus_step.h index ddbaf4d..de601be 100644 --- a/include/sancus_support/sancus_step.h +++ b/include/sancus_support/sancus_step.h @@ -48,17 +48,17 @@ void timerA_isr_entry2(void) \ "sub &%5, &%2\n\t" \ /* __ss_isr_interrupted_sm = false */ \ "mov #0x0, &%1\n\t" \ - /* check whether r1 register is set (0 if module got interrupted?) */ \ + /* check whether r1 register is set (0 if module got interrupted) */ \ "cmp #0x0, r1\n\t" \ - /* if module was not interrupted, jump to label "1" */ \ + /* if module was not interrupted, jump to label "1" (call end fn) */ \ "jne 1f\n\t" \ /* __ss_isr_interrupted_sm = true */ \ "mov #0x1, &%1\n\t" \ /* r1 = __isr_sp */ \ "mov &%3, r1\n\t" \ - /* */ \ + /* push r15 to stack */ \ "push r15\n\t" \ - /* */ \ + /* push 0 to stack */ \ "push #0x0\n\t" \ /* check whether __ss_dbg_measuring_reti_latency is set */ \ "cmp #0x0, &%7\n\t" \ @@ -72,7 +72,7 @@ void timerA_isr_entry2(void) \ "2: \n\t" \ /* call the first function parameter */ \ "call #" #fct_single_step "\n\t" \ - /* */ \ + /* push r15 to stack */ \ "push r15\n\t" \ /* r15 = __ss_isr_reti_latency */ \ "mov &%6, r15\n\t" \ @@ -80,7 +80,7 @@ void timerA_isr_entry2(void) \ "add #0x6, r15 ;\n\t" \ /* TACCR0 = r15 */ \ "mov r15, &%5\n\t" \ - /* */ \ + /* pop the stack top to r15 */ \ "pop r15\n\t" \ /* TACCTL0 = TACCTL_ENABLE_CONT */ \ "mov %11, &%12\n\t" \ diff --git a/src/sancus-step/sancus_step.c b/src/sancus-step/sancus_step.c index 94cb27c..173015b 100644 --- a/src/sancus-step/sancus_step.c +++ b/src/sancus-step/sancus_step.c @@ -17,6 +17,7 @@ int __ss_get_latency(void) int __ss_dbg_entry_delay = 0; int __ss_dbg_measuring_reti_latency = 0; +int __ss_dbg_init_done = 0; int __ss_isr_reti_latency = 0; int __ss_sm_exit_latency = 0; int __ss_isr_interrupted_sm = 0; @@ -28,7 +29,9 @@ int __ss_isr_interrupted_sm = 0; */ void __ss_start(void) { - __ss_init(); + if (__ss_dbg_init_done == 0) { + __ss_init(); + } __asm__("dint\n\t"); // disable interrupts timer_irqc(INIT_LATENCY); } @@ -66,6 +69,7 @@ void __ss_init(void) printf("entry delay: %d\n", __ss_dbg_entry_delay); __ss_dbg_measuring_reti_latency = 0; + __ss_dbg_init_done = 1; } void __ss_end(void)