diff options
| author | Damien George | 2015-06-10 14:25:54 +0100 |
|---|---|---|
| committer | Damien George | 2015-12-22 21:00:20 +0000 |
| commit | 401af50dc081faa421e7caef18fde2beb15632e4 (patch) | |
| tree | 3af529bf86743dddf182c632849edf2a9ecf5f6a /stmhal/irq.h | |
| parent | abd0fcfc86c413d7de58f0c927ca6f598ee12950 (diff) | |
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.
Diffstat (limited to 'stmhal/irq.h')
| -rw-r--r-- | stmhal/irq.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/stmhal/irq.h b/stmhal/irq.h index bf8c1fcd9..f3a8a2cc9 100644 --- a/stmhal/irq.h +++ b/stmhal/irq.h @@ -28,6 +28,19 @@ #define IRQ_STATE_DISABLED (0x00000001) #define IRQ_STATE_ENABLED (0x00000000) +// Enable this to get a count for the number of times each irq handler is called, +// accessible via pyb.irq_stats(). +#define IRQ_ENABLE_STATS (0) + +#if IRQ_ENABLE_STATS +extern uint32_t irq_stats[FPU_IRQn + 1]; +#define IRQ_ENTER(irq) ++irq_stats[irq] +#define IRQ_EXIT(irq) +#else +#define IRQ_ENTER(irq) +#define IRQ_EXIT(irq) +#endif + static inline mp_uint_t query_irq(void) { return __get_PRIMASK(); } @@ -60,6 +73,7 @@ static inline void restore_irq_pri(uint32_t basepri) { MP_DECLARE_CONST_FUN_OBJ(pyb_wfi_obj); MP_DECLARE_CONST_FUN_OBJ(pyb_disable_irq_obj); MP_DECLARE_CONST_FUN_OBJ(pyb_enable_irq_obj); +MP_DECLARE_CONST_FUN_OBJ(pyb_irq_stats_obj); // IRQ priority definitions. // |
