I am implementing a driver for an USB isochronous device in a latency critical application. For my tests I am using the Cypress FX3 kit (USBIsoSourceSink example). The endpoint is setup to supply data at bInterval 1 (transfer every 125usec microframes ~= 8kHz).
My data packages are very small (32bytes/pck). I am allowing 8 packages pr transfer.
Now, I am trying to demonstrate the 8kHz transfer rate in order to achieve a 125usec transfer latency.
For the IN endpoint my approach is this:
I have a vector of 4 transfer objects, each with a KOVL_HANDLE handle
and a KISO_CONTEXT*
context:
struct Xfer {
UCHAR buffer[MAX_PACKETS_PR_XFER * PACKET_SIZE_IN];
KOVL_HANDLE overlapHandle;
KISO_CONTEXT* isoCtx;
Xfer(KOVL_POOL_HANDLE &poolHandle) {
IsoK_Init(&isoCtx, MAX_PACKETS_PR_XFER, 0); // StartFrame 0 = Asap
IsoK_SetPackets(isoCtx, PACKET_SIZE_IN);
OvlK_Acquire(&overlapHandle, poolHandle);
}
};
I submit all 4 transfers by OvlK_ReUse(xfer.overlapHandle)
and
UsbK_IsoReadPipe(
usbHandle,
pipeID_IN,
xfer.buffer,
sizeof(xfer.buffer),
(LPOVERLAPPED)xfer.overlapHandle,
xfer.isoCtx);
While the program is running I point to a transfer in the cue and OvlK_Wait(xferINiter->overlapHandle, 100, KOVL_WAIT_FLAG_RELEASE_ON_TIMEOUT, &transferred);
.
Then I process (save) the data from the transfer and resubmit it (OvlK_ReUse
and UsbK_IsoReadPipe
) before I point to the next transfer in the cue, wrapping around.
This all seems to work. My problem is that I process 1000 transfers per second while I am expecting 8k. It seems that I am only getting the 1ms frames and not the microframes. I can easily get more packages per transfer, but my application is latency critical.
What am I doing wrong? Does libusbK have a limitation for only handling 1ms frames?