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

📄 csl_edmachannelopen.c

📁 TI达芬奇dm644x各硬件模块测试代码
💻 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_edmaChannelOpen.c
 *
 *  @brief    File for functional layer of CSL API @a CSL_edmaChannelOpen()
 *
 *  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_edmaChannelOpen
 *
 *   @b Description
 *   @n Reserves the specified EDMA Channel for use. The channel can be 
 *      re-opened anytime after it has been normally closed if so required. The 
 *      handle returned by this call is input as an essential argument for many 
 *      of the APIs described for this module.
 *
 *   @b Arguments
 *   @verbatim

            hRegion          Shadow region handle

            edmaObj          Pointer to the EDMA Handle Object - to be allocated
                             by the user.

            edmaNum          Instance of the EDMA to be opened.

            param            Channel specific parameters

            status           Pointer to CSL Status.

     @endverbatim
 *
 *   <b> Return Value </b>
 *      CSL_EdmaHandle
 *        Valid EDMA instance handle will be returned if status value is
 *        equal to CSL_SOK.
 *
 *   <b> Pre Condition </b>
 *   @n  @a CSL_edmaInit() must be called successfully.
 *
 *   <b> Post Condition </b>
 *   @n  None
 *
 *   @b  Modifies
 *   @n  None
 *
 *
 *  <b> Usage Constraints: </b>
 *  All @a CSL_edmaInit(), @a CSL_edmaOpen() must be 
 *  invoked successfully in that order before this API can be invoked.
 *  If the channel is opened in context of a Region, @a CSL_edmaRegionOpen()
 *   may also need to be invoked before this API. If a Shadow region is used  
 *   then care of the DRAE settings must be taken.
 *  
 *  Memory for the   CSL_EdmaChanObj must be allocated outside
 *  this call.
 *
 *   @b Example:
 *   @verbatim
         CSL_EdmaHandle hModule;

    CSL_EdmaChanObj ChObj;
    CSL_EdmaChanHandle hChannel;
    CSL_EdmaChannelParam chParam;
    CSL_Status         edmaStatus;  

    // Initialization
    CSL_edmaInit();
    // Module Level Open    
     hModule = CSL_edmaOpen(NULL,CSL_EDMA_0,NULL,&edmaStatus);

    ...
    // Channel 0 is opened which is allocated to Region Region 0
    chParam.regionNum = CSL_EDMA_REGION_GLOBAL;
    chParam.chaNum = CSL_EDMA_CHA0;
    hChannel = CSL_edmaChannelOpen(&edmaObj,
                            CSL_EDMA_0,
                            &chParam,
                            &edmaStatus);
     @endverbatim
 *
 * ===========================================================================
 */
#pragma CODE_SECTION (CSL_edmaChannelOpen, ".text:csl_section:edma");

/** Reserves the specified EDMA Channel for use. The channel can be
 *  re-opened anytime after it has been normally closed if so
 *  required. The handle returned by this call is input as an
 *  essential argument for many of the APIs described for this
 *  module.
 *  
 *  <b> Usage Constraints: </b>
 *  All @a CSL_edmaInit(), @a CSL_edmaOpen() must be 
 *  invoked successfully in that order before this API can be invoked.
 *  If the channel is opened in context of a Region, @a CSL_edmaRegionOpen()
 *  may also need to be invoked before this API. If a Shadow region is used  
 *  then care of the DRAE settings must be taken.
 *  
 *  Memory for the   CSL_EdmaChanObj must be allocated outside
 *  this call.
 *  
 *  @b Example:
    \code
    CSL_EdmaHandle hModule;
    
    CSL_EdmaChanObj ChObj;
    CSL_EdmaChanHandle hChannel;
    CSL_EdmaChannelParam chParam;
    CSL_Status         edmaStatus;  
    
    // Initialization
    CSL_edmaInit();
    // Module Level Open    
     hModule = CSL_edmaOpen(NULL,CSL_EDMA_0,NULL,&edmaStatus);
    
    ...
    // Channel 0 is opened which is allocated to Region Region 0
    chParam.regionNum = CSL_EDMA_REGION_GLOBAL;
    chParam.chaNum = CSL_EDMA_CHA0;
    hChannel = CSL_edmaChannelOpen(&edmaObj,
                            CSL_EDMA_0,
                            &chParam,
                            &edmaStatus);
                            
    \endcode
 *
 *  @return Handle   CSL_EdmaHandle to the requested channel instance
 *  of the specified EDMA if the call is successful, else a NULL is
 *  returned.
 *
 */
CSL_EdmaChanHandle  CSL_edmaChannelOpen(
    /** pointer to the object that holds reference to the channel
    * instance of the Specified DMA */
    CSL_EdmaChanObj            *edmaObj,
    /** instance of EDMA whose channel is requested */
    CSL_InstNum                edmaNum,
    /** instance of Channel requested */
    CSL_EdmaChannelParam       *param,
    /** This returns the status (success/errors) of the call */
    CSL_Status                 *pStatus
)
{
    CSL_EdmaChanHandle   hEdma = (CSL_EdmaChanHandle)NULL;
    
    CSL_Status status = CSL_SOK;
    CSL_EdmaModuleBaseAddress  baseAddress;
    if (param != NULL) {
        status = CSL_edmaccGetModuleBaseAddr(edmaNum,NULL,&baseAddress);
        edmaObj->ccregs = baseAddress.regs;
        edmaObj->edmaNum = edmaNum;
        edmaObj->chaNum = param->chaNum;
        edmaObj->region = param->regionNum;
        hEdma = (CSL_EdmaChanHandle)edmaObj;
    } else {
        status = CSL_ESYS_FAIL;    
    }
    if (status != CSL_SOK)
        *pStatus = CSL_ESYS_FAIL;
    else 
        *pStatus = CSL_SOK;

    return(hEdma);
}
    

⌨️ 快捷键说明

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