?? main.c
字號:
/****************************************************************************\
* Copyright (C) 2001 Texas Instruments Incorporated. *
* All Rights Reserved *
****************************************************************************
* VcpProcessing_BIOS.pjt *
* *
* The purpose of this project is to demonstrate how to use the Viterbi Co- *
* Processor (VCP) using the Chip Support Library (CSL) and BIOS modules. *
* *
* 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 VCP, EDMA, *
* and interrupt configuration necessary to process each user channel. *
* LOG module generates messages via a specific window : *
* DSP/BIOS -> Message Log *
* Run Project in Real Time Mode - Debug ->Real-Time Mode *
* Set Breakpoint at line 144 SEM_post(&semVcpFree); * *
* *
\****************************************************************************/
#include <csl.h>
#include <csl_irq.h>
#include <csl_vcp.h>
#include <csl_edma.h>
/* Include files for DSP/BIOS */
#include <std.h>
#include <log.h>
#include <swi.h>
#include <sem.h>
#include <clk.h>
#include <sts.h>
#include <rtdx.h>
#include <tsk.h>
#include <mem.h>
#include <hwi.h>
#include <VcpProcessingcfg.h>
/* Other includes */
#include "vcp_parameters.h"
/* Prototype declarations */
void intConfig(void);
Int32 checkResults(Uint32 *actual, Uint32 *reference, Uint32 size);
void hwiEdma(void);
void submitEdma(VCP_UserData *userData, VCP_Params *vcpParameters,
Uint32 **decisions, Uint32 **outParms,
VCP_ConfigIc **configIc, Uint32 *numDec);
/* Global variable declarations */
extern Uint32 ISRAM; /* Memory space used for buffer allocation */
/* Global variable declarations */
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)
{
/* Announce beginning of program */
LOG_printf(&trace, "DSP/BIOS program started");
/* Initialize the EDMA interrupt */
intConfig();
/* "Free" the VCP to the system */
SEM_post(&semVcpFree);
/* Following main() the system will drop into the task manager */
return;
} /* end main() */
/****************************************************************************\
* tskUserChannel: The user channel task. This is the task software used by *
* each of the user channels to obtain the VCP, establish memory buffers, *
* program the EDMA, and process the user channel data. *
\****************************************************************************/
void
tskUserChannel(Uint32 channelNum)
{
volatile Uint32 error = 0;
Uint32 *decisions, *outParms, numDec;
VCP_ConfigIc *configIc;
Uint32 iteration = 0;
while(1){ /* Repeat processing of the user channel forever */
/* Announce beginning of channel processing */
LOG_printf(&trace, "Starting Channel %d. Iteration %d",
channelNum, iteration++);
/* Wait for VCP coprocessor to be available */
LOG_printf(&trace, "Channel %d waiting for VCP", channelNum);
SEM_pend(&semVcpFree, SYS_FOREVER); /* Pend on available hardware */
SEM_reset(&semVcpFree, 0); /* Lock out other tasks */
/* Program EDMA to service User Channel */
submitEdma(userData[channelNum], &vcpParameters[channelNum], &decisions,
&outParms, &configIc, &numDec);
/* Announce that the VCP is being used to process the channel data */
LOG_printf(&trace, "Channel %d using the VCP", channelNum);
/* 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. */
LOG_printf(&trace, "Channel %d awaiting VCP completion", channelNum);
SEM_pend(&semVcpDone, SYS_FOREVER); /* Pend on completion semaphore */
SEM_reset(&semVcpDone, 0); /* Clear the semaphore */
LOG_printf(&trace, "Channel %d decode complete", channelNum);
/* 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[channelNum],
vcpParameters[channelNum].frameLen);
/* Report the error status */
LOG_printf(&trace, "User channel %d completed with %d error(s)",
channelNum, error);
/* Free memory spaces back to the system */
MEM_free(ISRAM, decisions, numDec * sizeof(Uint32));
MEM_free(ISRAM, outParms , VCP_NUM_OP * sizeof(Uint32));
MEM_free(ISRAM, configIc , VCP_NUM_IC * sizeof(Uint32));
/* Reset VCP available semaphore to allow another channel to use it */
SEM_post(&semVcpFree);
} /* end while(1) */
} /* end main */
/****************************************************************************\
* intConfig: Configure the CPU interrupt controller to receive interrupts *
* from the EDMA. *
\****************************************************************************/
void
intConfig(void)
{
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 *
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -