We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi All, I followed http://www.keil.com/forum/docs/thread11649.asp to try add 4 in endpoints with 64 byte data length on my MCB2300(LPC2368)board, But it can not be recognized. I can not fig it out what mistaks I made. My modified codes here based on the example USB_HID.
1.usbdesc.c
#include "type.h" #include "usb.h" #include "hid.h" #include "usbcfg.h" #include "usbdesc.h" #define INREPORT_SIZE 64 #define OUTREPORT_SIZE 64 /* HID Report Descriptor */ const BYTE HID_ReportDescriptor0[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(3), HID_LogicalMin(0), HID_LogicalMax(1), //HID_ReportCount(3), //HID_ReportSize(1), HID_ReportCount( INREPORT_SIZE ), // bytes HID_ReportSize(8), // bits HID_Input(HID_Data | HID_Variable | HID_Absolute), //HID_ReportCount(1), //HID_ReportSize(5), //HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(OUTREPORT_SIZE), HID_ReportSize(8), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, }; const BYTE HID_ReportDescriptor1[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(3), HID_LogicalMin(0), HID_LogicalMax(1), //HID_ReportCount(3), //HID_ReportSize(1), HID_ReportCount( INREPORT_SIZE ), // bytes HID_ReportSize(8), // bits HID_Input(HID_Data | HID_Variable | HID_Absolute), //HID_ReportCount(1), //HID_ReportSize(5), //HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(OUTREPORT_SIZE), HID_ReportSize(8), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, };
const BYTE HID_ReportDescriptor2[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(3), HID_LogicalMin(0), HID_LogicalMax(1), //HID_ReportCount(3), //HID_ReportSize(1), HID_ReportCount( INREPORT_SIZE ), // bytes HID_ReportSize(8), // bits HID_Input(HID_Data | HID_Variable | HID_Absolute), //HID_ReportCount(1), //HID_ReportSize(5), //HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(OUTREPORT_SIZE), HID_ReportSize(8), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, }; const BYTE HID_ReportDescriptor3[] = { HID_UsagePageVendor(0x00), HID_Usage(0x01), HID_Collection(HID_Application), HID_UsagePage(HID_USAGE_PAGE_BUTTON), HID_UsageMin(1), HID_UsageMax(3), HID_LogicalMin(0), HID_LogicalMax(1), //HID_ReportCount(3), //HID_ReportSize(1), HID_ReportCount( INREPORT_SIZE ), // bytes HID_ReportSize(8), // bits HID_Input(HID_Data | HID_Variable | HID_Absolute), //HID_ReportCount(1), //HID_ReportSize(5), //HID_Input(HID_Constant), HID_UsagePage(HID_USAGE_PAGE_LED), HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR), HID_LogicalMin(0), HID_LogicalMax(1), HID_ReportCount(OUTREPORT_SIZE), HID_ReportSize(8), HID_Output(HID_Data | HID_Variable | HID_Absolute), HID_EndCollection, }; const WORD HID_ReportDescSize0 = sizeof(HID_ReportDescriptor0); const WORD HID_ReportDescSize1 = sizeof(HID_ReportDescriptor1); const WORD HID_ReportDescSize2 = sizeof(HID_ReportDescriptor2); const WORD HID_ReportDescSize3 = sizeof(HID_ReportDescriptor3);
/* USB Standard Device Descriptor */ const BYTE USB_DeviceDescriptor[] = { USB_DEVICE_DESC_SIZE, /* bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0110), /* 1.10 */ /* bcdUSB */ 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ USB_MAX_PACKET0, /* bMaxPacketSize0 */ WBVAL(0xC251), /* idVendor */ WBVAL(0x1701), /* idProduct */ WBVAL(0x0100), /* 1.00 */ /* bcdDevice */ 0x04, /* iManufacturer */ 0x20, /* iProduct */ 0x42, /* iSerialNumber */ 0x01 /* bNumConfigurations */ }; /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const BYTE USB_ConfigDescriptor[] = { /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bDescriptorType */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ USB_CONFIGUARTION_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE ), 0x04, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */ /*USB_CONFIG_REMOTE_WAKEUP*/, USB_CONFIG_POWER_MA(100), /* bMaxPower */ /* Interface 0, Alternate Setting 0, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints */
USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */ /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(sizeof(HID_ReportDescriptor0)), /* wDescriptorLength */ /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(1), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ //WBVAL(0x0004), /* wMaxPacketSize */ WBVAL(0x0040), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Interface 1, Alternate Setting 0, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x01, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */ /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(sizeof(HID_ReportDescriptor1)), /* wDescriptorLength */ /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ //WBVAL(0x0004), /* wMaxPacketSize */ WBVAL(0x0040), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Interface 1, Alternate Setting 0, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x02, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */ /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(sizeof(HID_ReportDescriptor2)), /* wDescriptorLength */ /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(3), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ //WBVAL(0x0004), /* wMaxPacketSize */ WBVAL(0x0040), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Interface 1, Alternate Setting 0, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x03, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */ /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(sizeof(HID_ReportDescriptor3)), /* wDescriptorLength */ /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(4), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ //WBVAL(0x0004), /* wMaxPacketSize */ WBVAL(0x0040), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* Terminator */ 0 /* bLength */ };
Above is the first part I made, please take a look, any problem with description?
Thanks Jack
Report descriptor If you use report descriptors of the same contents for these four interfaces, you can do with single report descriptor. Define single report descriptor and assign it to the HID descriptors of all four interfaces.
The report descriptor is simplified as follows.
#define INREPORT_SIZE 64 #define OUTREPORT_SIZE 64 const BYTE HID_ReportDescriptor[] = { HID_UsagePageVendor( 0x00 ), HID_Usage( 0x01 ), HID_Collection( HID_Application ), HID_LogicalMin( 0 ), HID_LogicalMaxS( 0xFF ), HID_ReportSize( 8 ), // bits HID_ReportCount( INREPORT_SIZE ), // bytes HID_Usage( 0x01 ), HID_Input( HID_Data | HID_Variable | HID_Absolute ), HID_ReportCount( OUTREPORT_SIZE ), // bytes HID_Usage( 0x01 ), HID_Output( HID_Data | HID_Variable | HID_Absolute ), HID_EndCollection, }; const WORD HID_ReportDescSize = sizeof(HID_ReportDescriptor);
VID/PID on Device descriptor When you modify the device configuration radically, change the VID/PID (at least, PID). This VID/PID is the original one for the example.
WBVAL(0xC251), /* idVendor */ WBVAL(0x1701), /* idProduct */
Windows hold device instance records on its registry. These records maintain information about the device configurations. Unfortunately, they aren't automatically updated when you change the device configuration. New VID/PID pair makes new record on the registry, which matches to your new configuration. If you re-use existing VID/PID, delete the device instance of the VID/PID on the Device Manager once.
In this case, new VID/PID pair is better. Then, both of your modified one and the original one run without conflict on the same PC.
For development, you can use any VID/PID temporarily, unless it doesn't conflict with "registered" VID/PID on your PC. These posts show how to select temporary VID/PID. forum.microchip.com/tm.aspx forum.microchip.com/tm.aspx
When you release your product, get an official VID/PID for your device.
Endpoint addresses for interrupt transfer LPC2368 supposes fixed transfer type for each endpoint. Check it on the datasheet, Chapter 13 - 5. Fixed endpoint configuration For interrupt transfer, the addresses of 1, 4, 7, 10 and 13 are available. Select the four addresses from above series, and assign them to the endpoint descriptors.
Also, this selection of addresses affects to - the endpoint event (USB_EP_EVENT) on usbcfg.h, - the endpoint ISRs, USB_EndPoint4(), USB_EndPoint7(), ... on usbuser.c - the first dummy packet for each endpoint on USB_Configure_Event(), usbuser.c
GetDescriptor() Modify GetDescriptor() in usbcore.c, too, as I showed on this post. http://www.keil.com/forum/docs/thread11649.asp 24-Jan-2008 06:57
On the enumeration, host asks report descriptors over GetDescriptor() If this GetDescriptor() fails, the enumeration also fails.
Tsuneo
Thank you very much, Tsuneo!
Followed your instruction, used youe simplified HID_ReportDescriptor[], and changed my USB_ConfigDescriptor like as following like this:
const BYTE USB_ConfigDescriptor[] = { .... USB_ENDPOINT_DESC_SIZE + /*added other 3 endpoints*/ USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE + USB_INTERFACE_DESC_SIZE + HID_DESC_SIZE + USB_ENDPOINT_DESC_SIZE + ), 0x04, /*Changed to 4 endpoints, bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */ /*USB_CONFIG_REMOTE_WAKEUP*/, USB_CONFIG_POWER_MA(100), /* bMaxPower */ /* Interface 0, Alternate Setting none, HID Class */ ..... copy interface0 cofig, changed bInterfaceNumber to 1,2,3 and USB_ENDPOINT_IN(1) to USB_ENDPOINT_IN(4),USB_ENDPOINT_IN(7),USB_ENDPOINT_IN(10), keep other llines as the same as Interface 0 config /* Interface 1, Alternate Setting none, HID Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x01, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */ /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(sizeof(HID_ReportDescriptor)), /* wDescriptorLength */ /* Endpoint, HID Interrupt In */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(4), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0004), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* added 3rd endpoints*/ /* Endpoint, HID Interrupt In */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x02, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x01, /* bNumEndpoints */ USB_DEVICE_CLASS_HUMAN_INTERFACE, /* bInterfaceClass */ HID_SUBCLASS_NONE, /* bInterfaceSubClass */ HID_PROTOCOL_NONE, /* bInterfaceProtocol */ 0x5C, /* iInterface */ /* HID Class Descriptor */ /* HID_DESC_OFFSET = 0x0012 */ HID_DESC_SIZE, /* bLength */ HID_HID_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0100), /* 1.00 */ /* bcdHID */ 0x00, /* bCountryCode */ 0x01, /* bNumDescriptors */ HID_REPORT_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(sizeof(HID_ReportDescriptor)), /* wDescriptorLength */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(7), /* bEndpointAddress */ USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */ WBVAL(0x0004), /* wMaxPacketSize */ 0x20, /* 32ms */ /* bInterval */ /* added 4th endpoints*/ /* Endpoint, HID Interrupt In */ ... 0x03, /* bInterfaceNumber ... USB_ENDPOINT_IN(10), /* bEndpointAddress */ */ 0x20, /* 32ms */ /* bInterval */ /* Terminator */ 0 /* bLength */ };
any wrong above?
Seems fine.
Does the device still fail on enumeration? Then, to identify the error on the enumeration, watch the bus traffic using a sniffer. Do you have a hardware bus analyzer? If not, download the trial of this software sniffer. This software sniffer can catch the enumeration sequence.
SourceUSB http://www.sourcequest.com/
Compare the enumeration sequence of your device with the KEIL HID example. For these two HID devices, the sequences are the same at least until Set_Configuration.
On which request does your device stop? Any error report on the sniffer? Or the enumeration just stops? - Then, what is the last request?
In this post, I've shown the enumeration sequence of HID device on major OS. "Difference on HID enumeration on Win, Linux and Mac" www.cygnal.org/.../001325.html
Umm.. I have to update above post for new versions of OS.
Thanks Tsuneo! Now, 4 HID devices can be found in device manager. I checked on the USB monitor, I can see config/desc data in from 81,84,87,and 8A, when I insert USB cable, then stop. no my own data into PC. My project use 4 endpoints to send different application data to PC, and PC send command to LPC2368 through 1 endpoint(enpoint0). I will try your way to catch the enumeration sequence
Thanks again
Jack
"Now, 4 HID devices can be found in device manager."
Contrats!! If no yellow "?" on the device instances icon on the Device Manager, the enumeration succeeds. Once enumerated, any software sniffer works. "My project use 4 endpoints to send different application data to PC"
Then, the next step is the host app. As you'll see on the Device Manager, Windows recognize the four interfaces as independent "devices". On the host app, you have to count up all four interfaces as independent HID devices. This post on USB-IF will help you for this task.
"multi-interface device" www.usb.org/.../viewtopic.php
As I said on above USB-IF post, HidD_GetProductString returns the string specified by the iInterface on the HID interface descriptor, when this iInterface is not zero. Then, this iInterface string is available to identify the HID interface.
HidD_GetProductString msdn.microsoft.com/.../ms790920.aspx "and PC send command to LPC2368 through 1 endpoint(enpoint0)."
I don't recommend you to use the default endpoint always to send commands to the device, when the commands are sent repeatedly. For this purpose, append an OUT endpoint to one of the HID interface, and send the commands over this OUT endpoint.
The reasons are twofold, a) Set_Report( OUTPUT ) request over the default endpoint is heavy for the firmware. The handling of Control transfer requires many steps on the firmware.
b) For the command over Set_Report( OUTPUT ) request, no delay is allowed to complete it. The command over Set_Report( OUTPUT ) request should complete when this request finishes. It means that, even while the firmware handles another command, the firmware should do this command. Set_Report( OUTPUT ) request should be applied just to commands of higher priority.
In this topic, I showed the way to add OUT endpoint to HID interface. "LPC2148 usb controller" http://www.keil.com/forum/docs/thread11137.asp 21-Nov-2007 17:02 by Tsuneo Chinzei -- body of modification 21-Nov-2007 17:03 by Tsuneo Chinzei -- continued 21-Nov-2007 23:19 by Tsuneo Chinzei -- interface descriptor fix
Thank you very much Tsuneo. I will do it next week. Have a good weekend!
Hi Tsuneo, I modified my code to make 4 endpoint sending data to PC first, but my firware just sends 64 byte endpoint1 data(data is genrated in GetInReport1()), other 3 endpoint data can not be sent, it looks like GetInReport2() GetInReport3()GetInReport4() are not called.following are waht I modified:
//usbcfg.h #define USB_IF_NUM 5 #define USB_EP_EVENT 0x493// endpoint 0,1,4,7 10??? //usbcore.c switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_INTERFACE: #if USB_HID if ((SetupPacket.wIndex.WB.L == USB_HID_IF_NUM0)|| (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM1)|| (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM2)|| (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM3)) { switch (SetupPacket.bRequest) { case HID_REQUEST_GET_REPORT: if (HID_GetReport()) { EP0Data.pData = EP0Buf; USB_DataInStage(); goto class_ok; } break; ... //hiduser.c BOOL HID_GetReport (void) { int i; /* ReportID = SetupPacket.wValue.WB.L; */ switch (SetupPacket.wValue.WB.H) { case HID_REPORT_INPUT: if (SetupPacket.wIndex.WB.L == USB_HID_IF_NUM0){ GetInReport1(); for(i=0;i<INREPORT_SIZE;i++) EP0Buf[i] = InReport1[i]; } else if(SetupPacket.wIndex.WB.L == USB_HID_IF_NUM1) { GetInReport2(); for(i=0;i<INREPORT_SIZE;i++) EP0Buf[i] = InReport2[i]; } else if(SetupPacket.wIndex.WB.L == USB_HID_IF_NUM2){ GetInReport3(); for(i=0;i<INREPORT_SIZE;i++) EP0Buf[i] = InReport3[i];} else if(SetupPacket.wIndex.WB.L == USB_HID_IF_NUM3){ GetInReport3(); for(i=0;i<INREPORT_SIZE;i++) EP0Buf[i] = InReport3[i]; } break; case HID_REPORT_OUTPUT: return (FALSE); /* Not Supported */ case HID_REPORT_FEATURE: /* EP0Buf[] = ...; */ /* break; */ return (FALSE); /* Not Supported */ } return (TRUE); } void USB_EndPoint1 (DWORD event) { switch (event) { case USB_EVT_IN: GetInReport1(); USB_WriteEP(0x81, InReport1, sizeof(InReport1)); break; } } void USB_EndPoint4 (DWORD event) { switch (event) { case USB_EVT_IN: GetInReport2(); USB_WriteEP(0x84, InReport2, sizeof(InReport2)); break; } } void USB_EndPoint7 (DWORD event) { switch (event) { case USB_EVT_IN: GetInReport3(); USB_WriteEP(0x87, InReport3, sizeof(InReport3)); break; } } void USB_EndPoint10 (DWORD event) { switch (event) {case USB_EVT_IN: GetInReport4(); USB_WriteEP(0x8A, InReport4, sizeof(InReport4)); break; } }
Thank you very much! Jack