I follow the app note 'AN00136' and 'USB-Custom-Class-Device-Demo-_documentation_1.2.2rc0.a.pdf' to make the bulk demo works on XU208 device.
The test code on host side 'bulk_test.cpp' can return correct results. But the demo code uses the blocking functions to do it. I.e. XUD_GetBuffer() and XUD_SetBuffer().
This time I modify it by using the non-blocking functions:
Code: Select all
void bulk_endpoint_async(chanend chan_ep_from_host, chanend chan_ep_to_host)
{
unsigned char host_transfer_buf[BUFFER_SIZE*4], ep_inbuf[BUFFER_SIZE*4]; // BUFFER_SIZE = 128
unsigned char host_cmd_line = 0;
unsigned host_transfer_length = 0;
XUD_Result_t result;
XUD_ep ep_from_host = XUD_InitEp(chan_ep_from_host);
XUD_ep ep_to_host = XUD_InitEp(chan_ep_to_host);
/* Mark out/in endpoint as ready to receive/send */
XUD_SetReady_Out(ep_from_host, host_transfer_buf);
XUD_SetReady_In(ep_to_host, ep_inbuf, BUFFER_SIZE*4);
while(1)
{
select
{ // get data from host
case XUD_GetData_Select(chan_ep_from_host, ep_from_host, host_transfer_length, result):
if(result == XUD_RES_RST)
{
XUD_ResetEndpoint(ep_from_host, ep_to_host);
}
else if(result == XUD_RES_OKAY)
{
/* Packet from host recieved */
host_cmd_line = host_transfer_buf[0];
/* Mark EP as ready again */
XUD_SetReady_Out(ep_from_host, host_transfer_buf);
}
break;
// send data to host
case XUD_SetData_Select(chan_ep_to_host, ep_to_host, result):
if(result == XUD_RES_RST)
{
XUD_ResetEndpoint(ep_from_host, ep_to_host);
}
else if(result == XUD_RES_OKAY)
{
/* Packet successfully sent to host */
/* Create new buffer */
for(int i = 0; i < BUFFER_SIZE*4; i++)
{
ep_inbuf[i] = 0x44;
}
XUD_SetReady_In(ep_to_host, ep_inbuf, BUFFER_SIZE*4);
}
break;
}
}
}
I've noticed that the new XUD lib had change some function, for example, the bulk transfer type now is performed in functon 'XUD_InitEp()'. For now I still use the XUD module which the same with USB Audio 2.0 reference design (a copy from this ref design).
Do I miss something on implementing the non-blocking method (I'm sorry I don't have an USB analyzer...)?
Thank you very much for your replies.
Regards.