⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcp2_shared_mode_example.c

📁 Dm6455 driver,magbe useful to you!
💻 C
📖 第 1 页 / 共 2 页
字号:
        TRUE);

 
    /* Enable Channel */
    CSL_edma3HwChannelControl (hChannel1, CSL_EDMA3_CMD_CHANNEL_ENABLE, NULL);

    /* Enable Channel */
    CSL_edma3HwChannelControl (hChannel, CSL_EDMA3_CMD_CHANNEL_ENABLE, NULL);


    /* reset and start the TCP */
    TCP2_reset ();
    TCP2_start ();
    
    /* wait for the status to indicate extrinsics to be read */
    while (0x0B != TCP2_statTcpState ());
    printf ("Reading the extrinsics \n");

    /* wait for the status to indicate the extrinsics read complete */    
    while (0x01 == TCP2_statWaitExt ());
    printf ("Reading the extrinsics complete \n");
    
    /* Disable cahnnels and clear the EDMA event registers */
    CSL_edma3HwChannelControl (hChannel, CSL_EDMA3_CMD_CHANNEL_DISABLE, NULL);
    CSL_edma3HwChannelControl (hChannel1, CSL_EDMA3_CMD_CHANNEL_DISABLE, NULL);
    CSL_edma3HwChannelControl (hChannel, CSL_EDMA3_CMD_CHANNEL_CLEAR, NULL);
    CSL_edma3HwChannelControl (hChannel1, CSL_EDMA3_CMD_CHANNEL_CLEAR, NULL);
    
    /* clear the EDMA error registers */
    chErrClear.missed = TRUE;
    chErrClear.secEvt = TRUE;
    CSL_edma3HwChannelControl (hChannel, CSL_EDMA3_CMD_CHANNEL_CLEARERR, 
                               &chErrClear);
    CSL_edma3HwChannelControl (hChannel1, CSL_EDMA3_CMD_CHANNEL_CLEARERR, 
                               &chErrClear);

    printf ("Example complete \n");

}

/*
 * =============================================================================
 *   @func   tcp2_configEdma
 *   @desc
 *      Configures EDMA channels 30 and 31. 
 *      For channel 31 there are 3 param entries(0, 1 and 2) which are linked. 
 *          Link 0 transfers the TCP2 input configuration register values.
 *          Link 1 transfer the systematics and parity data.
 *          Link 2 transfers the apriori data
 *      For channel 30 there is 1 param entry (3).
 *          Link 3 transfers the extrinsic data.
 *
 *   @expected result
 *      
 *
 *   @eg
 *      tcp2_configEdma();  
 * =============================================================================
 */
