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

📄 vcp2_hard_decisions_example.c

📁 Dm6455 driver,magbe useful to you!
💻 C
📖 第 1 页 / 共 2 页
字号:
    chErrClear.missed = TRUE;
    chErrClear.secEvt = TRUE;
    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_CLEARERR, 
                               &chErrClear);
    CSL_edma3HwChannelControl (hChannel1, CSL_EDMA3_CMD_CHANNEL_CLEARERR, 
                               &chErrClear);
    CSL_edma3HwChannelControl (hChannel, CSL_EDMA3_CMD_CHANNEL_CLEAR, NULL);
    CSL_edma3HwChannelControl (hChannel1, CSL_EDMA3_CMD_CHANNEL_CLEAR, NULL);
    
    /* Close EDMA channel */
    CSL_edma3ChannelClose (hChannel);
    CSL_edma3ChannelClose (hChannel1);
}

/*
 * ============================================================================
 *   @func   vcp2_configEdma
 *   @desc
 *      Configures EDMA channels 28 and 29. 
 *   @n For channel 29 there are 2 param entries(0 &1) which are linked. 
 *   @n -   Link 0 transfers the VCP2 input configuration register values.
 *   @n -   Link 1 transfers Branch metrics.
 *   @n
 *   @n For channel 28 there 2 param entry (2 & 3).
 *   @n -   Link 2 transfers the Hard decisions.
 *   @n -   Link 3 transfers the VCPOUT values
 *
 *   @expected result
 *      Appropriate message will be logged depending on 
 *      the result
 *
 *   @eg
 *      vcp2_configEdma(inputBm, ouputHD);  
 * ============================================================================
 */
