Trying to Gett X200 USB Working

If you have a simple question and just want an answer.
bpelt
Junior Member
Posts: 6
Joined: Tue Oct 18, 2016 2:33 pm

Trying to Gett X200 USB Working

Post by bpelt »

Hi all,

I have been unable to get any setup/control packets from USB as of yet. The only return value I see from USB_GetSetupPacket is XUD_RES_RST. Is it obvious what I am missing? Please let me know if more information is helpful. I currently only have endpoint 0 defined. I have not gotten different results if I add more endpoints.

Below is my very simple program, build with "-g -DXUD_SERIES_SUPPORT=XUD_X200_SERIES -DUSB_TILE=tile[1]."

Thanks in advance for any help!

Best,
Bryant

Code: Select all

int main ( void )
{
    chan xudOutChans[Num_USBEndpointsOut];
    chan xudInChans[Num_USBEndpointsIn];

	par
	{
		on USB_TILE: xud(xudOutChans, Num_USBEndpointsOut,
                        xudInChans, Num_USBEndpointsIn,
                        null,
                        XUD_SPEED_FS, XUD_PWR_SELF);

		on USB_TILE: USBControlEndpoint(xudOutChans[USBEndpointsOut_Control], xudInChans[USBEndpointsIn_Control]);

	}

	return 0;
}

#define USB_HIST_SIZE		32
int usbReqHist[USB_HIST_SIZE] = {77};
int usbReqHistIt = 0;
int usbResets = 0;

void USBControlEndpoint(chanend outChan, chanend inChan)
{
    XUD_Result_t xudRes;
    XUD_ep outXUD = XUD_InitEp(outChan, XUD_EPTYPE_CTL | XUD_STATUS_ENABLE);
    XUD_ep inXUD = XUD_InitEp(inChan, XUD_EPTYPE_CTL | XUD_STATUS_ENABLE);
    USB_SetupPacket_t setupPkt;
    XUD_BusSpeed_t usbSpeed = XUD_SPEED_HS;

    while (1)
    {
        xudRes = USB_GetSetupPacket(outXUD, inXUD, setupPkt);

        if (XUD_RES_RST == xudRes)
        {
        	usbSpeed = XUD_ResetEndpoint(outXUD, inXUD);
    		++usbResets;
        }
        else
        {
        	if (XUD_RES_OKAY == xudRes)
        	{
				if (usbReqHistIt < USB_HIST_SIZE)
				{
					usbReqHist[usbReqHistIt] = setupPkt.bRequest;
					++usbReqHistIt;
				}
    		}
        }

    } // while (1)

    return;
}


User avatar
aneves
Experienced Member
Posts: 93
Joined: Wed Sep 16, 2015 2:38 pm

Post by aneves »

What hardware are you using? Is it one of the dev boards from xmos or something custom?

Have you tried running any of the examples?
bpelt
Junior Member
Posts: 6
Joined: Tue Oct 18, 2016 2:33 pm

Post by bpelt »

This is something custom largely based on the xCORE-200 Multichannel Audio Platform reference design but with the XUF216-512-TQ128-C20.

I did not have success building the example for this platform (sw_usb_audio-[sw]_6.15.2rc1).

Thanks!
bpelt
Junior Member
Posts: 6
Joined: Tue Oct 18, 2016 2:33 pm

Post by bpelt »

I went back to the examples and was able to get the app_usb_aud_xk_216_mc to run and the PC did recognize the device as an xCORE USB Audio 1.0 device.

I am still not seeing the posted code does not seem to get anything except bus reset notifications.
User avatar
aneves
Experienced Member
Posts: 93
Joined: Wed Sep 16, 2015 2:38 pm

Post by aneves »

Your posted code does not define any standard USB class or data, e.g., device descriptors, configuration descriptors, etc. How can the host know what your device is? That is probably why you are getting resets from the host, it has no idea on how to enumerate your device.

Take a look at the USB examples and study how the descriptors are defined and used. I would also highly recommend a USB analyzer. I have an ellisys USB Explorer. It is a critical investment if you will be writing USB firmware.
bpelt
Junior Member
Posts: 6
Joined: Tue Oct 18, 2016 2:33 pm

Post by bpelt »

Thank you for the reply and the suggestion of ellisys USB Explorer.

I suppose I was expecting to see setup packets from the XUD layer on endpoint 0, as this is how the host characterizes the device. In my example code, I never get anything from USB_GetSetupPacket() except for the XUD_RES_RST...not a single setup/control packet.
bpelt
Junior Member
Posts: 6
Joined: Tue Oct 18, 2016 2:33 pm

Post by bpelt »

Found it. In case it is helpful for anyone to know, I had not set the oscillator frequency for the USB peripheral:

Code: Select all

        <Node Id="1" InPackageId="1" Type="periph:XS1-SU" Reference="usb_tile" Oscillator="24MHz">
        </Node>
User avatar
aneves
Experienced Member
Posts: 93
Joined: Wed Sep 16, 2015 2:38 pm

Post by aneves »

Great! Glad you figured it out and shared the solution!
User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Yes - thanks for sharing the solution. It may well help others!