3 Replies Latest reply on Oct 18, 2017 6:24 PM by DoBa_1705086

    Combined USB UART and HID Keyboard


      I want to configure the USBFS on a PSOC5 to simultaneously act as both a HID keyboard and as a USBUART (CDC) device.  I have succeeded at making both the USBUART and the HID Keyboard configurations work independently.  However, I cannot get both to work simultaneously.  My intent is to use the HID Keyboard interface to send keystroke data back to the UBS Host (PC or Mac) while the USBUART interface is used as a separate channel for application configuration and diagnostics.


      I have attached a export of my most recent USB Descriptor root in xml format.  I have the necessary Interface Association Descriptor to link the CDC Comm & Data interfaces together.  A additional interface descriptor for the HID keyboard follows the USBUART entries.


      I found a Cypress document that described a similar effort, but it was written before the PSOC Creator IDE could create Interface Association Descriptors - so it's rather outdated and didn't help me achieve the desired result.


      What am I doing wrong to get both the USBUART and HID Keyboard to enumerate and operate simultaneously?

        • 1. Re: Combined USB UART and HID Keyboard

          I have tried to make a composite device on my CY8CKIT-050 EVK.


          1) Put a USBUART component on the CYSCH file to be used as the base component.

          2) Remove the "Device Descriptor" node on the "Device Descriptor"

          3) Import your XML file into the USBUART component.

          4) Modified the descriptor.

          4-1) Modify the "Device Descriptor" node as follows. The Device Class/Subclass must have EF/02 if an Interface Association Descriptor is used.


          4-2) Remove the Interface Association Descriptor for the HID interface.


          5) Write a simple code on main.c

          #include "project.h"
          int main (void) {
              CyGlobalIntEnable; /* Enable global interrupts. */
              /* Place your initialization/startup code here (e.g. MyInst_Start()) */
              USBUART_Start(0, USBUART_3V_OPERATION);
              for (;;) {
                  /* Place your application code here. */
                  while (USBUART_GetConfiguration() == 0);
                  for (;;) {
                      if (USBUART_IsConfigurationChanged()) {
                      USBUART_PutString("HELLO WORLD\r\n");

          The USBUART-RX and the HID are not used in this example.


          6) Build and Program the Project and connect the PSoC 5LP to PC.

          7) If a driver is required for the CDC device, use the INF file in the Generated_Source/PSoC5/USBUART directory.




          • 2. Re: Combined USB UART and HID Keyboard

            This is an additional information.


            "USB Device Viewer" (usbview.exe) is useful to confirm if the descriptor is valid.  The "USB Device Viewer" is contained in the "Debugging Tools for Windows" provided by Microsoft.


            When your original XML file is attempted to the USBUART component, you will see some ERRORs like followings.


                      ===>Device Descriptor<===
            bLength:                           0x12
            bDescriptorType:                   0x01
            bcdUSB:                          0x0200
            bDeviceClass:                      0x02
            *!*ERROR: device class should be Multi-interface Function 0xEF
                      When IAD descriptor is used
            bDeviceSubClass:                   0x02  -> This is the Common Class Sub Class
            bDeviceProtocol:                   0x00
            *!*ERROR: device Protocol should be USB IAD Protocol 1
                      When IAD descriptor is used
            bMaxPacketSize0:                   0x08 = (8) Bytes
            idVendor:                        0x04B4 = Cypress Semiconductor
            idProduct:                       0x8051
            bcdDevice:                       0x0000

            There are two ERRORs saying ...

            The DeviceClass must be 0xEF when Interface Association Descriptor (IAD) is used.

            The DeviceProtocol must be 0x01 when IAD is used.


                      ===>IAD Descriptor<===
            bLength:                           0x08
            bDescriptorType:                   0x0B
            bFirstInterface:                   0x02
            bInterfaceCount:                   0x01
            *!*ERROR:  bInterfaceCount must be greater than 1 
            bFunctionClass:                    0x03  -> HID Interface Class
            bFunctionSubClass:                 0x00
            bFunctionProtocol:                 0x00
            iFunction:                         0x00

            There is one ERROR saying...

            The InterfaceCount must be greater than 1.  In this case this IAD is no longer needed.




            1 of 1 people found this helpful
            • 3. Re: Combined USB UART and HID Keyboard



              Thank you so much for the thorough and rapid reply!  I especially appreciate the tip regarding the Microsoft USB Device Viewer tool.  This has "enabled me to fish for food" (solve my own future issues) rather than just having "given me a fish for today" (told me the solution to this specific problem).


              I was able to immediately apply the changes you outlined and as indicated by the USB Device Viewer tool in my PSOC 5 project.  I then rebuilt and downloaded the project with absolutely no other changes and everything works as desired.


              *****  - a Five Star review, question answered in full! 


              Thanks again,

              Doug Bartlett