例如 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;
}
|