📄 main.c
字号:
/*
* 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 *
****************************************************************************
* TCPSharedProcessing.pjt *
* *
* *
* The purpose of this project is to demonstrate how to use the Turbo Co- *
* Processor (TCP) using the Chip Support Library (CSL). *
* *
* User data, residing in the tcpUserx.asm files included with this project *
* is processed through the TCP in Shared Processing Mode. The TCP is *
* configured based on the channel parameters set in tcp_parameters.h. This *
* software handles the TCP, EDMA, and interrupt configuration necessary to *
* process each user channel. *
\****************************************************************************/
#include <csl.h>
#include <csl_tcp.h>
#include <csl_edma.h>
#include "tcp_parameters.h"
/* Prototype declarations */
void intConfig(void);
Int32 checkResults(Uint32 *actual ,Uint32 *reference, Uint32 size,
Uint32 nbValidBitsInLastWord);
interrupt void edmaIsr(void);
void submitEdma(TCP_UserData *userData, TCP_UserData *xabData,
TCP_Params *tcpParameters, Uint16 *interleaverTable,
TCP_ExtrinsicData *extrinsics, TCP_ExtrinsicData *apriori,
Uint32 numSubFrame);
void processUserChannel(TCP_UserData *userData, TCP_Params *configParms,
Uint16 *interleaverTable, Uint32 **hardDecisions, Uint32 *numHd,
Uint32 *validHdLast);
/* Global variable declarations */
Int32 tcpDone; /* TCP processing completion flag */
int tcc = -1; /* Transfer completion code used by EDMA */
int tccApriori = -1; /* Transfer completion code used for chain */
EDMA_Handle hEdmaRevt, /* EDMA channel used for extrinsics data */
hEdmaXevt, /* EDMA channel used for IC Values */
hEdmaSysPar, /* EDMA channel used for Systematics and */
/* Parities data */
hEdmaApriori, /* EDMA channel used for apriori data */
hEdmaNull; /* EDMA NULL channel used for termination */
/****************************************************************************\
* main function *
\****************************************************************************/
void
main(void)
{
volatile Uint32 error = 0;
Uint32 *hardDecisions, numHd, validHdLast;
Uint32 i;
/* Initialize Chip Support Library */
CSL_init();
/* Cycle through user channels */
for(i = 0; i < NUM_USERS; i++){
/* Process the user channel data */
processUserChannel(userData[i], &tcpParameters[i], interleaverTable[i],
&hardDecisions, &numHd, &validHdLast);
/* 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(hardDecisions, referenceHd[i], numHd, validHdLast);
if (error) break;
} /* end for i */
while(1);
} /* end main */
/****************************************************************************\
* processUserChannel: Perform the submission of the shared processing *
* channel data to the TCP as well as the necessary shared CPU functions. *
\****************************************************************************/
void
processUserChannel(TCP_UserData *userData, TCP_Params *configParms,
Uint16 *interleaverTable, Uint32 **hardDecisions, Uint32 *numHd,
Uint32 *validHdLast)
{
TCP_UserData *workingData1, *workingData2;
TCP_UserData *xabData;
Uint16 index;
TCP_ExtrinsicData *extrinsics1, *extrinsics2;
TCP_ExtrinsicData *apriori;
int i;
Uint32 numExt;
Uint32 numApriori;
Uint32 numSubFrame;
Uint16 frameLen = configParms->frameLen;
Uint16 rate = configParms->rate;
Uint32 workingDataSize;
/* Break up user channel data into sub-frames */
numSubFrame = TCP_calcSubBlocksSP(configParms);
/* Calculate all count parameters required for EDMA programming */
TCP_calcCountsSP(configParms);
/* Allocate all required memory for data */
workingDataSize = TCP_ceil(rate * frameLen, 3) << 3;
workingData1 = (TCP_UserData *)memalign(2 * sizeof(Uint32),
workingDataSize);
workingData2 = (TCP_UserData *)memalign(2 * sizeof(Uint32),
workingDataSize);
numExt = configParms->numExt * sizeof(Uint32);
extrinsics1 = (TCP_ExtrinsicData *)memalign(2 * sizeof(Uint32),
numSubFrame * numExt);
extrinsics2 = (TCP_ExtrinsicData *)memalign(2 * sizeof(Uint32),
numSubFrame * numExt);
numApriori = configParms->numApriori * sizeof(Uint32);
apriori = (TCP_ExtrinsicData *)memalign(2 * sizeof(Uint32),
numSubFrame * numApriori);
/* demultiplex channel data for SP mode */
TCP_demuxInput(rate, frameLen, userData, interleaverTable,
workingData1, workingData2);
index = frameLen * rate;
xabData = &userData[index];
for (i=0; i<configParms->maxIter; i++){
/* Submit MAP1 */
/* Clear TCP completion flag */
tcpDone = 0;
/* Program EDMA to service User Channel for MAP 1 */
submitEdma(workingData1, xabData, configParms, interleaverTable,
extrinsics1, apriori, numSubFrame);
/* Begin transmitting to the TCP */
TCP_start();
/* Wait on turbo decode to complete. The task pends on a semaphore */
/* that is set in the EDMA interrupt service routine. */
while(!tcpDone);
/* Interleave extrinsics to generate apriori data used for next MAP */
/* decode. */
TCP_interleaveExt(apriori, extrinsics1, interleaverTable,
frameLen);
configParms->map = TCP_MAP_MAP2;
/* Submit MAP2 */
/* Clear TCP completion flag */
tcpDone = 0;
/* Program EDMA to service User Channel for MAP 1 */
submitEdma(workingData2, xabData, configParms, interleaverTable,
extrinsics2, apriori, numSubFrame);
/* Begin transmitting to the TCP */
TCP_start();
/* Wait on turbo decode to complete. The task pends on a semaphore */
/* that is set in the EDMA interrupt service routine. */
while(!tcpDone);
/* De-interleave extrinsics to generate apriori data used for next */
/* MAP decode. */
TCP_deinterleaveExt(apriori, extrinsics2, interleaverTable,
frameLen);
/* Select MAP 1 decode (non-1st iteration) */
configParms->map = TCP_MAP_MAP1B;
} /* end for i */
/* Allocate memory for hard decisions data */
*numHd = tcpParameters->numHd;
*validHdLast = *numHd % 4;
*hardDecisions = (Uint32 *)memalign(2 * sizeof(Uint32),
*numHd * sizeof(Uint32));
/* Calculate Hard Decisions */
TCP_calculateHd(extrinsics1, apriori, userData, *hardDecisions, frameLen,
rate);
/* Free memory spaces back to the system */
free(workingData1);
free(workingData2);
free(extrinsics1);
free(extrinsics2);
free(apriori);
free(hardDecisions);
} /* end processUserChannel() */
/****************************************************************************\
* 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() */
/****************************************************************************\
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -