28.3.2.5.3 BULK or INTERRUPT Endpoint
- If the Respond with STALL (DOSTALL) bit in the Endpoint (USB.EP[n].OUT.CTRL) register is set, the incoming data is discarded. A STALL handshake is returned to the host. The Endpoint STALLED (STALLED) flags in the Endpoint Status (EP[n].OUT.STATUS) register and in the Interrupt Flags A (INTFLAGSA) register are set.
- If the Data Buffer Not Acknowledge (BUSNAK) flag in Endpoint STATUS or the Global NAK (GNAK) bit in the Control B (USB.CTRLB) register is set, the incoming data is discarded. The Underflow/Overflow (UNFOVF) flag in Endpoint STATUS and Underflow Interrupt (UNF) flag in the Interrupt Flags A (INTFLAGSA) register are set. A NAK handshake is returned to the host.
The data in the data buffer in RAM pointed to by the Endpoint Data Pointer (EP[n].IN.DATAPTR) register is sent to the host in a DATA0 or DATA1 packet according to the Data Toggle (TOGGLE) bit in Endpoint STATUS. When the number of data bytes specified in the endpoint’s CNT is sent, the CRC is appended and sent to the host.
The USB peripheral is waiting for an ACK handshake from the host. If an ACK handshake is not received within 16-bit times, the USB peripheral returns to idle and waits for the next token packet. If successfully receiving an ACK handshake, then BUSNACK and Transaction Complete (TRNCOMPL) flag are set, and TOGGLE is toggled. The endpoint address is written to the FIFO if this is enabled.