Uint16 tcp2_configEdma (
    Uint32 *inputRegs,
    Uint8  *aprioriData,    
    Uint8  *extrinsicBuffer,
    Uint32  txDataLen,
    Uint32  aprioriTxlen,
    Uint32  rxDataLen,
    Bool    endConfig
)
{
    volatile Uint16             count;
    CSL_Status                  chStatus, chStatus1;

    CSL_edma3Init(&context);
    
    CSL_edma3Open(&edmaObj,CSL_EDMA3,NULL,&chStatus);

    /* Channel Configuration for TCPXEVT event */
    /* Channel Open */
    if (txParamIndex == 0){ /* open it only the first time */
        chParam.regionNum = CSL_EDMA3_REGION_GLOBAL;
        chParam.chaNum = CSL_EDMA3_CHA_TCP2XEVT;
        hChannel = CSL_edma3ChannelOpen(&ChObj, CSL_EDMA3, &chParam, &chStatus);
        if ((chStatus != CSL_SOK) || (hChannel == NULL)) {
            printf("Error in EDMA channel open function\n");
            return 0;
        }

        /* Channel Setup for PaRAM entry 0 */
        if (CSL_SOK != CSL_edma3HwChannelSetupParam(hChannel, txParamIndex )){
            printf("Error is EDMA channel setup for channel #31\n");
            return 0;
        }
    
        if (CSL_SOK != CSL_edma3HwChannelSetupQue(hChannel, CSL_EDMA3_QUE_0)) {
            printf("Error is EDMA channel setup for channel #31\n");
            return 0;
        }
    }
    
    /* Setup EDMA to transmit the input configuration parameters  */
    hParam[txParamIndex] = CSL_edma3GetParamHandle (hChannel, txParamIndex, &chStatus);
    myParamSetup.option = CSL_EDMA3_OPT_MAKE(FALSE, FALSE, FALSE, FALSE, 0,
                                                CSL_EDMA3_TCC_NORMAL,
                                                CSL_EDMA3_FIFOWIDTH_NONE,
                                                FALSE,CSL_EDMA3_SYNC_A,
                                                CSL_EDMA3_ADDRMODE_INCR,
                                                CSL_EDMA3_ADDRMODE_INCR); 
                                                          
    myParamSetup.srcAddr = (Uint32)inputRegs;
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(0, 0);     
    myParamSetup.dstAddr = (Uint32)CSL_TCP2_CFG_REGS;
    myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(
                        ((txParamIndex+1) * EDMA_PARAM_SIZE), 0);  /* offset
                                                     to the next PARAM entry */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(sizeof (TCP2_ConfigIc), 1); 
    myParamSetup.cCnt = 1;
    
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[txParamIndex], &myParamSetup)) {
        printf("Error in EDMA PARAM setup for entry #0\n");
        return 0;
    }

    /* Setup link to transmit systematics and parity data using param */
    txParamIndex++;
    hParam[txParamIndex] = CSL_edma3GetParamHandle (hChannel, txParamIndex, &chStatus);
    myParamSetup.option = CSL_EDMA3_OPT_MAKE(FALSE, FALSE, FALSE, FALSE, 0,
                                                CSL_EDMA3_TCC_NORMAL,
                                                CSL_EDMA3_FIFOWIDTH_NONE,
                                                FALSE,CSL_EDMA3_SYNC_AB,
                                                CSL_EDMA3_ADDRMODE_INCR,
                                                CSL_EDMA3_ADDRMODE_INCR); 
                                                          
    myParamSetup.srcAddr = (Uint32)sysParData;
    myParamSetup.dstAddr = (Uint32)CSL_TCP2_X0_MEM;
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(8, 8);     
    /* length of the systematic and  parity data to be transferred */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(8, (txDataLen/2)); //txDataLen 
    /* linking to the offset to the next PARAM entry */
    myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE(
                        ((txParamIndex+1) * EDMA_PARAM_SIZE), 0);     
    myParamSetup.cCnt = 1;
    myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE(0, 0);     
    
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[txParamIndex], &myParamSetup)) {
        printf("Error in EDMA PARAM setup for entry #1\n");
        return 0;
    }
    txParamIndex++;
    
    /* Setup link to transmit apriori data using param */
    hParam[txParamIndex] = CSL_edma3GetParamHandle (hChannel, txParamIndex, &chStatus);
    myParamSetup.option = CSL_EDMA3_OPT_MAKE(FALSE, FALSE, FALSE, FALSE, 0,
                                                CSL_EDMA3_TCC_NORMAL,
                                                CSL_EDMA3_FIFOWIDTH_NONE,
                                                FALSE,CSL_EDMA3_SYNC_A,
                                                CSL_EDMA3_ADDRMODE_INCR,
                                                CSL_EDMA3_ADDRMODE_INCR); 
                                                          
    myParamSetup.srcAddr = (Uint32)aprioriData;
    myParamSetup.dstAddr = (Uint32)CSL_TCP2_W1_MEM;
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE(0, 0);     
    /* length of the apriori data to be transferred */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE(aprioriTxlen, 1);  
    myParamSetup.cCnt = 1;
    if (!endConfig) {                                       
        myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE (
                                        ((txParamIndex+1) * EDMA_PARAM_SIZE), 0);     
    }
    else {
        myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE (
                                        CSL_EDMA3_LINK_NULL, 0);     
    }                                        
    
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[txParamIndex], &myParamSetup)) {
        /* 
         * link this with the next transfer to be configured unless this 
         *                                       is the last iteration 
         */
        printf("Error in EDMA PARAM setup for entry #2\n");
        return 0;
    }
    
    /* increment to the next PARAM index */
    txParamIndex++;
      
    /* Receive Channel Open */
    if (rxParamIndex == 20) { /* open the channel only once */
        chParam1.regionNum = CSL_EDMA3_REGION_GLOBAL;
        chParam1.chaNum = CSL_EDMA3_CHA_TCP2REVT;
        hChannel1 = CSL_edma3ChannelOpen (&ChObj1, CSL_EDMA3, &chParam1, 
                                                            &chStatus1);
        if ((chStatus1 != CSL_SOK) | (hChannel1 == NULL)) {
            printf("Error in EDMA channel open function\n");
            return 0;
        }

        /* Channel Setup */
        if (CSL_SOK != CSL_edma3HwChannelSetupParam(hChannel1, rxParamIndex))
        {
            printf("Error is EDMA channel setup for channel #30\n");
            return 0;
        }
        if (CSL_SOK != CSL_edma3HwChannelSetupQue(hChannel1, CSL_EDMA3_QUE_0))
        {
            printf("Error is EDMA channel setup for channel #30\n");
            return 0;
        }
    }

   /* Channel Setup */

    /* configure param entry 3 to read the extrinsics data */
    hParam[rxParamIndex] = CSL_edma3GetParamHandle (hChannel1, rxParamIndex, &chStatus);
    myParamSetup.option = CSL_EDMA3_OPT_MAKE (FALSE, FALSE, FALSE, FALSE, 0,
                                             CSL_EDMA3_TCC_NORMAL,
                                             CSL_EDMA3_FIFOWIDTH_NONE,
                                             FALSE,CSL_EDMA3_SYNC_A,
                                             CSL_EDMA3_ADDRMODE_INCR,
                                             CSL_EDMA3_ADDRMODE_INCR);           
    myParamSetup.srcAddr = (Uint32)CSL_TCP2_W0_MEM;
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE (rxDataLen, 1); /* number of bytes of 
                                    apriori data to be read */      
    myParamSetup.dstAddr = (Uint32)extrinsicBuffer;        
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE (0, 0);     
    /* 
     * link this with the next transfer to be configured unless this 
     *                                       is the last iteration 
     */
    if (!endConfig) {                                       
        myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE (
                                        ((rxParamIndex+1) * EDMA_PARAM_SIZE), 0);     
    }
    else {
        myParamSetup.linkBcntrld = CSL_EDMA3_LINKBCNTRLD_MAKE (
                                        CSL_EDMA3_LINK_NULL, 0);     
    }                                        
                                        
    myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE (0, 0);     
    myParamSetup.cCnt = 1;
    
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[rxParamIndex], &myParamSetup)) {
        printf("Error in EDMA paRam setup for entry #3\n");
        return 0;
    }
    
    /* increment to the next PARAM index */
    rxParamIndex++;
    return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -