I use the XUD library in the lastest 2.1.0 from https://github.com/xmos/lib_xud/tree/develop/lib_xud inside my usb sound card project. In some circumdances, when I call XUD_DoGetRequest, this function stalls and never returns. The problem arises at endpoint 0, that the sound card controls.
To provoke this error faster, I wrote a shell script under Linux. The script switches a control in a loop between two states. Switching this control causes the sound card to send two interrupts to the host, because the states of two other controls have changed as a result of that change. Due to the interrupts, the host also reads the states of the other two controls. Very rarely, the sound card does not answer one of these host requests.
The implementation for the state request is nothing special: A endpoint 0 handler processes the host requests. The following pseudo code shows the implementation for answering a "get" request:
Code: Select all
// verify, if the request is valid
// load the state from a variable and store it to the buffer
XUD_DoGetRequest(ep0_out, ep0_in, buffer, 1, sp.wLength);
XUD_DoGetRequest calls the function XUD_SetBuffer_EpMax. This function in turn calls "XUD_SetBuffer" (inside "if (datalength <= epMax) { ... }"). XUD_SetBuffer calls XUD_SetBuffer_Finish and here the error occurs in the following line:
Code: Select all
asm volatile("testct %0, res[%1]" : "=r"(isReset) : "r"(ep->client_chanend));