CY8CKIT-062: Connecting request to composite device

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
MaGa_4619181
Level 1
Level 1
First like given

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

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi, please refer to the attached project file.

We are still working on this code example, so it uses some internal links. You will not be able to build the project without changing the links in the LIB files. But you can refer to the source code.

View solution in original post

6 Replies
RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

You should NOT re-init this interrupt with this handler:

Cy_SysInt_Init(&UsbDevIntrHigh, AudioIn_IsrHandler); 

I guess you want to execute the AudioIn_IsrHandler in the data endpoint callback. This can be done using the RegisterEndpointCallback() function.

Refer to the code Audio Recorder code example.

https://www.cypress.com/documentation/code-examples/ce225786-psoc-6-mcu-usb-audio-recorder

Alright so I followed your advice about the Cy_SysInt_Init() and I still have the code 10 error (The object was not found). But I don't really know how to use the Audio Recorder example because what I'm trying to do is to stream audio from the computer to the board so I don't need to use the PDM/PCM conversion (I'll use Audacity that can already send PCM data). Plus there's no implementation of the OUT endpoint in the aforementioned example.

0 Likes
lock attach
Attachments are accessible only for community members.

Hi, please refer to the attached project file.

We are still working on this code example, so it uses some internal links. You will not be able to build the project without changing the links in the LIB files. But you can refer to the source code.

lock attach
Attachments are accessible only for community members.

Hi RodolfoG_11,

Thanks for the example project it cleared some things up regarding the calling structure! I still have a problem with my composite device configuration (UAC-CDC). If you could just look at my USB config and tell me if you see something wrong that would be super helpful!

Thanks!

0 Likes

What's the problem? You can't enumerate?

0 Likes

The device shows up as two separate entities with the audio device giving a code 10 error :

This device cannot start. (Code 10)

I think it has to do with my configuration, maybe the IAD is badly used?

***EDIT***

When I gave a value to the iInterface fields, the device enumerated correctly.

0 Likes