USB.C 读取bCommon判断执行哪个动作 if (bCommon & rbRSUINT)//0x02 // Handle Resume interrupt { Usb_Resume(); } if (bCommon & rbRSTINT) // Handle Reset interrupt { Usb_Reset(); } if (bCommon & rbSUSINT) // Handle Suspend interrupt { Usb_Suspend(); } if (bIn & rbEP0) // Handle Setup packet received { // or packet transmitted if Endpoint 0 Handle_Setup(); // is transmit mode } if (bIn & rbIN1) // Handle In Packet sent, put new data { // on endpoint 1 fifo Handle_In1(); } if (bOut & rbOUT2) // Handle Out packet received, take data { // off endpoint 2 fifo Handle_Out2(); } void Handle_Setup(),标准请求和类请求 switch ( Setup.bmRequestType & DRT_MASK ) // Device Request Type { case DRT_STD: // Standard device request Standard_Device_Request(); break; case DRT_CLASS: // class specific request Class_Request(); break; case DRT_VENDOR: // vendor request Vendor_Request(); break; default: break; } void Class_Request( void )类请求实现Get_Report,Set_Report { if ( Setup.wIndex.i == DSC_INTERFACE_HID ) // interface index must match to the HID IF { switch( Setup.bRequest ) // dispatch according to the bRequest { case HID_REQ_GET_REPORT: Get_Report(); break; case HID_REQ_SET_REPORT: Set_Report(); break;