TI TDA2HG SOC在EDMA模式下的mcspi始终为0

问题描述

我已经尝试过IT e2e支持论坛来解决这个问题,但无济于事。

我在TDA2HG SOC芯片上进行开发。并使用VisionSDK(v03.05)使mcspi在具有EDMA模式的IPU1上运行。两周后,我弄清楚了如何使用GIO模型在EDMA成功的情况下初始化MCSPI。这是我的初始化代码

static void Utils_mcspiUserSlaveCommonInit(uint32_t mcSPINum)
{
    static uint32_t done = 0U;
    if (done == 0U)
    {
        Mcspi_init();
        done = 1U;
    }
    memcpy((Void *)&mcspiCfgPrms[mcSPINum],(const Void *)&Mcspi_ParaMS,sizeof(Mcspi_Params));
    /* Set the McSPI parameters */
    mcspiCfgPrms[mcSPINum].instNum = mcSPINum;
    mcspiCfgPrms[mcSPINum].opMode          = MCSPI_OPMODE_DMAINTERRUPT;
    mcspiCfgPrms[mcSPINum].hwiNumber       = 7;
    mcspiCfgPrms[mcSPINum].enableCache     = (UInt32) TRUE;
    mcspiCfgPrms[mcSPINum].edma3EventQueue = 0;
    mcspiCfgPrms[mcSPINum].enableErrIntr   = (UInt32) FALSE;
    mcspiCfgPrms[mcSPINum].prcmPwrmEnable = TRUE;

    mcspiCfgPrms[mcSPINum].spiHWCfgData.masterOrSlave         = MCSPI_COMMMODE_SLAVE;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.singleOrMultiChEnable = MCSPI_SINGLE_CHANNEL;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.pinopModes    = MCSPI_PInopMODE_4PIN;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.fifoRxTrigLvl = 32;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.fifoTxTrigLvl = 32;

    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].charLength = MCSPI_LEN_8BIT;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].multiWordAccessEnable =
        (UInt32)FALSE;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].spiChipSelectEnablePol =
        (UInt32)FALSE;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].clockMode =
        MCSPI_MODE0;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].clockRatioExtension = 0;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].spiWordInitDelay =
        MCSPI_NO_DELAY;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].trasmitReceiveMode =
        MCSPI_BOTH_RXTX;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].granularityEnable =
        (UInt32)TRUE;
    /* 24 MHz Bus Frequency */
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].busFreq = 0;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].spienHighPolarity =
        (UInt32)FALSE;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].slaveModeChipSelect =
        MCSPI_SPIEN_0;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].spiDat0Dir = MCSPI_IN;
    mcspiCfgPrms[mcSPINum].spiHWCfgData.configChfmt[0].spiDat1Dir = MCSPI_OUT;

    if (MCSPI_OPMODE_INTERRUPT == mcspiCfgPrms[mcSPINum].opMode) {
        Vps_printf(" UTILS_MCSPI: %s is configured in interrupt mode!!\r\n",gMcspiDriverNames[mcSPINum]);
    }
}

但是我只能收到0。这是我的读写代码

Int32 Utils_mcspiReadWrite(void * fd,UInt8 *pRxBuff,UInt8 *pTxBuff,UInt16 len)
{
    UInt32                    size             = 0U;
    Int                       status           = IOM_COMPLETED;
    Mcspi_DataParam           issueDataparam   = {0};
    Mcspi_DataParam           reclaimDataparam = {0};
    Ptr                       pReclaimDataParam;
    Int32                     retVal   = SYstem_LINK_STATUS_SOK;
    Utils_mcspiCommHandle commHndl = (Utils_mcspiCommHandle) fd;
    // commHndl->mcspiIoPrms.timeout = 1000 * 1000;

    issueDataparam.inBuffer = (UInt8 *) pRxBuff;
    issueDataparam.outBuffer = (UInt8 *) pTxBuff;
    issueDataparam.bufLen   = (UInt32) len;

    if ((UInt32)len > 0x1000U)
    {
        Vps_printf(" UTILS_MCSPI: Too large read requested!! Length = %x\r\n",(UInt32)len);
        retVal = SYstem_LINK_STATUS_EFAIL;
    }
    if (retVal == SYstem_LINK_STATUS_SOK)
    {
        size = (UInt32)len;

        status = GIO_issue(commHndl->mcspiHandle,&issueDataparam,size,NULL);

        if ((status != IOM_PENDING) && (status != IOM_COMPLETED))
        {
            Vps_printf(" UTILS_MCSPI: Failed to issue empty buffer to stream!!\r\n");
            return SYstem_LINK_STATUS_EFAIL;
        }

        pReclaimDataParam = (Ptr) & reclaimDataparam;
        status =
            GIO_reclaim((GIO_Object *) commHndl->mcspiHandle,(Ptr *) &pReclaimDataParam,NULL,NULL);
        if (IOM_COMPLETED != status)
        {
            Vps_printf(" UTILS_MCSPI: SPI Read/Write Failed: %d\r\n",status);
            retVal = SYstem_LINK_STATUS_EFAIL;
        }
        else
        {
            retVal = (Int32) len;
        }
    }
    return retVal;
}

我使用“ Utils_memAlloc”函数在ddr本地节上分配pRxBuff和pTxBuff的内存,而len为96。我认为没有任何问题。但是上帝知道我只有0。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)