www.pudn.com > DSP2812formotorcontrol.rar > DSP281x_EN.c


/* ================================================================================== 
File name:       DSP281x_EN.C 
                     
Originator:	Digital Control Systems Group 
			Texas Instruments 
 
Description:  This program configures the I/O pins and enables/disables the drive on MCK2812 
 
Target: TMS320F281x family 
               
===================================================================================== 
History: 
------------------------------------------------------------------------------------- 
 04-15-2005	Version 3.20: Using DSP281x v. 1.00 or higher  
------------------------------------------------------------------------------------*/ 
 
#include "DSP281x_Device.h" 
#include "DSP281x_EN.h" 
 
void F281X_EV1_DRIVE_Init(DRIVE *p)  
{        
		// IOPB4: strobe_ (T1PWM_GPIOA6); IO PB6: enable_ (TDIRA_GPIOA11) 
        EALLOW;                       // Enable EALLOW 
		GpioMuxRegs.GPAMUX.bit.T1PWM_GPIOA6 = 0; 
		GpioMuxRegs.GPAMUX.bit.TDIRA_GPIOA11 = 0; 
		 
		// config IOPB4 & IOPB6 as outputs and output "1" to disable drive 
		GpioMuxRegs.GPADIR.bit.GPIOA6 = 1; 
		GpioMuxRegs.GPADIR.bit.GPIOA11 = 1; 
        EDIS;                         // Disable EALLOW 
		 
} 
 
void F281X_EV1_DRIVE_Update(DRIVE *p)  
{        
       if (p->EnableFlag==1)      // Enable PWM drive on DMC1500 
       { 
       	GpioDataRegs.GPADAT.bit.GPIOA6 = 0;  // IOPB4 low (T1PWM_GPIOA6)  
       	GpioDataRegs.GPADAT.bit.GPIOA6 = 1;  // IOPB4 high (T1PWM_GPIOA6)  
       	GpioDataRegs.GPADAT.bit.GPIOA11 = 0; // IOPB6 low (T1PWM_GPIOA11) 
       } 
       else if (p->EnableFlag==0)   // Disable PWM drive on DMC1500 
       { 
            GpioDataRegs.GPADAT.all |= 0x0840; // IOPB4 (T1PWM_GPIOA6) & IOPB6 (T1PWM_GPIOA11) outputs high 
       }    
        
}