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

📄 csl_tcp2.c

📁 Dm6455 driver,magbe useful to you!
💻 C
📖 第 1 页 / 共 5 页
字号:
/*  ============================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005
 *
 *   Use of this software is controlled by the terms and conditions found in the
 *   license agreement under which this software has been supplied.
 *   ===========================================================================
 */

/** ============================================================================
 *   @file  csl_tcp2.c
 *
 *   @path  $(CSLPATH)\src\tcp2
 *
 *   @desc  File for functional layer of CSL API of TCP2
 *
 */
 
/* =============================================================================
 *  Revision History
 *  ===============
 *  15-Mar-2005  sd File Created.
 *  03-Aug-2005  sd Modifications for the requirements change.
 *  15-Sep-2005  sd Changed TCP to TCP2 in all the names
 *  07-Oct-2005  sd Changes during testing
 * =============================================================================
 */

#include <csl_tcp2.h>
#include <csl_tcp2Aux.h>

/* defines */

/* TCP number of extrinsic factors */
#define NUM_EXTRINSIC_FACTORS 	16

/* TCP data width */
#define DATA_WIDTH           	 6

/* forward declarations */
static void TCP2_calcSubBlocks (TCP2_Params *configParms);

/** ============================================================================
 *   @n@b TCP2_setParams 
 *
 *   @b Description
 *   @n This function sets up the TCP2 input configuration parameters in the
 *		TCP2_ConfigIc structure. The configuration values are passed in the 
 *		configParms input argument.
 *
 *   @b Arguments
     @verbatim
            configParms     Pointer to the structure holding the TCP 
                            configuration parameters.
                            
            configIc        Pointer to the TCP2_ConfigIc structure to be filled.

     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None 
 *
 *   @b Modifies
 *   @n The configIc argument passed.   
 *
 *   @b Example
 *   @verbatim 
		extern TCP2_Params *configParms;
		TCP2_ConfigIc *configIc;
		...
		TCP2_setParams(configParms, configIc);
     @endverbatim
 * ===========================================================================
 */