Uint16
vcp2_configEdma (
    Uint32 inputBM,
    Uint32 outputHD
)
{
    CSL_Status chStatus, chStatus1;
    Uint32 receive_link_offset, transmit_link_offset;
    
    /* EDMA Initialization */
    CSL_edma3Init (&context);

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

    /* Channel Configuration for VCPXEVT event */
    /* Channel Open */
    chParam.regionNum = CSL_EDMA3_REGION_GLOBAL;
    chParam.chaNum = CSL_EDMA3_CHA_VCP2XEVT;
    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 */
    if (CSL_SOK != CSL_edma3HwChannelSetupParam (hChannel,
            0 /* PaRAM entry */ )) {
        printf ("Error in Tx EDMA channel setup\n");
        return 0;
    }
    if (CSL_SOK != CSL_edma3HwChannelSetupQue (hChannel,
       CSL_EDMA3_QUE_0)) {
        printf ("Error in Tx EDMA channel setup\n");
        return 0;
    }

    /* Channel Configuration for VCPREVT event */
    /* Channel Open */
    chParam1.regionNum = CSL_EDMA3_REGION_GLOBAL;
    chParam1.chaNum = CSL_EDMA3_CHA_VCP2REVT;
    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,
            2 /* PaRAM entry */ )) {
        printf ("Error in Rx EDMA channel setup\n");
        return 0;
    }
    if (CSL_SOK != CSL_edma3HwChannelSetupQue (hChannel1,
        CSL_EDMA3_QUE_0)) {
        printf ("Error in Rx EDMA channel setup\n");
        return 0;
    }

    /* Using PaRAMs 0, 1, 2, 3 */
    /* 0 and 1 are to transmit */
    /* 2 and 3 are to receive */
    hParam[0] = CSL_edma3GetParamHandle (hChannel, 0, &chStatus);
    hParam[1] = CSL_edma3GetParamHandle (hChannel, 1, &chStatus);
    hParam[2] = CSL_edma3GetParamHandle (hChannel1, 2, &chStatus);
    hParam[3] = CSL_edma3GetParamHandle (hChannel1, 3, &chStatus);

    /* Lower 4 nibbles of the PaRAM address forms the link offset */

    /* PaRAMs 0 and 1 are linked */
    transmit_link_offset = (Uint32)hParam[1] & 0x0000FFFF; 

    /* PaRAMs 2 and 3 are linked */
    receive_link_offset = (Uint32)hParam[3] & 0x0000FFFF;

    /*
     *  itcchEn   -    False
     *  tcchEn    -    False
     *  itcintEn  -    False
     *  tcintEn   -    False
     *  tcc       -    0
     *  tccMode   -    Normal completion (interrupt after transfer completion)
     *  fwid      -    SAM, DAM are to increment, so fwid = none
     *  stat      -    0, linking allowed
     *  syncDim   -    A - synchronization
     *  dam       -    Destination address increment
     *  sam       -    Source address increment
     */
    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);                               /* Options */
    myParamSetup.srcAddr = (Uint32) & vcpConfig;         /* Source address */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE (VCPIC_DMA_SIZE, 1);
                                /* Single transfer of VCPIC_DMA_SIZE bytes */
    myParamSetup.dstAddr = (Uint32) &hVcp2Vbus->VCPIC0;      /* Destination address */
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE (0, 0);
                                                      /* Index do not care */
    myParamSetup.linkBcntrld =
         CSL_EDMA3_LINKBCNTRLD_MAKE (transmit_link_offset, 0);  /* linking */
    myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE (0, 0);
                                                      /* Index do not care */
    myParamSetup.cCnt = 1;                                  /* CCount is 1 */
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[0], &myParamSetup)) {
        printf ("Error in EDMA paRam setup for VCP IC register transfer\n");
        return 0;
    }

    transmit_link_offset = (Uint32)hParam[2] & 0x0000FFFF; 

    /* Setup link to transmit branch metrics */
    /*
     *  itcchEn   -    False
     *  tcchEn    -    False
     *  itcintEn  -    False
     *  tcintEn   -    False
     *  tcc       -    0
     *  tccMode   -    Normal completion (interrupt after transfer completion)
     *  fwid      -    64-bit
     *  stat      -    0, linking allowed
     *  syncDim   -    A - synchronization
     *  dam       -    Destination is a FIFO
     *  sam       -    Source address increment
     */
    myParamSetup.option = CSL_EDMA3_OPT_MAKE (FALSE, FALSE, FALSE, FALSE, 0,
        CSL_EDMA3_TCC_NORMAL, CSL_EDMA3_FIFOWIDTH_64BIT, FALSE,
        CSL_EDMA3_SYNC_A, CSL_EDMA3_ADDRMODE_CONST,
        CSL_EDMA3_ADDRMODE_INCR);                                /* Options */
    myParamSetup.srcAddr = (Uint32) branch_metric;        /* Source address */
                                                /* Source address increment */

    myParamSetup.dstAddr = (Uint32) & (hVcp2Vbus->VCPWBM);
                                                     /* Destination address */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE (DMA_BURST_SIZE, inputBM);
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE (DMA_BURST_SIZE, 0);
    myParamSetup.linkBcntrld =
        CSL_EDMA3_LINKBCNTRLD_MAKE (CSL_EDMA3_LINK_NULL, 0);
                                                              /* No linking */

                               /* inputBM transfers of DMA_BURST_SIZE bytes */
    myParamSetup.cCnt = 1;                                   /* CCount is 1 */
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[1], &myParamSetup)) {
        printf ("Error in EDMA paRam setup for branch metrics transfer\n");
        return 0;
    }

    /*
     *  itcchEn   -    False
     *  tcchEn    -    False
     *  itcintEn  -    False
     *  tcintEn   -    False
     *  tcc       -    0
     *  tccMode   -    Normal completion (interrupt after transfer completion)
     *  fwid      -    64-bit
     *  stat      -    0, linking allowed
     *  syncDim   -    A - synchronization
     *  dam       -    Destination to increment
     *  sam       -    Source is a FIFO
     */

    myParamSetup.option = CSL_EDMA3_OPT_MAKE (FALSE, FALSE, FALSE, FALSE, 0,
        CSL_EDMA3_TCC_NORMAL, CSL_EDMA3_FIFOWIDTH_64BIT, FALSE,
        CSL_EDMA3_SYNC_A, CSL_EDMA3_ADDRMODE_INCR,
        CSL_EDMA3_ADDRMODE_CONST);                               /* Options */
    myParamSetup.srcAddr = (Uint32)&(hVcp2Vbus->VCPRDECS);      /* Source */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE (outputHD, 1);
                                           /* outputHD bytes in a transfer */
    myParamSetup.dstAddr = (Uint32) hard_decision;          /* Destination */
    myParamSetup.srcDstBidx = CSL_EDMA3_BIDX_MAKE (0, outputHD);
                                                      
    myParamSetup.linkBcntrld =
         CSL_EDMA3_LINKBCNTRLD_MAKE (receive_link_offset, 0);  /* linking */

    myParamSetup.srcDstCidx = CSL_EDMA3_CIDX_MAKE (0, 0);
                                                      /* Index do not care */
    myParamSetup.cCnt = 1;                                       /* CCount */
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[2], &myParamSetup)) {
        printf ("Error in EDMA paRam setup for decisions read\n");
        return 0;
    }

    /*
     *  itcchEn   -    False
     *  tcchEn    -    False
     *  itcintEn  -    False
     *  tcintEn   -    False
     *  tcc       -    0
     *  tccMode   -    Normal completion (interrupt after transfer completion)
     *  fwid      -    SAM, DAM are to increment, so fwid = none
     *  stat      -    0, linking allowed
     *  syncDim   -    A - synchronization
     *  dam       -    Destination address increment
     *  sam       -    Source address increment
     */

    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);                                 /* Options */
    myParamSetup.srcAddr = (Uint32) & (hVcp2Vbus->VCPOUT1);       /* Source */
    myParamSetup.aCntbCnt = CSL_EDMA3_CNT_MAKE (VCPOUT_DMA_SIZE, 1);
                                 /* Transfer of VCPOUT_DMA_SIZE bytes 1 time */
    myParamSetup.dstAddr = (Uint32) & ouputParams[0];         /* Destination */
    myParamSetup.linkBcntrld =
        CSL_EDMA3_LINKBCNTRLD_MAKE (CSL_EDMA3_LINK_NULL, 0);
                                                               /* No linking */
    if (CSL_SOK != CSL_edma3ParamSetup (hParam[3], &myParamSetup)) {
        printf ("Error in EDMA paRam setup for output registers read\n");
        return 0;
    }

    return 1;

}

⌨️ 快捷键说明

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