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

📄 csl_pwmgethwsetup.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_pwmGetHwSetup.c
 *  
 *  @brief    File for functional layer of CSL API @a CSL_pwmGetHwSetup()
 *
 *  Path: \\(CSLPATH)\\ipmodules\\pwm\\src
 *
 *  Description
 *    - The @a CSL_pwmGetHwSetup() function definition & it's associated
 *      functions
 *  @date 6 May, 2004
 *  @author Pratheesh Gangadhar
 */
 
/* =============================================================================
 *  Revision History
 *  ===============
 *  03-Aug-2004 brn Updated for the new CSL architecture.
 *  11-Oct_2004 brn File updated with the review comments
 * =============================================================================
 */ 

#include <csl_pwm.h>

/** ============================================================================
 *   @n@b   CSL_pwmGetHwSetup
 *
 *   @b Description
 *   @n This function gets the current setup of the PWM. The status is
 *  returned through @a CSL_PwmHwSetup. The obtaining of status
 *  is the reverse operation of @a CSL_pwmHwSetup() function.
 *
 *
 *  @b Arguments
 *   
 *   @verbatim
            hPwm           Handle to the PWMS 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
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  The hardware set up structure will be populated with values from
 *       the registers
 *
 *   @b Modifies
 *   @n None
 *
 *  <b> Usage Constraints: </b>
 *  Both @a CSL_pwmInit() and @a CSL_pwmOpen() must be called successfully
 *  in that order before @a CSL_pwmGetHwSetup() can be called.
 *
 * @b Example:
 * @verbatim
      CSL_PwmHandle 	hPwm;
      CSL_Status 		status;
      CSL_PwmHwSetup 	*mysetup;
       ...
      status = CSL_pwmGetHwSetup(hPwm, &mysetup);
   @endverbatim
 *
 * @return returns the status of the operation (see @a CSL_Status)
 * ============================================================================
 */
#pragma CODE_SECTION (CSL_pwmGetHwSetup, ".text:csl_section:pwm");
CSL_Status CSL_pwmGetHwSetup ( 
    CSL_PwmHandle 		hPwm,
    CSL_PwmHwSetup 		*setup 
)   
{   
    CSL_Status status = CSL_SOK;
    CSL_PwmRegsOvly pwmRegs = hPwm->regs;   
    CSL_PwmConfigOneShot configOneShot;    
    CSL_PwmConfigContinuous configContinuous;                            
    if (setup == NULL) {
        return CSL_ESYS_INVPARAMS;
    }
    
    setup->modeSelect = (CSL_PwmMode)CSL_FEXT (pwmRegs->CFG, PWM_CFG_MODE);
                
    switch (setup->modeSelect) {
        case CSL_PWM_ONESHOT: 
            configOneShot.evtTrig = (CSL_PwmEventTrigger)
                                     CSL_FEXT (pwmRegs->CFG, PWM_CFG_EVTRIG);
            configOneShot.intEn = (CSL_PwmInterrupt)
                                   CSL_FEXT (pwmRegs->CFG, PWM_CFG_INTEN);
            configOneShot.inactOut = (CSL_PwmInactOutLevel)
                                      CSL_FEXT (pwmRegs->CFG, PWM_CFG_INACTOUT);
            configOneShot.p1Out = (CSL_PwmP1OutLevel)
                                   CSL_FEXT (pwmRegs->CFG, PWM_CFG_P1OUT);
            configOneShot.rpt = CSL_FEXT (pwmRegs->RPT, PWM_RPT_RPT);
            setup->mode.oneShot = configOneShot;
            break;     
             
        case CSL_PWM_CONTINUOUS: 
            configContinuous.intEn = (CSL_PwmInterrupt)
                                      CSL_FEXT (pwmRegs->CFG, PWM_CFG_INTEN);
            configContinuous.inactOut=(CSL_PwmInactOutLevel)
                                       CSL_FEXT (pwmRegs->CFG, PWM_CFG_INACTOUT);
            configContinuous.p1Out = (CSL_PwmP1OutLevel)
                                      CSL_FEXT (pwmRegs->CFG, PWM_CFG_P1OUT);
            setup->mode.continuous = configContinuous; 
            break;  
               
        default:
            status = CSL_EPWM_INVMODE;  
            break;  
    }
    setup->outPeriod = CSL_FEXT (pwmRegs->PER, PWM_PER_PER);    
    setup->phase1Duation = CSL_FEXT (pwmRegs->PH1D, PWM_PH1D_PH1D);
    setup->emuConfig = (CSL_PwmEmuCtrl)CSL_FEXT (pwmRegs->PCR, PWM_PCR_FREE);
    
    return status;
}

⌨️ 快捷键说明

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