Hi this is my transmit function for my Bulk Device:
static unsigned long
Transmit_USB(USBbuffer Data,int size)
{
unsigned long ulLoop, ulCount;
unsigned long ulWriteIndex;
tUSBRingBufObject sTxRing;
//
// Get the current buffer information to allow us to write directly to
// the transmit buffer (we already have enough information from the
// parameters to access the receive buffer directly).
//
USBBufferInfoGet(&g_sTxBuffer, &sTxRing);
//
// How many characters can we process this time round?
//
ulCount = size;
//
// Set up to process the characters by directly accessing the USB buffers.
//
ulWriteIndex = sTxRing.ulWriteIndex;
for(ulLoop = 0 ; ulLoop < ulCount;ulLoop++ )
{
g_pucUSBTxBuffer[ulWriteIndex] = Data.data[ulLoop];
ulWriteIndex = ulWriteIndex + 1;
ulWriteIndex = (ulWriteIndex == BULK_BUFFER_SIZE) ? 0 : ulWriteIndex;
}
//
// We've processed the data in place so now send the processed data
// back to the host.
//
USBBufferDataWritten(&g_sTxBuffer,size);
return(ulCount);
}
The bottleneck of my USB protocol is that as you can see , I write byte individually into the TX buffer.
Can we write block of byte instead of byte per byte into the buffer?