lpcware

Lpc4337 USB1 host: problem sending 64 bytes to usb full speed device

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by PeterZos on Thu Jun 11 00:45:43 MST 2015
I am using LPCUSBLib from LPCOpen v2.16 on lpc4337 to communicate with usb modem device.
USB1 is properly configured and the usb modem is enumerated as full speed device.
After configuring the bulk in and bulk out pipe i can communicate with modem - send AT command to modem and receive response,
make an http request through modem's tcp stack and receive response.
The problem arise when I want to send exactly 64 (128,192,..) bytes to modem.
In that case it looks that modem receive it after sending the next byte.

Pseudocode:
if (HcdGetPipeStatus(PipeInfo[corenum][pipeselected[corenum]].PipeHandle) == HCD_STATUS_OK)
{
fill the buffer with 64 bytes
HcdDataTransfer(PipeInfo[corenum][pipeselected[corenum]].PipeHandle,
PipeInfo[corenum][pipeselected[corenum]].Buffer,
PipeInfo[corenum][pipeselected[corenum]].ByteTransfered,
NULL /* FIXME &PipeInfo[pipeselected].ByteTransfered*/);
PipeInfo[corenum][pipeselected[corenum]].StartIdx = PipeInfo[corenum][pipeselected[corenum]].ByteTransfered = 0;
}
As a result I get the HcdIrqHandler called which in turn calls AsyncScheduleIsr where the status of the respective iTD is changed to OK


I know that on full speed device the MaxPacketSize is exactly 64 byte.
Should i send zero-length packet in case transfer is an integer multiple of MaxPacketSize?
How to send ZLP? The HcdDataTransfer function checks for zero length transfer and returns

if ((buffer == NULL) || (length == 0)) {
ASSERT_STATUS_OK_MESSAGE(HCD_STATUS_PARAMETER_INVALID, "Data Buffer is NULL or Transfer Length is 0");
}

In case I ignore the above if statement, iTD stays queued forever

Any suggestion how to send packet that are integer multiple of MaxPacketSize or how to send ZLP packet will be appreciated

Regards

Outcomes