Content originally posted in LPCWare by vitah on Tue Mar 12 01:15:11 MST 2013
wlamers,
Let try Project Device Bandwidth Test located at "applications\projects\Project_DeviceBandwidthTest".
According to your idea, the descriptor in project should be modified a little as below:
-------------------------------------
...
.VS_DataInEndpoint =
{
...
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = VENDOR_SPECIFIC_IO_EPSIZE,
.PollingIntervalMS = 0x8
},
.VS_DataOutEndpoint =
{
...
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = VENDOR_SPECIFIC_IO_EPSIZE,
.PollingIntervalMS = 0x8
},
...
---------------------------------------------
- Take a look at DeviceBandwidthTest.c, function USBForegroundTask(). This function will be called by SysTick_Handler every 1ms, this period can be adjusted in main. This function is created to check there is any data available in EP buffer and processes it.
- Place your communication protocol inside this function.
- To check that data is available in OUT EP buffer, use these steps:
+ Select OUT EP
Endpoint_SelectEndpoint(VENDOR_SPECIFIC_OUT_EPNUM);
+ Get number of bytes are in buffer
if (Endpoint_BytesInEndpoint()== USB_DATA_BUFFER_TEM_LENGTH){
+ Read and process your data
Endpoint_Read_Stream_LE();
+ Close transfer
Endpoint_ClearOUT();
- To transfer data to host, use these steps:
+ Select IN EP
Endpoint_SelectEndpoint(VENDOR_SPECIFIC_IN_EPNUM);
+ Check whether there is a room for inserting new data into IN EP buffer
if (Endpoint_IsINReady())
{
+ Push your data into FIFO
Endpoint_Write_Stream_LE
+ Make the data ready for sending
Endpoint_ClearIN();
Let try!