Why are data packets sent from Cypress Control Center/ Custom Host Application not committed to GPIF interface?
Consider the following scenario for USB 3.0:
- Consider an AUTO DMA channel configured as below:
dmaCfg.size = 16384; //Buffer size is 16KB
dmaCfg.count = CY_FX_SLFIFO_DMA_BUF_COUNT_U_2_P;
dmaCfg.prodSckId = CY_FX_PRODUCER_USB_SOCKET; //Producer : USB
dmaCfg.consSckId = CY_FX_CONSUMER_PPORT_SOCKET; //Consumer : GPIF
- In this configuration, the buffer would be committed to GPIF when any of the following conditions are met:
- Entire 16 KB buffer is filled by USB.
- A partial packet is received from USB (Note: When this happens the amount of data filled in the buffer will not be a multiple of 1024 bytes for USB 3.0 and 512 bytes for USB 2.0).
- A zero-length packet is received from USB.
So, design your host application considering these three conditions:
For instance, if OUT transfer needs to be made with X bytes, then:
- If X < 16 KB and (X % 1024) != 0, then on completion of X bytes nothing needs to be done.
- If X == 16 KB, then on completion of X bytes nothing needs to be done.
- If X > 16 KB, then let Y = (X % 16 KB). Now:
i) If Y == 0, then on completion of X bytes nothing needs to be done.
ii) If Y < 16 KB and (X % 1024) == 0, then on completion of X bytes, a zero-length packet must be sent so that the buffer in the device gets committed to GPIF.
- To send a zero length packet, call the XferData() API with ‘len’ parameter set to zero.
For the usage of XferData(), see the API Guide available in C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\library after installing FX3-SDK