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.

执行CSL_edma3Open()函数的问题



执行CSL_edma3Open()函数后hModule是空,导致无法EDMA功能。不知道为什么出现这个问题?
CSL_EDMA3的值是1。

void EDMAInit()
{
    CSL_Edma3ChannelAttr     chParam;
    CSL_Edma3Context         edmaContext;
    CSL_Edma3QueryInfo       info;
    CSL_Edma3CmdIntr         regionIntr;
    CSL_Edma3CmdDrae         regionAccess;
    CSL_Status               status;

   /* Edma Module Initialization */
    CSL_edma3Init(&edmaContext);    //初始化edma上下文对象变量,返回状态CSL_SOK

    /* Edma Module Level Open, 得到EDMA寄存器组的首地址,赋给edmaObj->regs,最后返回的指针hModule实际上指向edmaObj*/
    hModule = CSL_edma3Open(&edmaObj,CSL_EDMA3,NULL,&status);

    /* Query Module Info ,得到EDMA控制器的状态,实际上就是把PID和CCCFG寄存器的值读出到info*/
    CSL_edma3GetHwStatus(hModule,CSL_EDMA3_QUERY_INFO, &info);
......
}

  • 你测试到CSL_edma3Init(&edmaContext); 返回值是什么?对于这个函数的参数,文档中说明是:  

    pContext    Pointer to module-context. As EDMA doesn't have
                            any context based information user is expected 
                            to pass NULL
  • 问题已解决,将CSL_EDMA的值设为2就可以了,其他数值就不行,原因是什么?

  • 可以把CSL的source code加到你的工程里debug一下。例如下面是CSL_edma3Open的函数体,有多处条件判断都可能导致返回NULL。

    CSL_Edma3Handle CSL_edma3Open
    (
    CSL_Edma3Obj* pEdmaObj,
    CSL_InstNum edmaNum,
    CSL_Edma3ModuleAttr* pAttr,
    CSL_Status* pStatus
    )
    {
    CSL_Edma3ModuleBaseAddress baseAddress;
    CSL_Edma3CfgInfo cfgInfo;
    CSL_Edma3Handle hEdma = (CSL_Edma3Handle)NULL;

    /* Parameter Validation: Ensure that there is a placeholder to hold the status of the API */
    if (pStatus == NULL)
    return NULL;

    /* Parameter Validation: Ensure that there a valid parameter EDMA object is passed. */
    if (pEdmaObj == NULL)
    {
    *pStatus = CSL_ESYS_INVPARAMS;
    return NULL;
    }

    /* Get the EDMA Base Address. */
    *pStatus = CSL_edma3ccGetModuleBaseAddr(edmaNum, pAttr, &baseAddress, &cfgInfo);
    if (*pStatus == CSL_SOK)
    {
    /* Success: Initialize the parameters here. */
    pEdmaObj->regs = baseAddress.regs;
    pEdmaObj->instNum = (CSL_InstNum)edmaNum;
    pEdmaObj->cfgInfo = cfgInfo;

    /* Return the handle */
    hEdma = (CSL_Edma3Handle)pEdmaObj;
    }
    else
    {
    /* Error: Failed to get the base address for the Instance; report failure. */
    pEdmaObj->regs = (CSL_Edma3ccRegsOvly)NULL;
    pEdmaObj->instNum = (CSL_InstNum) -1;
    }
    return (hEdma);
    }

  • 之前不行是因为执行到

    *pStatus = CSL_edma3ccGetModuleBaseAddr(edmaNum, pAttr, &baseAddress, &cfgInfo);

    时*pStatus不等于CSL_SOK。