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

📄 csl_pwrdwnhwsetup.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_pwrdwnHwSetup.c
 *
 *  @brief    File for functional layer of CSL API @a CSL_pwrdwnHwSetup()
 *
 *  PATH \\(CSLPATH)\\ipmodules\\pwrdwn\\src
 *
 *  Description
 *    - The @a CSL_pwrdwnHwSetup() function definition & it's associated
 *      functions
 *
 *  Modification 1
 *    - Modified on: 7/16/2004
 *    - Reason: created the sources
 *
 *  @author Ruchika Kharwar.
 * ============================================================================ 
 */

#include <csl_pwrdwn.h>

/** ===========================================================================
 *   @n@b CSL_pwrdwnHwSetup
 *
 *   @b Description
 *   @n It configures the  timer instance registers as per the values passed
 *      in the hardware setup structure.
 *
 *   @b Arguments
 *   @verbatim
            hPwrdwn         Handle to the pwrdwn instance

            setup           Pointer to hardware setup structure
     @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  CSL_pwrdwnInit(), CSL_pwrdwnOpen() must be opened prior to this call
 *
 *   <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 Example:
     @verbatim
        CSL_PwrdwnObj pwrObj;
        CSL_PwrdwnHwSetup pwrSetup;
        CSL_PwrdwnHandle hPwr;
        // Init Module
        ...
        if (CSL_pwrdwnInit(NULL) != CSL_SOK)
            exit;
        // Opening a handle for the Module	
    	hPwr = CSL_pwrdwnOpen (&pwrObj, CSL_PWRDWN_0, NULL, NULL);
	
    	// Setup the arguments for the Setup structure
    	...
	
	    // Setup
    	CSL_pwrdwnHwSetup(hPwr,&pwrSetup);
    
	    // Close handle
        CSL_pwrdwnClose(hPwr);
    @endverbatim
 * ============================================================================  
 */
#pragma CODE_SECTION (CSL_pwrdwnHwSetup, ".text:csl_section:pwrdwn");
/** @brief Configures the PWRDWN using the values passed in through the
 *  setup structure. 
 */
CSL_Status  CSL_pwrdwnHwSetup(
    /** Pointer to the object that holds reference to the
     *  instance of PWRDWN requested after the call 
	 */
    CSL_PwrdwnHandle  hPwrdwn,
    /** Pointer to setup structure which contains the
     *  information to program PWRDWN to a useful state 
	 */
    CSL_PwrdwnHwSetup *setup
)
{
	/** This is a pointer to the registers of the instance of L2 PWRDWN
     *  referred to by this object
     */
	CSL_L2pwrdwnRegsOvly l2pwrdwnRegs;
	Uint32 tempPdcCmd,NewPdcCmd;
    CSL_Status status = CSL_SOK;

    if (hPwrdwn == NULL) {
        return CSL_ESYS_BADHANDLE;
    }

    if (setup == NULL) {
        return CSL_ESYS_INVPARAMS;
    }
    
    tempPdcCmd = hPwrdwn->pdcRegs->PDCCMD;
    NewPdcCmd = tempPdcCmd;
    if (setup->l1dConf) {
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_DMCLOG,setup->l1dConf->clockGate);
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_DMCMEM,setup->l1dConf->mode);
    }
    if (setup->l2Conf) {
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_UMCLOG,setup->l2Conf->clockGate);
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_UMCMEM,setup->l2Conf->mode);
    }
    if (setup->l1pConf) {
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_PMCLOG,setup->l1pConf->clockGate);
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_PMCMEM,setup->l1pConf->mode);
    }
    if (setup->emcConf) {
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_EMCLOG,setup->emcConf->clockGate);
    	CSL_FINS(NewPdcCmd,PDC_PDCCMD_EMCMEM,setup->emcConf->mode);
    }
    if (NewPdcCmd!= tempPdcCmd) 
    	hPwrdwn->pdcRegs->PDCCMD = NewPdcCmd;
    if (setup->autoPwrdwn) {
		l2pwrdwnRegs = hPwrdwn->l2pwrdwnRegs;
		l2pwrdwnRegs->L2PDAEN[0] = setup->autoPwrdwn->umap0PageEnable;
		l2pwrdwnRegs->L2PDAEN[1] = setup->autoPwrdwn->umap1PageEnable;
		l2pwrdwnRegs->L2PDAPS[0] = setup->autoPwrdwn->umap0PeriodSelect;
		l2pwrdwnRegs->L2PDAPS[1] = setup->autoPwrdwn->umap1PeriodSelect;
		l2pwrdwnRegs->L2PDAP = CSL_FMK(L2PWRDWN_L2PDAP_PERA, setup->autoPwrdwn->periodA)|\
			CSL_FMK(L2PWRDWN_L2PDAP_PERB, setup->autoPwrdwn->periodB);
    }
    if (setup->manualPwrdwn) {
    	l2pwrdwnRegs = hPwrdwn->l2pwrdwnRegs;
    	l2pwrdwnRegs->L2PDWAKE[0] = setup->manualPwrdwn->umap0PageWake;
    	l2pwrdwnRegs->L2PDWAKE[1] = setup->manualPwrdwn->umap1PageWake;
    	l2pwrdwnRegs->L2PDSLEEP[0] = setup->manualPwrdwn->umap0PageSleep;
    	l2pwrdwnRegs->L2PDSLEEP[1] = setup->manualPwrdwn->umap1PageSleep;
    }

    return status;
}

⌨️ 快捷键说明

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