本人有检查所使用sdk源码的习惯,想请诸位帮我确认一下sdk是否有问题?sdk是官网下载版本,如有新的,希望能告诉我。
1.赋值dma错误中断回调函数的条件错误(第一个函数)。
2.在调用回调时,错误中断中调用的是传输完成的中断(第二个函数)。
以下源码从dmac.c文件中复制,版本为HC32F030_DDL_Rev1.3.1。
en_result_t Dma_ConfigIrq(en_dma_channel_t enCh,stc_dma_irq_sel_t* stcDmaIrqCfg,stc_dma_irq_calbakfn_pt_t* pstcDmaIrqCalbaks)
{
ASSERT(IS_VALID_CH(enCh));
if(!IS_VALID_CH(enCh))
{
return ErrorInvalidParameter;
}
if(DmaCh0 == enCh)
{
if (TRUE == stcDmaIrqCfg->TrnErrIrq)
{
if (NULL != pstcDmaIrqCalbaks->pfnDma0TranferCompleteIrq)
{
stcDmaIrqCalbaks.pfnDma0TranferErrIrq = pstcDmaIrqCalbaks->pfnDma0TranferErrIrq;
}
}
if (TRUE == stcDmaIrqCfg->TrnCpltIrq)
{
if (NULL != pstcDmaIrqCalbaks->pfnDma0TranferCompleteIrq)
{
stcDmaIrqCalbaks.pfnDma0TranferCompleteIrq = pstcDmaIrqCalbaks->pfnDma0TranferCompleteIrq;
}
}
}
else if(DmaCh1 == enCh)
{
if (TRUE == stcDmaIrqCfg->TrnErrIrq)
{
if (NULL != pstcDmaIrqCalbaks->pfnDma1TranferCompleteIrq)
{
stcDmaIrqCalbaks.pfnDma1TranferErrIrq = pstcDmaIrqCalbaks->pfnDma1TranferErrIrq;
}
}
if (TRUE == stcDmaIrqCfg->TrnCpltIrq)
{
if (NULL != pstcDmaIrqCalbaks->pfnDma1TranferCompleteIrq)
{
stcDmaIrqCalbaks.pfnDma1TranferCompleteIrq = pstcDmaIrqCalbaks->pfnDma1TranferCompleteIrq;
}
}
}else
{}
return Ok;
}
void Dma_IRQHandler(uint8_t u8Param)
{
if((DmaAddOverflow == M0P_DMAC->CONFB0_f.STAT)||(DmaHALT == M0P_DMAC->CONFB0_f.STAT)||(DmaAccSCRErr == M0P_DMAC->CONFB0_f.STAT) ||(DmaAccDestErr == M0P_DMAC->CONFB0_f.STAT))
{
if (NULL != stcDmaIrqCalbaks.pfnDma0TranferErrIrq)
{
stcDmaIrqCalbaks.pfnDma0TranferCompleteIrq();
}
M0P_DMAC->CONFB0_f.STAT = 0u;
}
if((DmaAddOverflow == M0P_DMAC->CONFB1_f.STAT)||(DmaHALT == M0P_DMAC->CONFB1_f.STAT)||(DmaAccSCRErr == M0P_DMAC->CONFB1_f.STAT) ||(DmaAccDestErr == M0P_DMAC->CONFB1_f.STAT))
{
if (NULL != stcDmaIrqCalbaks.pfnDma1TranferErrIrq)
{
stcDmaIrqCalbaks.pfnDma1TranferCompleteIrq();
}
M0P_DMAC->CONFB1_f.STAT = 0u;
}
if(DmaTransferComplete == M0P_DMAC->CONFB0_f.STAT)
{
if (NULL != stcDmaIrqCalbaks.pfnDma0TranferCompleteIrq)
{
stcDmaIrqCalbaks.pfnDma0TranferCompleteIrq();
}
M0P_DMAC->CONFB0_f.STAT = 0u;
}
if(DmaTransferComplete == M0P_DMAC->CONFB1_f.STAT)
{
if (NULL != stcDmaIrqCalbaks.pfnDma1TranferCompleteIrq)
{
stcDmaIrqCalbaks.pfnDma1TranferCompleteIrq();
}
M0P_DMAC->CONFB1_f.STAT = 0u;
}
}
|