This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C6748EDMA3回调函数

最近在看C6748的EDMA3,在看例程时有一个问题比较疑惑,请各位帮忙解答下。例程里面有一个回调函数,这个函数是做什么用的,怎么触发它,自己使用时是不是一定要用这个回调函数,如果不写这个函数有什么影响?

  • 回调函数一般是中断服务程序调用的。

    如有疑问,把你看到的具体代码部分指出来。

  • // 回调函数
    void (*cb_Fxn[EDMA3_NUM_TCC])(unsigned int tcc, unsigned int status, void *appData);

    /****************************************************************************/
    /* */
    /* 回调函数 */
    /* */
    /****************************************************************************/
    void callback(unsigned int tccNum, unsigned int status, void *appData)
    {
    (void)tccNum;
    (void)appData;

    if(EDMA3_XFER_COMPLETE == status)
    {
    // 传输成功
    irqRaised = 1;
    }

    else if(EDMA3_CC_DMA_EVT_MISS == status)
    {
    // 传输导致 DMA 事件丢失错误
    irqRaised = -1;
    }

    else if(EDMA3_CC_QDMA_EVT_MISS == status)
    {
    // 传输导致 QDMA 事件丢失错误
    irqRaised = -2;
    }

    irqRaised = 1;
    }

    // 注册回调函数
    cb_Fxn[tccNum] = &callback;

    // 如果没有指定回调函数 就无法清除 IPR 相应位
    // 写 ICR 清除 IPR 相应位
    EDMA3ClrIntr(SOC_EDMA30CC_0_REGS, indexl);
    (*cb_Fxn[indexl])(indexl, EDMA3_XFER_COMPLETE, NULL);

    上面的就是相关的代码,最后两行是在EDMA传输完成中断服务函数里面的,最后面那一行应该就是调用这个回调函数吧!这里为什么要用回调函数,我直接把相关代码写在后面可不可以,不使用回调函数。

  • JIONG TANG 说:
    我直接把相关代码写在后面可不可以

    当然可以。

    这是个软件的问题,自己想想吧。