Skip to content

Commit d7defa7

Browse files
committed
Use periodic manual IRQ instead of SW for MPS2 target
1 parent 776d110 commit d7defa7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

source/led.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static void my_box_switch_irq(void)
4545
/* Print LED state on serial port. */
4646
uvisor_ctx->pc->printf("\r\nPressed switch, printing from interrupt - LED changed to %i\r\n\r\n",
4747
(int) (*uvisor_ctx->led));
48+
NVIC_ClearPendingIRQ(0);
4849
}
4950

5051
static void my_box_main(const void *)
@@ -70,12 +71,25 @@ static void my_box_main(const void *)
7071
if (!(uvisor_ctx->sw = new InterruptIn(SECURE_SWITCH))) {
7172
pc->printf("ERROR: failed to allocate memories for switch\r\n");
7273
} else {
74+
#if !defined(TARGET_MPS2)
7375
/* Register handler for switch. */
7476
uvisor_ctx->sw->mode(SECURE_SWITCH_PULL);
7577
uvisor_ctx->sw->fall(my_box_switch_irq);
7678

7779
/* No problem to return here as everything is initialized. */
7880
return;
81+
#else /* !defined(TARGET_MPS2) */
82+
/* Register handle for generic IRQ. */
83+
NVIC_SetVector(0, (uint32_t) &my_box_switch_irq);
84+
NVIC_ClearPendingIRQ(0);
85+
NVIC_EnableIRQ(0);
86+
87+
/* Trigger IRQ periodically. */
88+
while (1) {
89+
NVIC_SetPendingIRQ(0);
90+
Thread::wait(1000);
91+
}
92+
#endif /* !defined(TARGET_MPS2) */
7993
}
8094
delete uvisor_ctx->led;
8195
}

0 commit comments

Comments
 (0)