Skip to content

Commit

Permalink
Only run sancus-step initialization once
Browse files Browse the repository at this point in the history
  • Loading branch information
martonbognar committed Oct 17, 2019
1 parent e954682 commit e06c186
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions include/sancus_support/sancus_step.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -72,15 +72,15 @@ 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" \
/* r15 += 6 */ \
"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" \
Expand Down
6 changes: 5 additions & 1 deletion src/sancus-step/sancus_step.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e06c186

Please sign in to comment.