void TCP2_setParams (
 	TCP2_Params 		*restrict configParms,
    TCP2_ConfigIc 	*restrict configIc
) 
{
	/* IC0 parameters */
	TCP2_Mode mode          = configParms->mode;
	TCP2_NumSW  numSw       = configParms->numSlideWin;
	TCP2_Rate rate          = configParms->rate; 
	Uint32 intFlag         = configParms->intFlag;
	Uint32 outParmFlag     = configParms->outParmFlag;
	Uint32 frameLen        = configParms->frameLen;
	
	/* IC1 parameters */
	Uint32 relLen          = configParms->relLen;

	/* IC2 parameters */
	Uint32 prologSize      = configParms->prologSize;
	Uint32 numSubBlock     = configParms->numSubBlock;
	Uint32 maxIter         = configParms->maxIter;
	Uint32 snr             = configParms->snr;

	/* IC3 parameters */
	Bool maxStarEn		    = configParms->maxStarEn;
	Bool prologRedEn		= configParms->prologRedEn;
	Uint8 minIter			= configParms->minIter;
	TCP2_InputSign inputSign = configParms->inputSign;
	TCP2_OutputOrder  outputOrder = configParms->outputOrder;

	/* IC4 parameters */
	Uint8 numCrcPass 		= configParms->numCrcPass;
	Uint8 crcLen			= configParms->crcLen;

	/* IC5 parameters */
	Uint32 crcPoly			= configParms->crcPoly;	
	

	Uint32 ic0=0, ic1=0, ic2=0, ic3=0, ic4=0, ic5=0, 
					ic12=0, ic13=0, ic14=0, ic15=0;

	Uint32 gie;

	gie =  _disable_interrupts ();

	/* set the values for the TCPIC0 register */
	CSL_FINS (ic0, TCP2_TCPIC0_FL, 		frameLen);
	CSL_FINS (ic0, TCP2_TCPIC0_NUMSW, 	numSw);
	CSL_FINS (ic0, TCP2_TCPIC0_OUTF, 	outParmFlag);
	CSL_FINS (ic0, TCP2_TCPIC0_INTER, 	intFlag);
	CSL_FINS (ic0, TCP2_TCPIC0_RATE, 	rate);
	CSL_FINS (ic0, TCP2_TCPIC0_OPMOD,	mode);

	/* set the values for the TCPIC1 register */
	CSL_FINS (ic1, TCP2_TCPIC1_R, 		relLen);

	/* set the values for the TCPIC2 register */
	CSL_FINS (ic2, TCP2_TCPIC2_SNR, 	snr);  	
	CSL_FINS (ic2, TCP2_TCPIC2_MAXIT, 	maxIter);  	
	CSL_FINS (ic2, TCP2_TCPIC2_NSB, 	numSubBlock);  	
	CSL_FINS (ic2, TCP2_TCPIC2_P, 		prologSize);

	/* set the values for the TCPIC3 register */
	CSL_FINS (ic3, TCP2_TCPIC3_OUTORDER, 	outputOrder);  	
	CSL_FINS (ic3, TCP2_TCPIC3_INPUTSIGN, 	inputSign);  	
	CSL_FINS (ic3, TCP2_TCPIC3_MINITER,	 	minIter);  	
	CSL_FINS (ic3, TCP2_TCPIC3_EPRORED, 	prologRedEn);  	
	CSL_FINS (ic3, TCP2_TCPIC3_EMAXSTR, 	maxStarEn);  	

	/* set the values for the TCPIC4 register */
	CSL_FINS (ic4, TCP2_TCPIC4_CRCITERPASS, numCrcPass);  	
	CSL_FINS (ic4, TCP2_TCPIC4_CRCLEN, 		crcLen);  	

	/* set the values for the TCPIC5 register */
	CSL_FINS (ic5, TCP2_TCPIC5_CRCPOLY,		crcPoly);

	/* set the values for TCPIC12 to TCPIC15 */
	
	/* Form the value for the register TCPIC12 */
	ic12 = TCP2_setExtScaling (configParms->extrScaling [0], 
						configParms->extrScaling [1],
						configParms->extrScaling [2],
						configParms->extrScaling [3]);

	/* Form the value for the register TCPIC13 */
	ic13  = TCP2_setExtScaling (configParms->extrScaling [4], 
						configParms->extrScaling [5],
						configParms->extrScaling [6],
						configParms->extrScaling [7]);

	/* Form the value for the register TCPIC14 */
	ic14 = TCP2_setExtScaling (configParms->extrScaling [8], 
						configParms->extrScaling [9],
						configParms->extrScaling [10],
						configParms->extrScaling [11]);

	/* Form the value for the register TCPIC15 */
	ic15 = TCP2_setExtScaling (configParms->extrScaling [12], 
						configParms->extrScaling [13],
						configParms->extrScaling [14],
						configParms->extrScaling [15]);

	/* Assign the configIc values */
	configIc->ic0 = ic0;
	configIc->ic1 = ic1;
	configIc->ic2 = ic2;
	configIc->ic3 = ic3;
	configIc->ic4 = ic4;
	configIc->ic5 = ic5;

	configIc->ic12 = ic12;
	configIc->ic13 = ic13;
	configIc->ic14 = ic14;
	configIc->ic15 = ic15;

	_restore_interrupts (gie); 

    return;
} /* end TCP2_setParams */

/** ============================================================================
 *   @n@b TCP2_tailConfig 
 *
 *   @b Description
 *   @n This function generates the input control values IC6-IC11 based on the 
 *		processing to be performed by the TCP. These values consist of the tail 
 *  	data following the systematics and parities data. This function 
 *		calls specific tail generation functions depending on the
 *		standard followed.
 *
 *   @b Arguments
     @verbatim
            standard        3G standard to be decoded.

            mode            TCP processing mode (SA or SP)

            map             TCP shared processing MAP 

            rate            Code rate of the TCP

            tailData        Pointer to the tail data

            configIc        Pointer to the TCP_ConfigIc structure to be filled.

     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None 
 *
 *   @b Modifies
 *   @n The configIc argument passed.   
 *
 *   @b Example
 *   @verbatim
		extern TCP2_Params *configParms;
		TCP2_ConfigIc *configIc;
		TCP2_UserData *xabData = &userData[frameLen];		
		
		...
		TCP2_tailConfig (configParms->standard, configParms->mode, 
                configParms->map, configParms->rate,
					userData, configIc);
     @endverbatim
 * ===========================================================================
 */
