UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor t-nehada
Visitor
365 Views
Registered: ‎04-25-2018

Receive a USB data buffer using ep0

Hi all,

I am using this example to manage the USB on my device:

https://github.com/Xilinx/embeddedsw/blob/master/XilinxProcessorIPLib/drivers/usbps/examples/xusbps_intr_example.c

 

Now I try to send a SetFeature command over hid(using HidD_SetFeature) from the host side.

So to do that, because features commands arrived to the end-point 0, I changed the function XUsbPs_Ep0EventHandler() to hold the data from RX:

 

case XUSBPS_EP_EVENT_DATA_RX:
		{
			Status = XUsbPs_EpBufferReceive(InstancePtr, EpNum, &BufferPtr, &BufferLen, &Handle); 

			if (XST_SUCCESS == Status)
			{
				// My changes start
				u8* pRecvData = NULL;
				if ((REPORT_ID__NCP_INOUT_15 == BufferPtr[0]))
				{
					Xil_DCacheInvalidateRange((unsigned int)BufferPtr, BufferLen);
					pRecvData = (u8*)MM_RequestMemory_Original(MM_MEMORY_TYPE__1KB, TRUE);
					if (pRecvData != NULL)
					{
						memcpy(pRecvData, BufferPtr, BufferLen);
						InsertQueue_USBData_receive(EpNum, pRecvData, BufferLen, Handle);
					}
				}
				// My changes end
				XUsbPs_EpBufferRelease(Handle);
			}
			break;
		}

 

And I have two questions:

  1. This is the right way to do that? maybe I need to copy the buffer from another place?
  2. When I try to send many commands in a sequence, sometimes the buffer arrived with zeros values(Only the values in buffer of data. The length is obtained right).

 

Someone saw that problem and can pour me some light?

 

Thank you very much!

Netanel.

 

 

0 Kudos