@@ -37,3 +37,48 @@ static inline mp_uint_t query_irq(void) {
3737MP_DECLARE_CONST_FUN_OBJ (pyb_wfi_obj );
3838MP_DECLARE_CONST_FUN_OBJ (pyb_disable_irq_obj );
3939MP_DECLARE_CONST_FUN_OBJ (pyb_enable_irq_obj );
40+
41+ // IRQ priority definitions.
42+ // Lower number implies higher interrupt priority.
43+
44+ #define IRQ_PRI_CAN 0x7
45+ #define IRQ_SUBPRI_CAN 0x0
46+
47+ #define IRQ_PRI_DMA 0x6
48+ #define IRQ_SUBPRI_DMA 0x0
49+
50+ #define IRQ_PRI_EXTINT 0xf
51+ #define IRQ_SUBPRI_EXTINT 0xf
52+
53+ // Flash IRQ must be higher priority than interrupts of all those components
54+ // that rely on the flash storage.
55+ #define IRQ_PRI_FLASH 0x1
56+ #define IRQ_SUBPRI_FLASH 0x1
57+
58+ #define IRQ_PRI_OTG_FS 0x6
59+ #define IRQ_SUBPRI_OTG_FS 0x0
60+
61+ #define IRQ_PRI_OTG_HS 0x6
62+ #define IRQ_SUBPRI_OTG_HS 0x0
63+
64+ // PENDSV should be at the lowst priority so that other interrupts complete
65+ // before exception is raised.
66+ #define IRQ_PRI_PENDSV 0xf
67+ #define IRQ_SUBPRI_PENDSV 0xf
68+
69+ #define IRQ_PRI_RTC_WKUP 0xf
70+ #define IRQ_SUBPRI_RTC_WKUP 0xf
71+
72+ #define IRQ_PRI_TIM3 0x6
73+ #define IRQ_SUBPRI_TIM3 0x0
74+
75+ #define IRQ_PRI_TIM5 0x6
76+ #define IRQ_SUBPRI_TIM5 0x0
77+
78+ // Interrupt priority for non-special timers.
79+ #define IRQ_PRI_TIMX 0xe
80+ #define IRQ_SUBPRI_TIMX 0xe
81+
82+ #define IRQ_PRI_UART 0xd
83+ #define IRQ_SUBPRI_UART 0xd
84+