void TCP2_tailConfig (
	TCP2_Standard 	standard,
    TCP2_Mode		mode,
    TCP2_Map 		map,
    TCP2_Rate 		rate,
    TCP2_TailData 	*restrict tailData,
    TCP2_ConfigIc 	*restrict configIc
) 
{
    /* Call the specific tail generation function */
	if (standard == TCP2_STANDARD_3GPP) 
		TCP2_tailConfig3GPP ( mode, map, rate, tailData, configIc);
	else 
		TCP2_tailConfigIs2000 (mode, map, rate, tailData, configIc);
 
    return;
} /* end TCP2_tailConfig() */


/** ============================================================================
 *   @n@b TCP2_genIc 
 *
 *   @b Description
 *   @n This function sets up the TCP2 input configuration parameters in the
 *		TCP2_ConfigIc structure. The configuration values are passed in the 
 *		configParms input argument.
 *
 *   @b Arguments
     @verbatim
            configParms     Pointer to the structure holding the TCP 
                            configuration parameters.
	
            tailData        Tail data

            configIc        Pointer to the TCP2_ConfigIc structure to be filled.

     @endverbatim
 *
 *   <b> Return Value </b>  
 *   @n  None
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  None 
 *
 *   @b Modifies
 *   @n The configIc argument passed.   
 *
 *   @b Example
 *   @verbatim
        extern TCP2_UserData *userData;
        
	    TCP2_BaseParams	configBase;
	    TCP2_Params      configParams;
        TCP2_TailData    *xabData;
    	Uint32          frameLen = 40;

        xabData = &userData [frameLen];
        
        // assign the configuration parameters 
	    configBase.frameLen		= frameLen;
	    configBase.inputSign	= TCP2_INPUT_SIGN_POSITIVE;
	    configBase.intFlag		= 1;
	    configBase.maxIter		= 8;
	    configBase.maxStarEn	= TRUE;
	    configBase.standard		= TCP2_STANDARD_3GPP;
	    configBase.crcLen		= 0;
	    configBase.crcPoly		= 0;
	    configBase.minIter		= 1;
	    configBase.numCrcPass	= 1;
	    configBase.outParmFlag	= 0;
	    configBase.outputOrder	= TCP2_OUT_ORDER_0_31;
	    configBase.prologRedEn	= FALSE;
	    configBase.prologSize	= 24;
	    configBase.rate         = TCP2_RATE_1_3;
	    configBase.snr          = 0;

	    for (cnt = 0; cnt < 16; cnt++)
		    configBase.extrScaling [cnt] = 32;

	    // setup the TCP configuration registers parameters 
	    TCP2_genParams (&configBase, &configParams);

	    // generate the configuration register values 
	    TCP2_genIc (&configParams, xabData, &configIc); 

     @endverbatim
 * ===========================================================================
 */
void TCP2_genIc (
    TCP2_Params      *restrict configParms,
    TCP2_TailData    *restrict tailData,
    TCP2_ConfigIc    *restrict configIc
) 
{

	TCP2_Standard standard = configParms->standard;
	TCP2_Rate rate         = configParms->rate;
	TCP2_Mode mode		  = configParms->mode;
	TCP2_Map map		      = configParms->map;

	/* configuration parameters configuration */
	TCP2_setParams (configParms, configIc);

	/* TCP tail parameter configuration */
	TCP2_tailConfig(standard, mode, map, rate, tailData, configIc);

    return;
} /* end TCP2_genIc */


/** ============================================================================
 *   @n@b TCP2_genParams  
 *
 *   @b Description
 *   @n This function copies the basic parameters, to the configParams 
 *		parameters structure.
 *
 *   @b Arguments
     @verbatim
            configBase      Pointer to the TCP2_BaseParams structure 
            
            configParams    Pointer to the TCP configuration parameters 
                            structure.

     @endverbatim
 *
 *   <b> Return Value </b>  Uint32
 *   @n                     The number of sub frames for shared processing mode                       
 *
 *   <b> Pre Condition </b>
 *   @n  configBase is populated with all the configurtaion parameters
 *
 *   <b> Post Condition </b>
 *   @n  None 
 *
 *   @b Modifies
 *   @n The configParams argument passed.   
 *
 *   @b Example

⌨️ 快捷键说明

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