📄 csl_edmaparam.c
字号:
/* ============================================================================
* 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_edmaParam.c
*
* @brief File for functional layer of CSL API @a CSL_edmaParamSetup()
*
* Path: \\(CSLPATH)\\ipmodules\\edma\\src
*
* @date
* @author Ruchika Kharwar
*/
/* =============================================================================
* Revision History
* ===============
* 10-Aug-2005 brn Updated for doxygen documentation and butification
* =============================================================================
*/
#include <csl_edma.h>
/** ============================================================================
* @n@b CSL_edmaGetParamHandle
*
* @b Description
* @n Acquires the Param entry as specified by the argument
* @b Arguments
*
* @verbatim
hEdma Channel handle
entryNum Entry number desired
status Pointer to the placeholder for the status
@endverbatim
*
* <b> Return Value </b> CSL_Status
* @li CSL_SOK - Hardware setup successful
* @li CSL_ESYS_BADHANDLE - Invalid handle
* @li CSL_ESYS_INVPARAMS - Hardware structure is not
* properly initialized
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n Returns the handle to the requested parameter entry
*
* @b Modifies
* @n NONE
*
* <b> Usage Constraints: </b>
* CSL_edmaInit(), CSL_edmaOpen(), CSL_edmaChannelOpen() must be called
* successfully in that order before this function can be called.
* If the channel for which the paramentry is obtained is in the context of
* a region then CSL_edmaRegionOpen() must also be invoked.
* This API returns a handle to the requested parameter entry.
*
* @b Example:
* @verbatim
CSL_EdmaObj ModuleObj;
CSL_EdmaHandle hModHndl;
CSL_EdmaChanObj ChObj;
CSL_EdmaChanHandle chHndl;
CSL_EdmaChannelParam chParam;
CSL_Status edmaStatus;
CSL_EdmaParamHandle param;
// Initialization
CSL_edmaInit();
// Module Level Open
hModHndl = CSL_edmaOpen(NULL,CSL_EDMA_0,NULL,&modStatus);
...
// Channel 0 is opened which is allocated to Region Region 0
chParam.regionNum = CSL_EDMA_REGION_GLOBAL;
chParam.chaNum = CSL_EDMA_CHA0;
chHndl = CSL_edmaChannelOpen(&ChObj,
CSL_EDMA_0,
&chParam,
&edmaStatus);
// Acquire Param Entries in the Shadow Region itself, hence region is NULL
param = CSL_edmaGetParamHandle(chHndl,1,&status);
// Setup the acquired parameter entry
...
@endverbatim
* =============================================================================
*/
#pragma CODE_SECTION (CSL_edmaGetParamHandle, ".text:csl_section:edma");
CSL_EdmaParamHandle CSL_edmaGetParamHandle(
/** a handle to the channel instance of the specified EDMA
* obtained through the @a CSL_edmaOpen() call */
CSL_EdmaChanHandle hEdma,
/** entry number to be acquired */
Uint16 entryNum,
/** status of operation */
CSL_Status *status
)
{
if (status!=NULL)
*status = CSL_SOK;
return (&hEdma->ccregs->PARAMENTRY[entryNum]);
}
/** ============================================================================
* @n@b CSL_edmaParamSetup
*
* @b Description
* @n Configures the EDMA parameter Entry using the values passed in through the
* Param setup structure
*
* @b Arguments
*
* @verbatim
hParam Handle to the Parameter Handle
void* Pointer to the CSL_EdmaParamSetup (in case of BASIC
parameter ram setup)OR CSL_EdmaParamHandle(in case of
LINK parameter ram setup) OR CSL_EdmaChanHandle (in
case of CHAIN parameter ram setup) depending on the
3rd argument.
stage Stage of the Setup i.e BASIC/LINK/CHAIN
@endverbatim
*
* <b> Return Value </b> CSL_Status
* @li CSL_SOK - Hardware setup successful
* @li CSL_ESYS_BADHANDLE - Invalid handle
* @li CSL_ESYS_INVPARAMS - Hardware structure is not
* properly initialized
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n The specified instance will be setup according to value passed
*
* @b Modifies
* @n Hardware registers for the specified instance
*
* <b> Usage Constraints: </b>
* CSL_edmaInit(),@a CSL_edmaOpen,@a CSL_edmaChannelOpen(),
* @a CSL_edmaGetParamHandle() must be called successfully in that order
* before this function can be called. If the channel for which the paramentry
* is obtained is in the context of a region then CSL_edmaRegionOpen() must
* also be invoked. The user must allocate space for & fill in the parameter
* setup structure
*
* @b Example:
* @verbatim
CSL_EdmaObj ModuleObj;
CSL_EdmaHandle hModHndl;
CSL_EdmaChanObj ChObj;
CSL_EdmaChanHandle chHndl;
CSL_EdmaChannelParam chParam;
CSL_Status edmaStatus;
CSL_EdmaParamHandle param;
CSL_EdmaParamSetup myParamSetup;
// Initialization
CSL_edmaInit();
// Module Level Open
hModHndl = CSL_edmaOpen(NULL,CSL_EDMA_0,NULL,&modStatus);
...
// Channel 0 is opened which is allocated to Region Region 0
chParam.regionNum = CSL_EDMA_REGION_GLOBAL;
chParam.chaNum = CSL_EDMA_CHA0;
chHndl = CSL_edmaChannelOpen(&ChObj,
CSL_EDMA_0,
&chParam,
&edmaStatus);
// Acquire Param Entries in the Shadow Region itself, hence region is NULL
param = CSL_edmaGetParamHandle(chHndl,1,&status);
// Setup the acquired parameter entry
// Setup the parameter Entry parameters (Ping buffer)
myParamSetup.option = CSL_EDMA_OPT_MAKE(FALSE,FALSE,FALSE,TRUE,tcc,
CSL_EDMA_TCC_EARLY,CSL_EDMA_FIFOWIDTH_128BIT,TRUE,CSL_EDMA_SYNC_ARRAY,
CSL_EDMA_ADDRMODE_INCR,CSL_EDMA_ADDRMODE_INCR);
myParamSetup.srcAddr = (Uint32)srcBuff1;
myParamSetup.elmArrCnt = CSL_EDMA_CNT_MAKE(256,1);
myParamSetup.dstAddr = (Uint32)dstBuff1;
myParamSetup.srcDstBidx = CSL_EDMA_BIDX_MAKE(1,1);
myParamSetup.BcntRld = CSL_EDMA_LINKBCNTRLD_MAKE(CSL_EDMA_LINK_NULL,0);
myParamSetup.srcDstCidx = CSL_EDMA_CIDX_MAKE(0,1);
myParamSetup.cCnt = 1;
myParamSetup.triggerWord = CSL_EDMA_TRIGWORD_NONE;
// Setup the acquired parameter Entry
CSL_edmaParamSetup(param,&myParamSetup,CSL_EDMA_PARAM_BASIC);
}
@endverbatim
*
* ============================================================================
*/
#pragma CODE_SECTION (CSL_edmaParamSetup, ".text:csl_section:edma");
CSL_Status CSL_edmaParamSetup(
/** a handle to the param entry acquired previously by the channel */
CSL_EdmaParamHandle hParamHndl,
/** Pointer to setup structure which contains the
* information to program EDMA Channel to the startup state
* OR the parameter entry to which linking needs to be done
* OR the Channel to which chaining needs to be performed */
void *setup,
/** Specifies the stage of Setup i.e Could be initial, link Setup or Chain
Setup.These do not fall into the category of the Control Commands
since this does not fall into the category of the run time change of
parameter setups. The user is expected to follow tis flow of parameter
entry setup hence 3 diferent stages are required */
CSL_EdmaParamSetupStage stage
)
{
Uint32* paramHndl = (Uint32*)hParamHndl;
int i;
if (hParamHndl == NULL)
return CSL_ESYS_BADHANDLE;
if (setup == NULL)
return CSL_ESYS_INVPARAMS;
if (stage == CSL_EDMA_PARAM_BASIC) {
for ( i = ((CSL_EdmaParamSetup*)setup)->triggerWord-1; i >=0; i--)
paramHndl[i] = ((Uint32*)setup)[i];
for ( i = 7; i > ((CSL_EdmaParamSetup*)setup)->triggerWord; i--)
paramHndl[i] = ((Uint32*)setup)[i];
paramHndl[((CSL_EdmaParamSetup*)setup)->triggerWord] =
((Uint32*)setup)[((CSL_EdmaParamSetup*)setup)->triggerWord];
} else if (stage == CSL_EDMA_PARAM_LINK) {
CSL_FINS(hParamHndl->LINK_BCNTRLD,
EDMACC_LINK_BCNTRLD_LINK,
(Uint32)setup);
} else {
CSL_FINS(hParamHndl->OPT,
EDMACC_OPT_TCC,
((CSL_EdmaChanHandle)(setup))->chaNum);
}
return CSL_SOK;
}
/** ============================================================================
* @n@b CSL_edmaParamWriteWord
*
* @b Description
* @n This is for the ease of EDMA channels. Once the QDMA channel transfer is
* triggered, subsequent triggers may be done with only writing the modified
* words in the parameter entry along with the trigger word. This API is
* expected to achieve this this purpose. Most usage scenarios, the user
* should not be writing more than the trigger word entry
*
* @verbatim
hParamHndl Handle to the Parameter Entry
wordOffset Word Offset at which the specified word is to be
written 3rd argument
word Word itself that needs to be written
@endverbatim
*
* <b> Return Value </b> CSL_Status
* @li CSL_SOK - Hardware setup successful
* @li CSL_ESYS_BADHANDLE - Invalid handle
* @li CSL_ESYS_INVPARAMS - Hardware structure is not
* properly initialized
*
* <b> Pre Condition </b>
* @n None
*
* <b> Post Condition </b>
* @n The specified instance will be setup according to value passed
*
* @b Modifies
* @n Hardware registers for the specified instance
*
*
* <b> Usage Constraints: </b>
* CSL_edmaInit(),@a CSL_edmaOpen,@a CSL_edmaChannelOpen(),
* @a CSL_edmaGetParamHandle(), CSL_edmaParamSetup(), must be called
* successfully in that order before this function can be called.
* The main setup structure consists of pointers to sub-structures. The user
* has to allocate space for & fill in the parameter setup structure.
* If the channel for which the paramentry is obtained is in the context of
* a region then CSL_edmaRegionOpen() must also be invoked before this API.
*
* @b Example:
* @verbatim
CSL_EdmaObj ModuleObj;
CSL_EdmaHandle hModHndl;
CSL_EdmaChanObj ChObj;
CSL_EdmaChanHandle chHndl;
CSL_EdmaChannelParam chParam;
CSL_Status edmaStatus;
CSL_EdmaParamHandle param;
CSL_EdmaParamSetup myParamSetup;
// Initialization
CSL_edmaInit();
// Module Level Open
hModHndl = CSL_edmaOpen(NULL,CSL_EDMA_0,NULL,&modStatus);
...
// Channel 0 is opened which is allocated to Region Region 0
chParam.regionNum = CSL_EDMA_REGION_GLOBAL;
chParam.chaNum = CSL_EDMA_QCHA0;
chHndl = CSL_edmaChannelOpen(&ChObj,
CSL_EDMA_0,
&chParam,
&edmaStatus);
// Acquire Param Entries in the Shadow Region itself, hence region is NULL
param = CSL_edmaGetParamHandle(chHndl,1,&status);
// Setup the acquired parameter entry
// Setup the parameter Entry parameters (Ping buffer)
myParamSetup.option = CSL_EDMA_OPT_MAKE(FALSE,FALSE,FALSE,TRUE,tcc,
CSL_EDMA_TCC_EARLY,CSL_EDMA_FIFOWIDTH_128BIT,TRUE,CSL_EDMA_SYNC_ARRAY,
CSL_EDMA_ADDRMODE_INCR,CSL_EDMA_ADDRMODE_INCR);
myParamSetup.srcAddr = (Uint32)srcBuff1;
myParamSetup.elmArrCnt = CSL_EDMA_CNT_MAKE(256,1);
myParamSetup.dstAddr = (Uint32)dstBuff1;
myParamSetup.srcDstBidx = CSL_EDMA_BIDX_MAKE(1,1);
myParamSetup.BcntRld = CSL_EDMA_LINKBCNTRLD_MAKE(CSL_EDMA_LINK_NULL,0);
myParamSetup.srcDstCidx = CSL_EDMA_CIDX_MAKE(0,1);
myParamSetup.cCnt = 1;
myParamSetup.triggerWord = CSL_EDMA_TRIGWORD_DEFAULT;
// Setup the acquired parameter Entry
CSL_edmaParamSetup(param,&myParamSetup,CSL_EDMA_PARAM_BASIC);
// Enable Channel
...
// Write the trigger Word to trigger transfer
CSL_edmaParamWriteWord(myParamSetup,7,myParamSetup.cCnt);
}
@endverbatim
*
* ============================================================================
*/
#pragma CODE_SECTION (CSL_edmaParamWriteWord, ".text:csl_section:edma");
CSL_Status CSL_edmaParamWriteWord(
/** a handle to the param entry acquired previously by the QDMA channel */
CSL_EdmaParamHandle hParamHndl,
/** word offset in the 8 word paramater entry */
Uint16 wordOffset,
/** word to be written */
Uint32 word
)
{
Uint32* hParam = (Uint32*)(hParamHndl);
hParam[wordOffset] = word;
return CSL_SOK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -