File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ static void my_box_switch_irq(void)
45
45
/* Print LED state on serial port. */
46
46
uvisor_ctx->pc ->printf (" \r\n Pressed switch, printing from interrupt - LED changed to %i\r\n\r\n " ,
47
47
(int ) (*uvisor_ctx->led ));
48
+ NVIC_ClearPendingIRQ (0 );
48
49
}
49
50
50
51
static void my_box_main (const void *)
@@ -70,12 +71,25 @@ static void my_box_main(const void *)
70
71
if (!(uvisor_ctx->sw = new InterruptIn (SECURE_SWITCH))) {
71
72
pc->printf (" ERROR: failed to allocate memories for switch\r\n " );
72
73
} else {
74
+ #if !defined(TARGET_MPS2)
73
75
/* Register handler for switch. */
74
76
uvisor_ctx->sw ->mode (SECURE_SWITCH_PULL);
75
77
uvisor_ctx->sw ->fall (my_box_switch_irq);
76
78
77
79
/* No problem to return here as everything is initialized. */
78
80
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) */
79
93
}
80
94
delete uvisor_ctx->led ;
81
95
}
You can’t perform that action at this time.
0 commit comments