i all,
I am working with Keil for software development of my custom board which is based on LPC2368 device.
I could run USBHID and USBaudio code samples of keil now when I want to change length of data for EP1 and send a string instead of one byte it won't send the stream anyway it has some problem with the length of data?! while I saw that Ep1 max packet size is defined 64bytes?!..
can anybody help me with this issue.
below I copied codes:
/* * USB Endpoint 1 Event Callback * Called automatically on USB Endpoint 1 Event * Parameter: event */
void USB_EndPoint1 (DWORD event) { BYTE str[] = {"This is a test for USB2.0 Connection Speed."}; switch (event) { case USB_EVT_IN: // GetInReport(); // USB_WriteEP(0x81, &InReport, sizeof(InReport)); USB_WriteEP(0x81, &str[0], sizeof(str)); break; } }
DWORD USB_WriteEP (DWORD EPNum, BYTE *pData, DWORD cnt) { DWORD n;
USB_CTRL = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
TX_PLENGTH = cnt;
for (n = 0; n < (cnt + 3) / 4; n++) { TX_DATA = *((__packed DWORD *)pData); pData += 4; }
delay_ms(1); USB_CTRL = 0;
WrCmd(CMD_SEL_EP(EPAdr(EPNum))); WrCmd(CMD_VALID_BUF);
return (cnt); }
Are you working on HID example or audio? Maybe HID... Audio can't play the string :-)
You have to change the report descriptor, too. Also, you ignore "switch (event) { case USB_EVT_IN:" but it's wrong. USB_EndPoint1() is called by both IN and OUT endpoint. You don't need to expand the contents of USB_WriteEP() there. Just call USB_EndPoint1() as the example does.
See this topic. http://www.keil.com/forum/18571/
Either LPC2148 or LPC2368, keil example is (almost) the same.
Tsuneo
Hi, Thank you for your consideration and comment. First I should tell that I am not aware of report descriptor, where is it? what is it related to? The second issue is that I didn't comment or ignore anything in the code it is just copied from the original source file. Today , I read more about endpoints and found out that we can specify the maximum packet size which every EP can send or receive and when I looked at the mentioned parameter for EP of this example I saw that wMaxPacketSize is 4(WBVAL(0x0004)) for this EP -take a look at the usbdesc.c file in the HIDUSB folder- then I changed it to 0x40-the maximum packet size for each EP- and recompiled the code again but it didn't work I don't know what is the issue with this simple change ?! I may need to change other variables too or I may only need to recheck all conditions and changes again.
Best Regards, Hossein
Ah, I see. You didn't ignore "switch (event)" on the code, but you ignored forum regulation to post code. And then, the forum engine mixes up your code lines.
Anyway, read my post of 10-May-2011 19:26 GMT on this topic. http://www.keil.com/forum/18571/ I'm bored to answer to quite alike questions.
99% of the code on keil USB examples are same for MCUs of NXP LPC family. Just the PINSEL and USB clock settings are different.
Hi, I couldn't find USB_HID_REPORT_IN & USB_HID_REPORT_OUT in my source files of HIDUSB project. I only found some parameters which look like the one has been mentioned in the thread and that is : HID_ReportCount(3), HID_ReportSize(2),
which are related to the HID_ReportDescriptor array defined in usbdesc.c file. Would you please tell me which parameters I should change for LPC2368 in usb source files?
thanks, Hossein
Ah, this one is more alike to the LPC2368 example than above post. The descriptors are same. http://www.keil.com/forum/11137/
Ah, this post is more alike to the LPC2368 example than above post. The descriptors are same. http://www.keil.com/forum/11137/
> I couldn't find USB_HID_REPORT_IN & USB_HID_REPORT_OUT > in my source files of HIDUSB project.