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

📄 csl2_dat_edma3lld.c

📁 vicp做为dm6446上的硬件加速器
💻 C
字号:
/*
 *  Copyright 2006
 *  Texas Instruments Incorporated
 *
 *  All rights reserved.  Property of Texas Instruments Incorporated
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *
 */
/**
 *  @file        csl2_dat_edma3lld.c
 *
 *  @brief       Implements the EDMA3 LLD Initialization and clean up
 *               functions
 *
 */

/*
 * Includes for accessing EDMA3 Driver Sample Init/Deinit functions
 */
#include <ti/sdo/edma3/drv/sample/bios_edma3_drv_sample.h>

#include <csl2_dat_edma3lld.h>
/*
 * global variable definitions
 */

/*
 * Flag to guard against multiple calls to DAT_EDMA3LLD_init
 */
int DAT_EDMA3LLD_initCalled = 0;


/*
 * static variable definitions
 */

/*
 * Flag to indicate that this instance is the master of the DRV instance
 */
static int _drvMaster = 0;

/*
 * extern variable declarations
 */

/*
 * The EDMA3 handle and the number of allocated channels needed by the
 * DAT module is setup here
 */
extern EDMA3_DRV_Handle DAT_EDMA3LLD_hEdma;
extern int DAT_EDMA3LLD_numAllocatedChannels;



/* External Declaration */
EDMA3_DRV_Result edma3init();

/*
 * OS dependent functions, that must be implemented by user of CSL DAT adapter
 * These functions mark the entry and exit to critical sections of the code
 */
extern void _dat_critical_section_enter();
extern void _dat_critical_section_exit();


/*
 * global function definitions
 */

/*
 * ======== DAT_EDMA3llD_init ========
 * This function initializes the EDMA3 LLD for the DAT module
 */
int DAT_EDMA3LLD_init(DAT_EDMA3LLD_Param * param) {

    EDMA3_DRV_Result edmaResult = EDMA3_DRV_SOK;

    /*
     * Ensure DAT_EDMA3LLD_init is called only once
     */
    _dat_critical_section_enter();
    if (DAT_EDMA3LLD_initCalled)
    {
        _dat_critical_section_exit();
        return 0;
    }

    DAT_EDMA3LLD_initCalled = 1;
    _dat_critical_section_exit();

    /*
     *  If the passed parameter is NULL, then configure EDMA3 with the
     * default settings
     */
    if (NULL == param) {

    /* Initialize EDMA3 first */
    edmaResult = edma3init();
    if (edmaResult != EDMA3_DRV_SOK)
        {
        printf("edma3init() FAILED, error code: %d\r\n",
                            edmaResult);
        }
    else
        {
        printf("edma3init() PASSED\r\n");
        }

        /*
         * Allocate maximum number of channels by default
         */
        DAT_EDMA3LLD_numAllocatedChannels = DAT_QUEUEDEPTH;

        /*
         * Flag indicating DAT was responsible for creating the DRV instance
         * and opening it
         */
        _drvMaster = 1;
    }
    else
    {
        /*
         * Use the EDMA3 DRV handle passed for requesting channels etc
         */
        DAT_EDMA3LLD_hEdma = param->hEdma;

        /*
         * Save the number of allocated channels from the config information
         */
        DAT_EDMA3LLD_numAllocatedChannels = param->numChannels;
    }

    return 1;
}

/*
 * ======== DAT_EDMA3llD_exit ========
 * Function to clean-up the EDMA3 LLD after use
 */
void DAT_EDMA3LLD_exit() {

    /*
     * Ensure _initCalled was set
     */
    _dat_critical_section_enter();
    if (DAT_EDMA3LLD_initCalled == 0)
    {
        _dat_critical_section_exit();
        return;
    }

    if (_drvMaster == 0)
    {
        DAT_EDMA3LLD_hEdma = NULL;
        _dat_critical_section_exit();
        return;
    }

    DAT_EDMA3LLD_initCalled = 0;
    _dat_critical_section_exit();
}




⌨️ 快捷键说明

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