MrLolthe1st wrote:
Ben, i have a great mistake: what initial state of toggle bit for InEndpoint and OutEndpoint. Did you mean, that after success completion of TD, toggle bit of endpoint must be changed? I.e.: first state of toggle of OutEndpoint is 1, after sending CBW, toggle bit for OutEndpoint must be changed to 0?
The toggle bit initially is set to zero. Therefore, the first transfer on the endpoint has a toggle bit of zero. Then every transfer after has the toggle bit toggled. Hence the name of the bit. However, this toggle bit is independent of each endpoint. Each endpoint has its own toggle bit.
This toggle bit remains toggled on each transfer until a Stall is found, in which you send a Set_Feature(Clear Stall) request to that endpoint. By doing this, you reset the endpoint to zero. i.e.: After a Clear Stall request, the next transfer will have a toggle bit of zero.
Appendix D of
Volume 8 has a very good example of this toggle bit for BBB transfers.
One thing you must remember is that if you set up your TD's to use 64-byte transfers, due to full-speed traffic, expecting 512-byte sectors, and receive a short packet, you must calculate via the short package location, the last toggle bit used, so that the very next toggle bit is the correct toggle value. i.e.: You can't just place eight (8) TD's on the "stack" and expect the next toggle bit to be a given value. If at any time one of those eight packets errors, short packets, or stalls, you have to know what the next toggle bit will be.
Also, for a read, the CSW packet is part of that toggle sequence, since a read uses the
in endpoint. For a write, the CBW is part of the toggle sequence, since a write uses the
out endpoint.
The toggle bit doesn't care what type of packet it is, a CSW, Data, or CBW. It only cares that it is an
in endpoint or an
out endpoint and is toggled each time it sends/receives data.
Ben