AnsweredAssumed Answered

LPC4330 USB device response to IN bulk endpoint

Question asked by Venkat Vallapaneni on May 21, 2017
Latest reply on Jun 8, 2017 by jeremyzhou


I have set USB1 as device with IN and OUT bulk endpoints.

When PC requests URB_BULK in packet with URB length as 0x583e0, my response is only 0xf000 (I respond using WriteEP method).

When I look at my response packet, I see that URB length is 0xf000 and data length is 0xf000.

I expect URB length to be 0x583e0 and data length as 0xf000.

Please let me know why URB length is changed to actual length from the requested length.

Looks like my app (which is a pre-compiled library from 3rd party) expects URB length as requested length in response.


On side-note, I noticed that if number of bytes to write is 0x8000 to WriteEP function, it is sending null packet!

so my response of 0xf000, I split to three packets: First I caled WriteEP with 0x7FC0 as number of bytes to write and in my EP handler, I called WriteEP with 0x7040 and then WriteEP with 0x0 (null packet to terminate).


// My EP handler function...

// First WriteEP with 0x7FC0 happens somewhere else in the core before URB_BULK in packet

    static uint8_t pkt_cnt = 0;
    if(pkt_cnt == 0) {
        USBD_API->hw->WriteEP(hUsb, 0x82, g_data+0x7FC0,0x7040);
    } else if(pkt_cnt == 1) {
        USBD_API->hw->WriteEP(hUsb, 0x82, g_data,0x0);
    } else {
        pkt_cnt = 0;
    return LPC_OK;