コード例 #1
0
ファイル: usb_t9.c プロジェクト: Forvater/STM32-P103
/*************************************************************************
 * Function Name: UsbWakeUp
 * Parameters:  none
 *
 * Return: none
 *
 * Description: Wake-up device from suspend mode
 *
 *************************************************************************/
void UsbWakeUp (void)
{
  if(UsbDevCtrl.Feature.RemoteWakeupEnable && UsbDevCtrl.State.Suspend)
  {
    USB_WakeUp();
  }
}
コード例 #2
0
ファイル: Usb_Drv.c プロジェクト: QrackEE/rapidradioUSB
/******************************************************************************
 * Function:        void USB_Suspend(void)
 * PreCondition:    None
 * Input:           None
 * Output:          None
 * Side Effects:    None
 * Overview:        After 3ms of USB bus idle status, the SLEEPF will be set,
 *                  The firmware should enable the resume function in 7ms before 
 *                  the USB enters into suspend state.       
 * Note:            None
 *****************************************************************************/
void USB_Suspend(void)
{
    unsigned char Result;
   
    //INTENB_RESUME = 1;   
    USBCTL0_USBRESMEN = 1;
                     
    //INTSTAT_SLEEPF = 1;                    
    //RTC_DISBALE();
    
   
    Usb_Device_State = USB_SUSPEND;
    do
      {
        Result = USB_WakeUp() ;
      }while(!Result);
      
    //USBCTL0_USBRESMEN = 0;  
    
    if(Result == 2)
        USB_Remote_Wakeup();
    
    Usb_Device_State = Old_Usb_State;                      
                          
    //RTC_ENABLE();
	return;
}
コード例 #3
0
ファイル: usbhw_STM32F10x.c プロジェクト: mcufans/xlink
void USB_LP_IRQHandler (void) {
  U32 istr, num, val;

  istr = ISTR;

  /* USB Reset Request */
  if (istr & ISTR_RESET) {
    USB_Reset();
#if USB_RESET_EVENT
    USB_Reset_Event();
#endif
    ISTR = ~ISTR_RESET;
  }

  /* USB Suspend Request */
  if (istr & ISTR_SUSP) {
    USB_Suspend();
#if USB_SUSPEND_EVENT
    USB_Suspend_Event();
#endif
    ISTR = ~ISTR_SUSP;
  }

  /* USB Wakeup */
  if (istr & ISTR_WKUP) {
    USB_WakeUp();
#if USB_RESUME_EVENT
    USB_Resume_Event();
#endif
    ISTR = ~ISTR_WKUP;
  }

  /* Start of Frame */
  if (istr & ISTR_SOF) {
#if USB_SOF_EVENT
    USB_SOF_Event();
#endif
    ISTR = ~ISTR_SOF;
  }

#if USB_ERROR_EVENT

  /* PMA Over/underrun */
  if (istr & ISTR_PMAOVR) {
    USB_Error_Event(1);
    ISTR = ~ISTR_PMAOVR;
  }

  /* Error: No Answer, CRC Error, Bit Stuff Error, Frame Format Error */
  if (istr & ISTR_ERR) {
    USB_Error_Event(0);
    ISTR = ~ISTR_ERR;
  }

#endif

  /* Endpoint Interrupts */
  while ((istr = ISTR) & ISTR_CTR) {
    ISTR = ~ISTR_CTR;

    num = istr & ISTR_EP_ID;

    val = EPxREG(num);
    if (val & EP_CTR_RX) {
      EPxREG(num) = val & ~EP_CTR_RX & EP_MASK;
      if (USB_P_EP[num]) {
        if (val & EP_SETUP) {
          USB_P_EP[num](USB_EVT_SETUP);
        } else {
          USB_P_EP[num](USB_EVT_OUT);
        }
      }
    }
    if (val & EP_CTR_TX) {
      EPxREG(num) = val & ~EP_CTR_TX & EP_MASK;
      if (USB_P_EP[num]) {
        USB_P_EP[num](USB_EVT_IN);
      }
    }
  }
}
コード例 #4
0
void
CmtUsbDev::IrqHandler() {
  uint32 istr, num, val;

  istr = ISTR;

  /* USB Reset Request */
  if (istr & ISTR_RESET) {
    USB_Reset();
    ISTR = ~ISTR_RESET;
    }

  /* USB Suspend Request */
  if (istr & ISTR_SUSP) {
    USB_Suspend();
    ISTR = ~ISTR_SUSP;
    }

  /* USB Wakeup */
  if (istr & ISTR_WKUP) {
    USB_WakeUp();
    ISTR = ~ISTR_WKUP;
    }

  /* Start of Frame */
  if (istr & ISTR_SOF) {
    USB_StartOfFrame();
    ISTR = ~ISTR_SOF;
    }

  /* PMA Over/underrun */
  if (istr & ISTR_PMAOVR) {
    USB_Error(1);
    ISTR = ~ISTR_PMAOVR;
    }

  /* Error: No Answer, CRC Error, Bit Stuff Error, Frame Format Error */
  if (istr & ISTR_ERR) {
    USB_Error(0);
    ISTR = ~ISTR_ERR;
    }

  /* Endpoint Interrupts */
  while( (istr = ISTR) & ISTR_CTR) {
    ISTR = ~ISTR_CTR;

    num = istr & ISTR_EP_ID;

    val = EPxREG(num);
    if (val & EP_CTR_RX) {
      EPxREG(num) = val & ~EP_CTR_RX & EP_MASK;
      switch( num ) {
        case 0  : EndPoint0( val & EP_SETUP ? USB_EVT_SETUP : USB_EVT_OUT ); break;
        case 1  : EndPoint1( USB_EVT_OUT ); break;
        case 2  : EndPoint2( USB_EVT_OUT ); break;
        case 3  : EndPoint3( USB_EVT_OUT ); break;
        case 4  : EndPoint4( USB_EVT_OUT ); break;
        case 5  : EndPoint5( USB_EVT_OUT ); break;
        case 6  : EndPoint6( USB_EVT_OUT ); break;
        case 7  : EndPoint7( USB_EVT_OUT ); break;
        case 8  : EndPoint8( USB_EVT_OUT ); break;
        case 9  : EndPoint9( USB_EVT_OUT ); break;
        case 10 : EndPoint10( USB_EVT_OUT ); break;
        case 11 : EndPoint11( USB_EVT_OUT ); break;
        case 12 : EndPoint12( USB_EVT_OUT ); break;
        case 13 : EndPoint13( USB_EVT_OUT ); break;
        case 14 : EndPoint14( USB_EVT_OUT ); break;
        case 15 : EndPoint15( USB_EVT_OUT ); break;
        }
      }
    if (val & EP_CTR_TX) {
      EPxREG(num) = val & ~EP_CTR_TX & EP_MASK;
      switch( num ) {
        case 0  : EndPoint0( USB_EVT_IN ); break;
        case 1  : EndPoint1( USB_EVT_IN ); break;
        case 2  : EndPoint2( USB_EVT_IN ); break;
        case 3  : EndPoint3( USB_EVT_IN ); break;
        case 4  : EndPoint4( USB_EVT_IN ); break;
        case 5  : EndPoint5( USB_EVT_IN ); break;
        case 6  : EndPoint6( USB_EVT_IN ); break;
        case 7  : EndPoint7( USB_EVT_IN ); break;
        case 8  : EndPoint8( USB_EVT_IN ); break;
        case 9  : EndPoint9( USB_EVT_IN ); break;
        case 10 : EndPoint10( USB_EVT_IN ); break;
        case 11 : EndPoint11( USB_EVT_IN ); break;
        case 12 : EndPoint12( USB_EVT_IN ); break;
        case 13 : EndPoint13( USB_EVT_IN ); break;
        case 14 : EndPoint14( USB_EVT_IN ); break;
        case 15 : EndPoint15( USB_EVT_IN ); break;
        }
      }
    }  
  }