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

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

#include <csl_pwm.h>
#include <csl_pwmAux.h>

/** ============================================================================
 *   @n@b   CSL_pwmHwControl
 *
 *   @b Description
 *   @n Control operations for the PWM.  For a particular control operation, the
 *  pointer to the corresponding data type needs to be passed as argument 
 *  HwControl function Call. All the arguments (Structure elements included) 
 *  passed to  the HwControl function are inputs. For the list of commands 
 *  supported and argument type that can be @a void* casted & passed with a 
 *  particular command refer to @a CSL_PwmHwControlCmd.
 *
 *   @b Arguments
 *   @verbatim
            hPwm         Handle to the PWM instance

            cmd          Operation to be performed on the PWM

            arg          Argument specific to the command

     @endverbatim
 *
 *   <b> Return Value </b>  CSL_Status
 *   @li                    CSL_SOK            - Command execution successful.
 *   @li                    CSL_ESYS_BADHANDLE - Invalid handle
 *   @li                    CSL_ESYS_INVCMD    - Invalid command
 *
 *   <b> Pre Condition </b>
 *   @n  None
 *
 *   <b> Post Condition </b>
 *   @n  Registers of the PWM instance are configured according to the command
 *       and the command arguments. The command determines which registers are
 *       modified.
 *
 *   @b Modifies
 *   @n Registers determined by the command
 *
 *  <b> Usage Constraints: </b>
 *  Both @a CSL_pwmInit() and @a CSL_pwmOpen() must be called successfully
 *  in that order before @a CSL_pwmHwControl() can be called. For the
 *  argument type that can be @a void* casted & passed with a particular command
 *  refer to @a CSL_PwmHwControlCmd
 *
 * @b Example:
 * @verbatim
       CSL_PwmHandle        hPwm;
       CSL_Status           status;
       ...
       status = CSL_pwmHwControl(hPwm,
                                  CSL_PWM_CMD_START,
                                  &command);
   @endverbatim
 *
 *  @return returns the status of the operation (see @a CSL_Status)
 * ============================================================================
 */
#pragma CODE_SECTION (CSL_pwmHwControl, ".text:csl_section:pwm");
CSL_Status CSL_pwmHwControl ( 
    CSL_PwmHandle         hPwm,
    CSL_PwmHwControlCmd   cmd,
    void                  *arg 
)
{
    CSL_Status status = CSL_SOK;
    if(hPwm == NULL) {
        status = CSL_ESYS_BADHANDLE;
        return status;
    }
    
    switch (cmd) {
        case CSL_PWM_CMD_START: 
            CSL_pwmStart (hPwm);      
            break;
            
        case CSL_PWM_CMD_SET_PERIOD:  
            CSL_pwmSetPeriod (hPwm, *(Uint32 *)arg);
            break; 
               
        case CSL_PWM_CMD_SET_PHASE1_DURATION: 
            CSL_pwmSetPhase1Duration (hPwm, *(Uint32 *)arg);
            break;    
            
        case CSL_PWM_CMD_SET_MODE: 
            switch (*(CSL_PwmMode*)arg) {
                case CSL_PWM_DISABLE:       
                    CSL_pwmDisableMode (hPwm);
                    break;
                    
                case CSL_PWM_ONESHOT:
                    CSL_pwmOneShotMode (hPwm);
                    break;
                    
                case CSL_PWM_CONTINUOUS:    
                    CSL_pwmContinuousMode (hPwm);
                    break;
                    
                default:
                    status = CSL_EPWM_INVMODE;
                    break;
            }  
            break; 
            
        case CSL_PWM_CMD_CONFIG_ONE_SHOT:
            CSL_pwmConfigOneShot (hPwm, *(CSL_PwmConfigOneShot *)arg);           
            break;        
            
        case CSL_PWM_CMD_CONFIG_CONTINUOUS:  
            CSL_pwmConfigContinuous (hPwm, *(CSL_PwmConfigContinuous *)arg);
            break; 
            
        case CSL_PWM_CMD_STOP:
             CSL_pwmStop (hPwm);
            break;
            
        case CSL_PWM_CMD_RUN_FREE:    
             CSL_pwmRunFree (hPwm);
            break;     
            
        default:
            status = CSL_ESYS_INVCMD;
            break;
    }
    
    return status;
}  

⌨️ 快捷键说明

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