|
Uint16 Request; USB_REQUEST_RET ReqHandlerRet = USB_REQUEST_DONE; USB_EVENT_MASK USB_ctl_events;
USB_ctl_events = (USB_getEvents(hEp0Out) | USB_getEvents(hEp0In));
//Match with the appropriate EVENT if(USB_ctl_events & USB_EVENT_RESET) // USB RESET event received { USB_abortAllTransaction(DevNum); // stop all data transfer activities usbCurConfigStat = 0x00; // reset device config number usbCurAltSetStat = 0x00; // reset Alt Setting number USB_init(USB0, myUsbConfig, 0x80); // reconfig the USB module }
if(USB_ctl_events & USB_EVENT_SUSPEND) //USB suspend { //add code here to deal with suspend
}
if((USB_ctl_events & USB_EVENT_SETUP) == USB_EVENT_SETUP) {
if(USB_getSetupPacket(DevNum,&USB_Setup) == USB_FALSE) { //stall the control pipe ReqHandlerRet = USB_REQUEST_STALL; } //decode the setup packet else { // unpacket the setup packet }
|