Detecting NAKing of OUT transfers by FX2LP

Question: How can i detect in firmware when an OUT transfer has been NAKed by FX2LP due to lack of space in the FIFOs?

 

Answer:

High-speed USB implements a PING-NAK mechanism for (Bulk and Control) OUT transfers. When the host wishes to send OUT data to an end-point,  and it was previous data transfer was responded by a NYET, it first sends a PING token to see if the endpoint is ready (for example, if it has an empty buffer). If a buffer is not available, the FX2LP returns a NAK handshake. PING-NAK transactions continue to occur until an OUT buffer is available, at which time the FX2LP answers a PING with an ACK handshake and the host sends the OUT data to the endpoint.

 

FX2LP implements PING-NAK interrupt as EP0PING, EP1PING and so on, one for each endpoint. The EPxPING interrupt is asserted when the host PINGs an OUT endpoint and the FX2LP responds with a NAK because the particular endpoint buffer memory is not available.  This interrupt can be used to detect when an OUT transfer has been NAKed by FX2LP due to lack of space in the FIFOs.