外设反初始化
我的项目结构是 IAP(在线升级) + APP,外设在 IAP 中工作正常,但是在 APP 中工作不正常。这主要是由于:外设在 IAP 中已经初始化,然而在调整到 APP 之后,这部分外设由于已经被初始化,导致不会再次被初始化。这一点其实对于 ST 的 MCU 同样适用。因此,需要我们来特殊处理!
例如 hc32f46x_interrupts.c/h 中配置的中断,如果在 IAP 中已经被设置,跳转到 APP 后,就无法再正常配置了(全局变量中会检查是否被配置过)
e
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 函数进行重新标记!
外设反初始化
我的项目结构是 IAP(在线升级) + APP,外设在 IAP 中工作正常,但是在 APP 中工作不正常。这主要是由于:外设在 IAP 中已经初始化,然而在调整到 APP 之后,这部分外设由于已经被初始化,导致不会再次被初始化。这一点其实对于 ST 的 MCU 同样适用。因此,需要我们来特殊处理!
例如 hc32f46x_interrupts.c/h 中配置的中断,如果在 IAP 中已经被设置,跳转到 APP 后,就无法再正常配置了(全局变量中会检查是否被配置过)
e
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 函数进行重新标记!
举报