AnsweredAssumed Answered

How to transfer data across two EZ-KITs through USB?

Question asked by PrasanthR Employee on Jul 26, 2011

I had written a USB Host example for my sensor device sometime back. Recently I stripped out the device mode bulk class example and host mode shell browser example, and created a setup to perform simple data transfer across two KITs with one actiing as Device and other as Host. I thought of sharing the same here.

 

The codes are attached herewith and have been tested across two BF527 0.2 Si Kits with VDSP.5.0.9. Application data transfer happens through BULK IN and OUT endpoints.You need to run the device first and then host.

 

The device code uses ADI Bulk Class, and has two BULK endpoints for data in and data out. The descriptors are programmed through VSBulkConfigure() function in the adi_usb_bulkadi.c, when the application calls the command: ADI_USB_CMD_CLASS_CONFIGURE.  Device has to wait for a command block from host to call the right API for write or read.

 

Host reuses the Endpoint IDs to communicate with device:

 

g_ReadEpID  = 0x5;
g_WriteEpID = 0x6;

 

While development, host application make peek in to device descriptors after enumeration, by turning on macros USB_OTG_PRINT_DESCRIPTOR and USB_DEBUG for USB driver libraries and rebuilding the same. If you are sure about the object IDs and endpoints (see the function ParseConfigurationMemory() in adi_usb_otg.c), you could just do something like below:

 

#ifdef DEBUG_DESCRIPTORS
  PDEVICE_OBJECT pDevO;
  PCONFIG_OBJECT pCo;
  PINTERFACE_OBJECT pIo;
  PENDPOINT_OBJECT pEpO1,pEpO2;   
 
  adi_usb_GetObjectFromID(1,USB_DEVICE_OBJECT_TYPE,(void*)&pDevO);
  adi_usb_PrintDeviceDescriptor(pDevO); printf("\n\n");
  adi_usb_GetObjectFromID(1,USB_CONFIGURATION_OBJECT_TYPE,(void*)&pCo);
  adi_usb_PrintConfigDescriptor(pCo);printf("\n\n");
  adi_usb_GetObjectFromID(0,USB_INTERFACE_OBJECT_TYPE,(void*)&pIo);
  adi_usb_PrintInterfaceDescriptor(pIo);printf("\n\n");
  adi_usb_GetObjectFromID(g_ReadEpID,USB_ENDPOINT_OBJECT_TYPE,(void*)&pEpO1);
  adi_usb_PrintEndpointDescriptor(pEpO1);printf("\n\n");
  adi_usb_GetObjectFromID(g_WriteEpID,USB_ENDPOINT_OBJECT_TYPE,(void*)&pEpO2);
  adi_usb_PrintEndpointDescriptor(pEpO2);printf("\n\n");
#endif

 

Common functions like WriteMemory() and ReadMemory() are used for data transfer. Host uses SendCommand(), while device uses ReadCommand().

 

Please refer to the below references for further details and more accurate info of API usage.

 

--Prasanth.

 

Further reference:

 

Host example: ...\Blackfin\Examples\ADSP-BF527 EZ-KIT Lite\Services\File System\VDK\shell_browser

 

Device example: ...\Blackfin\Examples\ADSP-BF527 EZ-KIT Lite\Drivers\usb\bulk_loopback_app

 

Driver Docs: ...\Blackfin\docs\drivers\usb

 

USB Descriptors: http://www.beyondlogic.org/usbnutshell/usb5.shtml

 

Here are some screenshots:

 

Device: 

Device.jpg

Host:

 

Host.jpg

Descriptors:

 

USB_Descriptors.jpg

Attachments

Outcomes