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

📄 main.c

📁 关于DM642片上支持库CSL的几个例程
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DSP/BIOS 4.90.270 06-11-03 (barracuda-m10)" */
/****************************************************************************\
 *           Copyright (C) 2001 Texas Instruments Incorporated.             *
 *                           All Rights Reserved                            *
 ****************************************************************************
 * VcpProcessing.pjt (3GPP-HD)                                              *
 *                                                                          *                                   *
 *                                                                          *
 * The purpose of this project is to demonstrate how to use the Viterbi Co- *
 * Processor (VCP) using the Chip Support Library (CSL).                    *
 *                                                                          *
 * User data, residing in the tcpuserx.asm files included with this project *
 * is processed through the VCP. The VCP is configured based on the channel *
 * parameters set in vcp_parameters.h. This software handles the TCP, EDMA, *
 * and interrupt configuration necessary to process each user channel.      *
\****************************************************************************/

#include <csl.h>
#include <csl_vcp.h>
#include <csl_edma.h>
#include "vcp_parameters.h"

/* Prototype declarations */
void intConfig(void);
void initExtMem(void);
Int32 checkResults(Uint32 *actual, Uint32 *reference, Uint32 size);
interrupt void edmaIsr(void);
void submitEdma(VCP_UserData *userData, VCP_Params *vcpParameters,
                Uint32 **decisions, Uint32 **outParms, Uint32 *numDec);

/* Global variable declarations */
Int32 vcpDone;                   /* VCP processing completion flag          */ 
int tcc = -1;                    /* Transfer completion code used by EDMA   */
EDMA_Handle hEdmaRevt,           /* EDMA channel used for Hard Decisions    */
            hEdmaXevt,           /* EDMA channel used for IC Values         */
            hEdmaBrMet,          /* EDMA channel used for Branch Metrics    */
                                 /*      data                               */
            hEdmaOutPar,         /* EDMA channel used for Output Parameters */
            hEdmaNull;           /* EDMA NULL channel used for termination  */


/****************************************************************************\
 * main function                                                            *
\****************************************************************************/
void
main(void)
{
volatile Uint32 error = 0;
Uint32 *decisions, *outParms, numDec;
int i;

    /* Initialize Chip Support Library */
    CSL_init();
    
    /* Cycle through user channels */
    for(i = 0; i < NUM_USERS; i++){
      /* Clear VCP completion flag */
      vcpDone = 0;    

      /* Program EDMA to service User Channel */
      submitEdma(userData[i], &vcpParameters[i], &decisions, &outParms, &numDec);

      /* Start the VCP to begin the EDMA transfers */
      VCP_start();

      /* Wait on viterbi decode to complete. The task pends on a semaphore  */
      /* that is set in the EDMA interrupt service routine.                 */
      while(!vcpDone);
          
      /* Verify the coprocessing results by comparing received decisions and*/
      /* output parameters to programmed reference data. A value of "0"     */
      /* indicates that no error was present. A non-zero value indicates an */
      /* error occurred.                                                    */
      error = checkResults(decisions, referenceDec[i],
                           vcpParameters[i].frameLen);
      if (error) break;

      /* Free memory spaces back to the system */
      free(decisions);
    } /* end for i */
    
    while(1);
    
} /* end main */ 


/****************************************************************************\
 * intConfig: Configure the CPU interrupt controller to receive interrupts  *
 * from the EDMA.                                                           *
\****************************************************************************/
void
intConfig(void)
{
    IRQ_resetAll();                       /* Reset all maskable interrupts  */
    IRQ_enable(IRQ_EVT_EDMAINT);          /* Enable EDMA -> CPU interrupt   */
    IRQ_nmiEnable();                      /* Enable non-maskable interrupt  */
    IRQ_globalEnable();                   /* Globally enable all interrupts */
} /* end intConfig() */


/****************************************************************************\
 * checkResults: Verify that the hard decisions and output parameters sent  *
 * by the VCP are correct. If the hard decisions are not correct, the index *
 * of the first incorrect value is returned. If the output parameters (the  *
 * number of iterations) is not correct, then a -1 is returned. If all      *
 * values are correct then a 0 is returned.                                 *
\****************************************************************************/
Int32
checkResults(Uint32 *actual ,Uint32 *reference, Uint32 size) 
{
Uint32 i;
Uint32 mismatch=0;
Uint32 numWords = size>>5;
    
    /* Directly compare received values to reference values for 32 valid    */
    /* bits.                                                                */
    for (i=0; i<numWords; i++) {
      if (actual[i]!=reference[i]) {
        mismatch++;
        break;
      } /* end if actual != reference */
    } /* end for i */
    
    /* Compare last halfword. */
    if ((!mismatch) && (size & 1)) {    
      if ((short)actual[i] != (short)reference[i]) mismatch++;
    } /* end if */

    if (mismatch) return(i+1); /* return index for 1st error that occured. */
                               /* Index will range from 1 to framelength   */
    else return(0);            /* no error */
    
} /* end checkResults() */


/****************************************************************************\
 * edmaIsr: EDMA interrupt service routine. The vcpDone flag is set to one  *
 * and all EDMA handles are closed, freeing them for use on the next        *
 * iteration.                                                               *
\****************************************************************************/
interrupt void
edmaIsr(void)  
{ 
    vcpDone = EDMA_intTest(tcc); /* Signal that processing is completed     */
    EDMA_intClear(tcc);          /* Clear the interrupt in the CIPR         */
    EDMA_intFree(tcc);           /* Free the TCC value to the system        */
    EDMA_close(hEdmaRevt);       /* Close the hard decisions EDMA channel   */
    EDMA_close(hEdmaXevt);       /* Close the IC values EDMA channel        */
    EDMA_freeTable(hEdmaBrMet);  /* Close the branch metrics EDMA channel   */
    EDMA_freeTable(hEdmaOutPar); /* Close the output parameters EDMA channel*/
    EDMA_freeTable(hEdmaNull);   /* Close the NULL EDMA channel             */

} /* end edmaIsr */


/****************************************************************************\
 * submitEdma: The EDMA is programmed to service the user channel. The IC   *
 * values are configured and all EDMA parameters are calculated here.       *
\****************************************************************************/
void
submitEdma(VCP_UserData *userData, VCP_Params *vcpParameters,
           Uint32 **decisions, Uint32 **outParms, Uint32 *numDec)
{
EDMA_Config edmaConfig;
VCP_ConfigIc configIc = {0,0,0,0,0,0};

⌨️ 快捷键说明

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