Event Driven USB Task

New to XMOS and XCore? Get started here.
Post Reply
saul01
Member
Posts: 14
Joined: Thu Feb 16, 2017 12:57 am

Event Driven USB Task

Post by saul01 »

Hi,
I am having difficulty implementing an event driven USB Task. I have ported the code from AN00136_vendor_specific, it works ok but is not suited for our application since it goes in a loop polling to see if there is data and then replies to PC.
I need to do something like this:

Code: Select all

void CommsTask(.. USB channels, some interfaces to movable pointers)
{
	USB Endpoints and buffer setup
	
	while(1)
	{
		select
		{
			onUsbDataReceive():
				Notify other task of received USB data() 
				break;
			
		 	onProcessedDataReady():
		 		Send Data To Host via USB()
		 		break;		 		
	}
}
I have tried using XUD_GetDataSelect(c_epOut, ep_out, len, rslt), but it returns immediately and the DSP is not enumerating. Using XUD_GetBuffer(..) helps with the enumeration problem, but it does not help with the overall code architecture.

Is there a way to "select" on USB data available?
Thanks!


-Saul


Post Reply