SpyderTL wrote:
BenLunt wrote:
You send the Set Address TD, wait for the response, then send the Status TD.
Can you elaborate a bit, for clarity?
What "response" are you waiting for? Do you mean just wait for the TD ConditionCode to be something other than 0x0e (pending)?
And what "Status TD" are you sending? Do you mean send a GET_STATUS message, and read the result? Is this strictly necessary?
Thanks.
A device can stall after the start of a setup packet. The only way to clear the stall is to start a new setup packet.
If you send a setup packet, the first TD is a SETUP TD. This is when the device may stall. If your ED contains a list of TD's, two in this case, and the second TD is the Status TD, you haven't cleared a stall and the Status TD won't ever get processed. Your code could be waiting for the Status TD to complete for a long time.
Therefore, send the first TD, the SETUP TD. If and when it comes back successful, then send the Status TD. If it comes back stalled. You need to clear the stall by sending another Setup TD.
The reason for the Status TD is to indicate to the device that you have successfully sent/received a transfer. If you instantly send the Status TD before waiting for the device to process the request, it defeats the purpose of the Status TD.
However, please note that if you have a Status TD right after a Setup TD in the same ED, the device won't process the Status TD until after it has processed the Setup TD. But if the device stalls, it will never get to the Status TD.
Therefore, send the Request TD, wait for a good transfer, then send the Status TD.
I gave an example to the OP of this thread of an ED with two TD's, assuming it would not stall. To create a good USB driver, you should not do this, but send a Setup TD, wait for the response, then send the Status TD, using two separate ED's, or the same ED, twice.
Does this help?
Ben
In my case when I do a Control Read I should be sending the SETUP TD's together with the DATA TD's and then check for the error and then send the STATUS TD's right?