中断反注册 由于我们使用中断(部分)时需要在 hc32f46x_interrupts.c/h 的文件中定义的结构体中进行注册,如果想第二次注册(例如,更改回调接口)时,必须要反注册,否则不能正常注册。这个问题在我们使用 IAP 和 APP 两个程序时尤为明显!
en_result_t enIrqRegistration(const stc_irq_regi_conf_t *pstcIrqRegiConf) { // todo, assert ... stc_intc_sel_field_t *stcIntSel; en_result_t enRet = Ok;
//DDL_ASSERT(NULL != pstcIrqRegiConf->pfnCallback); DDL_ASSERT(IS_NULL_POINT(pstcIrqRegiConf->pfnCallback));
/* IRQ032~127 whether out of range */ if (((((pstcIrqRegiConf->enIntSrc/32)*6 + 32) > pstcIrqRegiConf->enIRQn) || \ (((pstcIrqRegiConf->enIntSrc/32)*6 + 37) < pstcIrqRegiConf->enIRQn)) && \ (pstcIrqRegiConf->enIRQn >= 32)) { enRet = ErrorInvalidParameter; } else { stcIntSel = (stc_intc_sel_field_t *)((uint32_t)(&M4_INTC->SEL0) + \ (4u * pstcIrqRegiConf->enIRQn)); if (0x1FFu == stcIntSel->INTSEL) /* 如果已经初始化过,这里将不能再初始化 */ { stcIntSel->INTSEL = pstcIrqRegiConf->enIntSrc; IrqHandler[pstcIrqRegiConf->enIRQn] = pstcIrqRegiConf->pfnCallback; } else { enRet = ErrorUninitialized; } } return enRet; }
具体方法就是使用 enIrqResign 函数进行重新标记!
|