Adding Communication Device Class Interface to FX3 Firmware - KBA229099

Version 2

    Author: KandlaguntaR_36            Version: **

     

    Translation - Japanese: サイプレスタイトル - KBA229099 - Community Translated (JA)

    Question 1:
    How can I add Communication Device Class (CDC) interface to vendor class application?

    Answer:
    All USB devices have a hierarchy of descriptors, which describes the device information to the host. The common USB descriptors are:

    • Device Descriptors: USB Device descriptor includes information such as USB version, Product, and Vendor IDs to load appropriate drivers and the number of possible configurations the device can have.
    • Configuration Descriptors: The configuration descriptor specifies values such as the amount of power used by a configuration, whether the device is bus-powered or self-powered, and the number of interfaces.
    • Interface Descriptors: Interface descriptor could be a header or grouping of the endpoints into a functional group performing a single feature of the device.
    • Endpoint Descriptors: Endpoint descriptors are used to describe endpoints other than endpoint zero. The host will use the endpoint information to determine the bandwidth requirements of the bus.
    • Interface Association Descriptors: Interface Association descriptor allows the device to group interfaces belonging to a function.

    Adding CDC Interface to FX3 Vendor Class Firmware

    Adding CDC interface to FX3 vendor class firmware includes:

    • Modifying Configuration Descriptor
    • Modifying Interface Descriptor
    • Modifying Endpoint Descriptor
    • Handling CDC Requests and Adding CDC Functionality

     

    Modifying Configuration Descriptor

     

    1. Modify the Length of this descriptor and all sub descriptors field with the total length of configuration descriptor and all interface descriptors.
    2. Update the Number of interfaces field with the total number of interfaces after adding the CDC interface.

    Figure 1 shows an example of adding a CDC interface to Slave FIFO in SDK.

     

    Figure 1. Adding CDC Interface to Slave FIFO

    Note: These changes apply for SuperSpeed Descriptors for USB3.0. You can make similar changes for High Speed descriptors, if the application is for USB 2.0.

     

    Modifying Interface Descriptor

     

    1. The Interface number field in the descriptor should be in sequence.

    For this example, if the Interface number of the Slave FIFO interface is 0x00, and if the CDC interface descriptors are added after the Slave FIFO interface descriptors, the numbering of CDC interfaces should be as follows:

        • Communication Interface Descriptor – 0x01
        • Data Interface Descriptors – 0x02

     

    2. After the interface descriptors and endpoints descriptors for the interface used for Slave FIFO, add the descriptors related to the CDC interface. As per CDC specification, the CDC device should have two interfaces: Communication Interface Descriptor and Data Interface Descriptor. Interface Association Descriptor is used to bind both the CDC interfaces. The binding is determined by I/f number of first CDC i/f and Number of CDC i/f.

    Figure 2. Adding Interface Association Descriptor

    Modifying Endpoint Descriptor

    There are no changes to the endpoint descriptors. Make sure the endpoint address mentioned in the Endpoint address and description field used for each interface is unique.

    Handling CDC Requests and Adding CDC Functionality

    The changes mentioned here add the functionality of UsbUart example to Slave FIFO example from the SDK. By enabling #define cdc in the firmware available with this Knowledge Base Article (KBA), the following changes will be added to the default Slave FIFO (cyfxslfifosync.c) firmware:

     

    1. Create a thread for handling CDC device functionality.

    2. Handle the following Communication Device Class requests in the USB setup callback function:

      • SET LINE CODING
      • GET LINE CODING
      • SET CONTROL LINE STATE

    3. Create the DMA channel for transfers between UART block and USB block.

    4. Configure the endpoints for the channel created.

    5. After building the project, {project_name}.img file will be generated and saved in the respective project folder path. Program FX3 with this .img file.

    6. The device will not show up in the control center due to improper driver binding.

     

    If the CDC interface is automatically bound to the driver, follow these steps to manually bind the drivers to the slavefifo (vendor) interface: 

    1. On programming FX3 with the firmware, the driver will not be bound properly. Figure 3 shows the Device Manager with improper driver binding.

    Figure 3. Improper Driver Binding

    2. To bind the Cypress cyusb3 driver properly, uninstall the previously bound driver.

     

    3. Reset the device and reprogram with the .img file. Figure 4 shows the device manager after reprogramming.

     

    Figure 4. Uninstalling Driver Bound to FX3

    4. Bind the cyusb3 driver to FX3 that appears in the Other Devices section of the Device Manager. Choose the model Cypress FX3 USB StreamerExample Device. After the driver successfully binds to the FX3 device, the device appears in the control center. Now both interfaces, interface associated with Slave FIFO and CDC interface, can be used simultaneously.  For more details on how to forcefully bind the driver to FX3 interface, see Driver Binding.

     

    Figure 5. After Manually Binding the Driver

    If the CDC interface does not bind to the driver automatically, both interfaces can show up in Other devices section and should be manually bound to their respective drivers.

    Figure 6. CDC interface Not Bound Automatically

    To bind the correct drivers to both interfaces, check the device properties in the device manager to know the class of both interfaces.

    Figure 6. Device Properties

     

    If the Value is Class ff (vendor class), follow step 4 for binding cyusb3 driver to slavefifo (vendor) interface

    If the Value is Class 02 (CDC class), follow these steps to bind Cypress driver to the CDC interface:

    1. Download and install CypressDriverInstaller_1.exe from this link. After default installation, the Cypress USB-Serial Driver folder will be created in the following path: C:\Program Files (x86)\Cypress.
    2. In the Device Manager, right-click FX3 from Other Devices and click Update Driver Software.
    3. In the pop-up window, click Browse my computer for driver software.
    4. Click Let me pick from a list of device drivers on my computer.
    5. Choose Show All Devices and click Next.
    6. Click Have Disk….
    7. For win7, x64 PC, in the pop-up window, click Browse… and go to: C:\Program Files (x86)\Cypress\Cypress USB-Serial Driver\DriverBinary\CDC_Driver\bin\win7\x64.
    8. Select the CypressSerial.inf file and click Open.
    9. Click OK. In the next window, select USB to UART Adapter and click Next.
    10. In the Update Driver Warning window, click Yes. Now, one of the CDC interface will appear as USB to UART Adapter in the Device Manager. 
      Now, another device Virtual Serial Port will appear under the Other devices section of the Device Manager.
    11. Right-click Virtual Serial Port and select Update Driver Software.
    12. Follow steps 3 to 8.
    13. Select USB Serial Port and click Next.
    14. In the Update Driver Warning window, select Yes. USB Serial Port (COM x) (where, x can be any number) will appear under the Ports (COM & LPT) section of the Device Manager. Now, you can check the simultaneous working of the CDC interface by opening a Uart Terminal Application (TeraTerm) and the Slave FIFO application.

    Note: The CDC interface will automatically bind to Microsoft driver for Windows 10 PC and will appear under Ports (COM & LPT). If the CDC interface is to be bound to the Cypress driver, click the USB Serial Port (COM x) and follow steps 1 to 14.

    Question 2: How can I add Communication Device Class interface to a UVC application?

    To add CDC interface to UVC application, see the firmware attached in this thread.

    The firmware is for CX3 application. Similar changes need to be done for UVC applications on FX3 device.