This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Keil functions for writing in USB EP1 doesn't work?!

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

Parents
  • 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

Reply
  • 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

Children