6 Replies Latest reply on Jan 24, 2020 11:54 AM by MaGa_4619181

    CY8CKIT-062: Connecting request to composite device

    MaGa_4619181

      Hi,I have a USB device using both a CDC and an Audio interface with Interface Association Descriptor. This is my init function:

       

      CommPort *comportInit()
      {
          CommPort *port = NULL;
      
      
          Context *ctx = getNewCtx();
      
      
          if (ctx != NULL &&
              Cy_USB_Dev_Init(USBFS0, &usb_0_config, &ctx->usbfsDevDrvContext,
                              &usb_devices[0], &usb_devConfig, &ctx->usbDevContext) == CY_USB_DEV_SUCCESS &&
      audioCommInit(ctx) &&
      cdcCommInit(ctx) /*&&
          audioCommunicationInit(ctx)*/)
          {
              /* Initialize USB interrupts */
              bool res = Cy_SysInt_Init(&UsbDevIntrHigh, &USBUART_IsrHigh) == CY_SYSINT_SUCCESS;
              res = res && Cy_SysInt_Init(&UsbDevIntrMedium, &USBUART_IsrMedium) == CY_SYSINT_SUCCESS;
              res = res && Cy_SysInt_Init(&UsbDevIntrLow, &USBUART_IsrLow) == CY_SYSINT_SUCCESS;
      
      
              /* Enable the USB */
              NVIC_EnableIRQ(UsbDevIntrHigh.intrSrc);
              NVIC_EnableIRQ(UsbDevIntrMedium.intrSrc);
              NVIC_EnableIRQ(UsbDevIntrLow.intrSrc);
      
      
              /* Enable global interrupts. */
              __enable_irq();
      
      
              /* Make device appear on the bus. This function call is blocking, it waits till the device enumerates */
              if (res && Cy_USB_Dev_Connect(true, CY_USB_DEV_WAIT_FOREVER, &ctx->usbDevContext) == CY_USB_DEV_SUCCESS)
              {
                  initFctDriver(ctx);
                  port = &ctx->port;
      
      
              }
          }
      
      
          return port;
      }
      

       

      And this is my audioInit:

      bool audioCommInit(Context *ctx)
      {
           bool retStatus = false;
      
      
           if (Cy_USB_Dev_Audio_Init(NULL, &ctx->usbfAudioContext, &ctx->usbDevContext) == CY_USB_DEV_SUCCESS)
           {
                retStatus = true;
           }
      
      
           USBCOMM_INTERFACE_FUNCTIONS intfFunc =
          {
              .disableIn = AudioIn_Disable,
              .enableIn = AudioIn_Enable,
          };
      
      
           UsbComm_RegisterInterfaceFunctions(&intfFunc);
      
      
          registerAudioCallback(ctx);
      
      
          Cy_SysInt_Init(&UsbDevIntrHigh, AudioIn_IsrHandler);
      
      
          Cy_USBFS_Dev_Drv_RegisterEndpointCallback(USBFS0, AUDIO_STREAMING_OUT_ENDPOINT, NULL, &ctx->usbfsDevDrvContext);
      
      
          Cy_USB_Dev_OverwriteHandleTimeout(AudioApp_UsbDelay, &ctx->usbDevContext);
      
      
           return retStatus;
      }
      

       

      And this is the CDC init:

      bool cdcCommInit(Context *ctx)
      {
           bool retStatus = false;
           if (Cy_USB_Dev_CDC_Init(&usb_cdcConfig, &ctx->cdcContext, &ctx->usbDevContext) == CY_USB_DEV_SUCCESS)
           {
                retStatus = true;
           }
      
           return retStatus;
      }
      

       

      My problem is that when I call the Cy_USB_Dev_Connect, it triggers both the CDC and Audio Request Handler with the following Control Transfer Request :

      ExpressionValue
      Direction1
      Type0
      Recipient0
      bRequest6
      wValue1536
      wIndex0
      wLength10

       

      What I don't understand is that a request for a standard device is passed to the specific classes asking for the descriptor (I guess the device descriptor?). This request then can't be handled by both my custom handler for the audio and the default for the CDC and it then says that my device can't be configured and it disables certain endpoints making my USB device unusable. I linked my configuration below if it can help.

       

      Thank you for your time.

       

       

      *** EDIT***

      The error I get when I run the code is :
      The device cannot start. (Code 10)
      The object was not found