www.pudn.com > wave-bulktransfer.rar > FUNCTION.C


#pragma NOIV 
 
#include "testheader.h" 
#include "testregs.h" 
 
extern BOOL	Rwuen;  
extern BOOL	GotSUD; 
extern BOOL	Sleep; 
extern BOOL	Selfpwr; 
 
BYTE	Configuration; 
BYTE	AlternateSetting; 
BYTE    suspCount; 
 
void TD_Init(void) 	 
{ 
     
    IN07VAL |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7; 
    OUT07VAL |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5+ bmEP6 + bmEP7; 
     
    OUT07IEN |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7; 
    IN07IEN |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7; 
 
    suspCount = 1;       
    Rwuen = TRUE;	 
     
    PORTCCFG = 0x40;     
    OEC = 0x30 ;         
 
    OUTC = 0x10;   
    OUTC = 0x10;   
    OUTC = 0x10;   
} 
 
void TD_Poll(void) 
{ 
                   
} 
 
BOOL TD_Suspend(void) 	     
{                              
   PORTCCFG = 0x40;  
   OEC = 0x30 ;              
 
   return(TRUE); 
}       
 
BOOL TD_Resume(void) 	 
{ 
	return(TRUE);        
} 
BOOL DR_GetDescriptor(void)  
{	 
	return(TRUE);        
} 
BOOL DR_GetInterface(void)  
{ 
	IN0BUF[0] = AlternateSetting; 
	EZUSB_SET_EP_BYTES(IN0BUF_ID,1); 
	return(TRUE);	 
} 
BOOL DR_SetInterface(void)  
{ 
	AlternateSetting = SETUPDAT[2]; 
	return(TRUE);	 
} 
BOOL DR_GetConfiguration(void)	  
{ 
	IN0BUF[0] = Configuration; 
	EZUSB_SET_EP_BYTES(IN0BUF_ID,1); 
	return(TRUE);		 
} 
BOOL DR_SetConfiguration(void)	  
{ 
	Configuration = SETUPDAT[2]; 
	return(TRUE);		 
} 
 
BOOL DR_GetStatus(void)           
{ 
	return(TRUE);             
} 
BOOL DR_ClearFeature(void)        
{ 
	return(TRUE);             
} 
 
BOOL DR_SetFeature(void)          
{ 
	return(TRUE);             
} 
 
BOOL DR_VendorCmnd(void) 
{ 
   if (SETUPDAT[1] == 0xB0) 
   { 
      EZUSB_UNARM_EP(EPID(SETUPDAT[4])); 
 
      return(FALSE); 
   } 
 
   return(TRUE); 
} 
 
void ISR_Sudav(void) interrupt USB_VECT 
{ 
	GotSUD = TRUE;	 
 
	EZUSB_IRQ_CLEAR(); 
	USBIRQ = bmSUDAV; 
} 
 
void ISR_Sutok(void) interrupt USB_VECT 
{ 
	EPIO[OUT0BUF_ID].cntrl = 0; 
 
	EZUSB_IRQ_CLEAR(); 
	USBIRQ = bmSUTOK;	 
} 
 
void ISR_Sof(void) interrupt USB_VECT 
{ 
	EZUSB_IRQ_CLEAR(); 
	USBIRQ = bmSOF;	 
} 
 
void ISR_Ures(void) interrupt USB_VECT 
{ 
        EPIO[OUT1BUF_ID].bytes = 0; 
        EPIO[OUT2BUF_ID].bytes = 0; 
        EPIO[OUT3BUF_ID].bytes = 0; 
        EPIO[OUT4BUF_ID].bytes = 0; 
        EPIO[OUT5BUF_ID].bytes = 0; 
        EPIO[OUT6BUF_ID].bytes = 0; 
        EPIO[OUT7BUF_ID].bytes = 0; 
 
	EZUSB_IRQ_CLEAR(); 
	USBIRQ = bmURES; 
} 
 
void ISR_Spare(void) interrupt USB_VECT 
{ 
 
} 
 
void ISR_Susp(void) interrupt USB_VECT 
{ 
   if (suspCount) 
   { 
           suspCount--; 
   } 
   else 
   { 
	   Sleep = TRUE; 
   } 
	   EZUSB_IRQ_CLEAR(); 
	   USBIRQ = bmSUSP; 
} 
 
void ISR_Ep0in(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep0out(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep1in(void) interrupt USB_VECT 
{ 
} 
void ISR_Ep1out(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep2in(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep2out(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep3in(void) interrupt USB_VECT 
{   
} 
 
void ISR_Ep3out(void) interrupt USB_VECT 
{ 
  if (OUT3BUF[0]==0x55)        
  { 
      OUTC =(PINSC)&0xEF;  
      OUTC =(PINSC)&0xEF;  
      OUTC =(PINSC)&0xEF;  
       
      OUTC =(PINSC)|0x20;  
      OUTC =(PINSC)|0x20;  
      OUTC =(PINSC)|0x20;  
  } 
 
  OUT3BC = 0; 
 
  EZUSB_IRQ_CLEAR(); 
  OUT07IRQ = bmEP3; 
} 
 
void ISR_Ep4in(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep4out(void) interrupt USB_VECT 
{ 
    if(OUT4BUF[0]==0xAA) 
    { 
        OUTC =(PINSC)|0x10; 
        OUTC =(PINSC)|0x10; 
        OUTC =(PINSC)|0x10; 
 
        OUTC = (PINSC)&0xDF;  
        OUTC = (PINSC)&0xDF;  
        OUTC = (PINSC)&0xDF;  
        OUTC = (PINSC)&0xDF;  
    } 
 
   OUT4BC = 0;    
 
   EZUSB_IRQ_CLEAR(); 
   OUT07IRQ = bmEP4; 
} 
 
void ISR_Ep5in(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep5out(void) interrupt USB_VECT 
{ 
   int i; 
   for (i=0;i<64;i++) 
   { 
      DA0832=OUT5BUF[i]; 
   }      
 
   OUT5BC = 0; 
 
 
   EZUSB_IRQ_CLEAR(); 
   OUT07IRQ = bmEP5; 
} 
 
void ISR_Ep6in(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep6out(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep7in(void) interrupt USB_VECT 
{ 
} 
 
void ISR_Ep7out(void) interrupt USB_VECT 
{ 
}