How to Transfer Data Across Two EZ-KITs via USB

Document created by PrasanthR Employee on Aug 25, 2011Last modified by jobo23 on Dec 21, 2011
Version 2Show Document
  • View in full screen mode

The attached code sets up two ADSP-BF527 EZ-KITs with one acting as  a USB Device and the other as a USB Host. This has been tested on revision 0.2 silicon with VisualDSP++ 5.0 Update 9. Application data transfer happens through BULK IN and OUT endpoints.You need to run the device first and then the host.

 

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

 

The Device has the opened endpoints information, but the host doesn't. The following may be employed to retrieve this data at the Host end:

 

1.  The Host reuses the known/published Endpoint IDs to communicate with the Device:

 

g_ReadEpID  = 0x5;
g_WriteEpID = 0x6;

 

2.  It is however possible to retrieve the complete descriptor info, including which endpoints are configured at the Device. During enumeration, the event adi_usb_otg_SetConfiguration(1) is called to set the configuration number to be used by the Device. This function uses adi_usb_GetObjectFromID  to get the configuration object which the Host is going to activate for the Device. The Host stores this configuration object as its active configuration Object. This configuration object can be used to find out which BULK Endpoints are currently used by the Device.

 

case ADI_USB_OTG_EVENT_ENUMERATION_COMPLETE:     
          
         printf("\nenumeration event\n");
         usberrorcheck(adi_usb_otg_SetConfiguration(1));     


         pDevO = (PDEVICE_OBJECT)pArg;
         pCfgO = pDevO->pConfigObj;
         pEpO  = pCfgO->pActiveEpObj;
         pActiveEpO = pEpO;
        
         while(pActiveEpO != NULL)
         {
             /* BULK endpoints ONLY */
             if(pActiveEpO->pEndpointDesc->bAttributes == USB_BULK_MODE)
             {
                 if((pActiveEpO->pEndpointDesc->bEndpointAddress & 0x80))
                 {
                     g_ReadEpID   = pActiveEpO->ID;
                 }
                 else
                 {
                     g_WriteEpID   = pActiveEpO->ID;
                 }
             }

 

            pActiveEpO = pActiveEpO->pNextActiveEpObj;
         }
        
            g_bUsbenumerated = TRUE;
            break;

 

3.. Turn on the USB_OTG_PRINT_DESCRIPTOR and USB_DEBUG macros for USB driver libraries and rebuild them. This prints out the complete descriptor info to the console.

 

4. If the object IDs and endpoints (see the function ParseConfigurationMemory() in the adi_usb_otg.c file) are already known, you could do something similar to what the above macros do. If the info is not known, use method #2 to retrieve it and pass it to adi_usb_PrintDeviceDescriptor();


#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. The Host uses SendCommand() while the 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

 

This FAQ was generated from the following discussion: How to transfer data across two EZ-KITs through USB?

Attachments

Outcomes