예제 #1
0
/******************************************************************************
 * Function:       void interrupt  USB_ISR()
 * Input:          
 * Output:          None
 * Overview:        The USB stat interrupt service routine
 * Note:            None
 *****************************************************************************/
void interrupt 7 USB_ISR()
{
  if(USBCTL0_LPRESF)
    {
      USBCTL0_USBRESMEN = 0;
    }
  
  if(INTSTAT_RESUMEF && INTENB_RESUME)
     USB_WakeFrom_Suspend();

     	
  if(INTSTAT_USBRSTF && INTENB_USBRST) 
    {
      INTSTAT = 0xBF;

      if(Usb_Device_State == USB_SUSPEND)
         Usb_State_Flag |= WAKE_UP_BY_RESET;
       
      USB_Bus_Reset_Handler();
    }
   

  if(INTSTAT_SOFTOKF && INTENB_SOFTOK)
    {
      USB_SOF_Handler();
    }
    
  if(INTSTAT_STALLF && INTENB_STALL )
      USB_Stall_Handler();
    
  if(INTSTAT_ERRORF && INTENB_ERROR)
      USB_Error_Handler(); 
   
     
  if(INTSTAT_SLEEPF && INTENB_SLEEP)
    {
      INTSTAT_SLEEPF = 1; 
      USBCTL0_USBRESMEN = 1;

      Old_Usb_State = Usb_Device_State ;
      Usb_Device_State = USB_ENTER_SUSPEND; /*do not hope enter into suspend */
    }
                
  if(INTSTAT_TOKDNEF && INTENB_TOKDNE)
    {            
      USB_Transaction_Handler();              
      INTSTAT_TOKDNEF = 1;     /*write 1 to clear*/
    }
    
   return;
}
예제 #2
0
void USB_ISR(void)
{
    *pu8trace++=0xCC;

  //PMC_VLPR_Exit();
    
    FLAG_SET(1,GPIOC_PDOR);
  
    if(FLAG_CHK(USB_ISTAT_USBRST_SHIFT,USB0_ISTAT)) 
    {
        // Clear Reset Flag 
        //USB_ISTAT = USB_ISTAT_USBRST_MASK;   

        // Handle RESET Interrupt 
        USB_Reset_Handler();
   
        // Clearing this bit allows the SIE to continue token processing
        //   and clear suspend condition 
        //CTL_TXSUSPEND_TOKENBUSY = 0;
        //FLAG_CLR(USB_CTL_TXSUSPENDTOKENBUSY_SHIFT,USB_CTL);
        // No need to process other interrupts 
        //return;
    }
    
    
    if(FLAG_CHK(USB_ISTAT_SOFTOK_SHIFT,USB0_ISTAT)) 
    {
        USB0_ISTAT = USB_ISTAT_SOFTOK_MASK;   
    }
    
    
    
    if(FLAG_CHK(USB_ISTAT_STALL_SHIFT,USB0_ISTAT)) 
    //if(INT_STAT_STALL && INT_ENB_STALL_EN )
    {
        USB_Stall_Handler();
    }
    
    
     if(FLAG_CHK(USB_ISTAT_TOKDNE_SHIFT,USB0_ISTAT)) 
    {

        FLAG_SET(USB_CTL_ODDRST_SHIFT,USB0_CTL);
        USB_Handler();
        FLAG_SET(USB_ISTAT_TOKDNE_SHIFT,USB0_ISTAT);
    }
    
    
    if(FLAG_CHK(USB_ISTAT_SLEEP_SHIFT,USB0_ISTAT)) 
    //if(INT_STAT_SLEEP && INT_ENB_SLEEP_EN_MASK)
    {
            // Clear RESUME Interrupt if Pending 
        //INT_STAT = INT_STAT_RESUME_MASK;
          //u8ISRCounter++;  
      //FLAG_SET(USB_ISTAT_RESUME_SHIFT,USB_ISTAT);
        
        // Clear SLEEP Interrupt 
        FLAG_SET(USB_ISTAT_SLEEP_SHIFT,USB0_ISTAT);
        //INT_STAT = INT_STAT_SLEEP_MASK;
        //FLAG_SET(USB_INTEN_RESUME_SHIFT,USB_ISTAT);
        //INT_ENB_RESUME_EN = 1;
        
    }
    
    if(FLAG_CHK(USB_ISTAT_ERROR_SHIFT,USB0_ISTAT)) 
    //if(INT_STAT_ERROR && INT_ENB_ERROR_EN )
    {
        FLAG_CHK(USB_ISTAT_ERROR_SHIFT,USB0_ISTAT);
        //printf("\nUSB Error\n");
        //INT_STAT_ERROR=1;

    }
}