24bit and 16bit options in USBAudio on PSoC 6

Hello,

I am using mbed os (6.15) on a PSoC 6 and I would like to make a soundcard that supports 2 modes:

  • 24bit 48000Hz
  • 16bit 44100Hz

I started from USBAudio class and I am trying to extend it to support both options. First I added 2 more interfaces in the USB descriptor, so there are 2 ISO endpoints for 24bit 48000Hz (in and out) and 2 more ISO endpoints for 16 bit 44100Hz (in and out). When connecting the board to Linux, dmesg gives a warning, which says that it ignores 2 of the 4 interfaces because they have the same endpoint address. So it seems that I am not allowed to use the same endpoint in and endpoint out addresses for both of the above options.
Then I tried to add 2 more addresses in _init using:

EndpointResolver resolver(endpoint_table());
    resolver.endpoint_ctrl(64);
    _episo_out_16bit_44100hz = resolver.endpoint_out(USB_EP_TYPE_ISO, _tx_packet_size_max_16bit_44100hz);
    _episo_in_16bit_44100hz = resolver.endpoint_in(USB_EP_TYPE_ISO, _rx_packet_size_max_16bit_44100hz);
    _episo_out_24bit_48000hz = resolver.endpoint_out(USB_EP_TYPE_ISO, _tx_packet_size_max_24bit_48000hz);
    _episo_in_24bit_48000hz = resolver.endpoint_in(USB_EP_TYPE_ISO, _rx_packet_size_max_24bit_48000hz);
    MBED_ASSERT(resolver.valid());

However, the assertion fails (resolver is not valid). Digging into the USB phy code for the endpoint table for PSoC 6 I can see the following:

const usb_ep_table_t *USBPhyHw::endpoint_table()
{
    static const usb_ep_table_t lpc_table = {
        512,
        // CY USB IP has hardware buffer of 512 bytes that is shared among 8 data endpoint.
        // The buffer has static allocation as follows:
        // - 4 endpoints of 64 that supports BULK and INT.
        // - 2 endpoints of 128 that support ISOC, BULK and INT.
        // The static allocation of max packet for BULK and INT allows to handle change interface
        // alternates properly if endpoint size is changed (the endpoint is not overlapped with
        // endpoints of neighborhood interface).
        // The CY USB IP has separate endpoint 0 hardware buffer of 8 bytes.
        {
            {USB_EP_ATTR_ALLOW_CTRL | USB_EP_ATTR_DIR_IN_AND_OUT, 0, 0},
            {USB_EP_ATTR_NON_ISO    | USB_EP_ATTR_DIR_IN_OR_OUT,  0, 0},
            {USB_EP_ATTR_NON_ISO    | USB_EP_ATTR_DIR_IN_OR_OUT,  0, 0},
            {USB_EP_ATTR_NON_ISO    | USB_EP_ATTR_DIR_IN_OR_OUT,  0, 0},
            {USB_EP_ATTR_NON_ISO    | USB_EP_ATTR_DIR_IN_OR_OUT,  0, 0},
            {USB_EP_ATTR_DATA_EP    | USB_EP_ATTR_DIR_IN_OR_OUT,  0, 0},
            {USB_EP_ATTR_DATA_EP    | USB_EP_ATTR_DIR_IN_OR_OUT,  0, 0},
            {0, 0, 0},
            {0, 0, 0},
        }
    };

    return &lpc_table;
}

Only 2 endpoints can be defined as ISO.

Do you have any workaround or suggestion how to implement both options (24bit and 16bit) in USBAudio?

Many thanks!

I found out I can use the same endpoints with different alternate settings. I think this ticket may be closed.