www.pudn.com > DSP2812formotorcontrol.rar > DSP281x_BLDCPWM.h


/* ================================================================================== 
File name:        DSP281x_BLDCPWM.H                      
                     
Originator:	Digital Control Systems Group 
			Texas Instruments 
Description:   
Header file containing data type and object definitions and  
initializers. Also contains prototypes for the functions in DSP281x_BLDCPWM.C. 
 
Target: TMS320F281x family 
 
===================================================================================== 
 History: 
------------------------------------------------------------------------------------- 
 04-15-2005	Version 3.20: Using DSP281x v. 1.00 or higher  
---------------------------------------------------------------------------------- */ 
 
#ifndef __DSP281X_BLDCPWM_H__ 
#define __DSP281X_BLDCPWM_H__ 
 
#include "DSP281x_BMSK.h" 
 
/*---------------------------------------------------------------------------- 
Initialization constant for the F281X Timer TxCON for PWM Generation.  
Sets up the timer to soft stop emulation suspend, continuous up mode 
prescaler 1, timer enabled, compare enable. 
----------------------------------------------------------------------------*/ 
#define BLDCPWM_INIT_STATE  (SOFT_STOP_FLAG + 			\ 
                             TIMER_CONT_UP + 			\ 
                             TIMER_CLK_PRESCALE_X_1 + 	\ 
                             TIMER_ENABLE + 			\ 
                             TIMER_ENABLE_COMPARE) 
 
/*----------------------------------------------------------------------------- 
Define the structure of the PWM Driver Object  
-----------------------------------------------------------------------------*/ 
 
typedef struct {   
     	Uint16 CmtnPointer;    	// Input: Commutation (or switching) state pointer input (Q0) 
   		int16 MfuncPeriod;      // Input: Duty ratio of the PWM outputs (Q15)  
   		Uint16 PeriodMax;    	// Parameter: Maximum period (Q0) 
   		int16 DutyFunc;   	    // Input: PWM period modulation input (Q15) 
   		Uint16 PwmActive;     	// Parameter: 0 = PWM active low, 1 = PWM active high (0 or 1) 
   		void (*init)();   	    // Pointer to the init function  
   		void (*update)();     	// Pointer to the update function 
       } PWMGEN; 
 
/* 
The "PwmActive" setting depends on Power devices.  
when PwmActive = 1 (active high) implies the power device turns ON with a HIGH gate signal.  
     PwmActive = 0 (active low) implies the power device turns ON with a LOW gate signal.  
 
This polarity definition is not the same as the PWM polarity(Active High/Active Low)  
defined by the ACTRA register in x281x. The setting chosen here is applicable only  
when ACTRA is configured to generate Active High PWM.  
*/ 
 
/*----------------------------------------------------------------------------- 
Define a PWMGEN_handle 
-----------------------------------------------------------------------------*/ 
typedef PWMGEN *PWMGEN_handle; 
 
/*------------------------------------------------------------------------------ 
Default Initializers for the F281X PWMGEN Object  
------------------------------------------------------------------------------*/ 
#define F281X_EV1_BLDC_PWM_GEN {0x0000, \ 
                                0x7FFF, \ 
                                0x1D4C, \ 
                                0x0000, \ 
                                0x0001, \ 
                             (void (*)(Uint32))F281X_EV1_BLDC_PWM_Init,  \ 
                             (void (*)(Uint32))F281X_EV1_BLDC_PWM_Update \ 
                             } 
 
#define F281X_EV2_BLDC_PWM_GEN {0x0000, \ 
                                0x7FFF, \ 
                                0x1D4C, \ 
                                0x0000, \ 
                                0x0001, \ 
                             (void (*)(Uint32))F281X_EV2_BLDC_PWM_Init,  \ 
                             (void (*)(Uint32))F281X_EV2_BLDC_PWM_Update \ 
                             } 
 
#define PWMGEN_DEFAULTS 	F281X_EV1_BLDC_PWM_GEN 
/*------------------------------------------------------------------------------ 
 Prototypes for the functions in DSP281X_BLDCPWM.C 
------------------------------------------------------------------------------*/ 
void F281X_EV1_BLDC_PWM_Init(PWMGEN_handle); 
void F281X_EV1_BLDC_PWM_Update(PWMGEN_handle); 
 
#endif  // __DSP281X_BLDCPWM_H__