summaryrefslogtreecommitdiffstatshomepage
path: root/stmhal/irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'stmhal/irq.c')
-rw-r--r--stmhal/irq.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/stmhal/irq.c b/stmhal/irq.c
index 749e4813c3..44758e11bc 100644
--- a/stmhal/irq.c
+++ b/stmhal/irq.c
@@ -31,6 +31,10 @@
/// \moduleref pyb
+#if IRQ_ENABLE_STATS
+uint32_t irq_stats[FPU_IRQn + 1] = {0};
+#endif
+
/// \function wfi()
/// Wait for an interrupt.
/// This executies a `wfi` instruction which reduces power consumption
@@ -62,3 +66,11 @@ STATIC mp_obj_t pyb_enable_irq(uint n_args, const mp_obj_t *arg) {
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_enable_irq_obj, 0, 1, pyb_enable_irq);
+
+#if IRQ_ENABLE_STATS
+// return a memoryview of the irq statistics array
+STATIC mp_obj_t pyb_irq_stats(void) {
+ return mp_obj_new_memoryview(0x80 | 'I', MP_ARRAY_SIZE(irq_stats), &irq_stats[0]);
+}
+MP_DEFINE_CONST_FUN_OBJ_0(pyb_irq_stats_obj, pyb_irq_stats);
+#endif