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, };
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