From 401af50dc081faa421e7caef18fde2beb15632e4 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 10 Jun 2015 14:25:54 +0100 Subject: stmhal: Add pyb.irq_stats() to get statistics about IRQ calls. Adds a lot of code, makes IRQs a bit less efficient, but is very useful for debugging. Usage: pyb.irq_stats() returns a memory view that can be read and written, eg: list(pyb.irq_stats()) pyb.irq_stats()[0] pyb.irq_stats()[0] = 0 The patch provides general IRQ_ENTER() and IRQ_EXIT() macros that can be modified to provide further IRQ statistics if desired. --- stmhal/modpyb.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'stmhal/modpyb.c') diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index be71f3f80..0f18b04ed 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -139,6 +139,9 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_wfi), (mp_obj_t)&pyb_wfi_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_disable_irq), (mp_obj_t)&pyb_disable_irq_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_enable_irq), (mp_obj_t)&pyb_enable_irq_obj }, + #if IRQ_ENABLE_STATS + { MP_OBJ_NEW_QSTR(MP_QSTR_irq_stats), (mp_obj_t)&pyb_irq_stats_obj }, + #endif { MP_OBJ_NEW_QSTR(MP_QSTR_stop), (mp_obj_t)&machine_sleep_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_standby), (mp_obj_t)&machine_deepsleep_obj }, -- cgit v1.2.3