28.3.2.4.1 Control Endpoint
- If the Respond with STALL (DOSTALL) bit in the Endpoint CTRL is set, the incoming data are discarded. A STALL handshake is returned to the host. The Endpoint STALLED Flags (STALLED) in the Endpoint STATUS and in the Interrupt Flags A (INTFLAGSA) register are set.
- If the Endpoint SETUP Complete Flag (EPSETUP) in the Endpoint STATUS is set, the incoming data are discarded. The Underflow/Overflow Flag (UNFOVF) in the Endpoint STATUS and the Overflow Interrupt Flag (OVF) in the INTFLAGSA are set. A NAK handshake is returned to the host.
- The PID is checked against the Data Toggle (TOGGLE) bit in the Endpoint STATUS. Unless they match, the incoming data are discarded, and an ACK handshake is returned to the host. If the Data Buffer Not Acknowledge Flag (BUSNAK) in the Endpoint STATUS or the Global NAK (GNAK) bit in the Control B (USB.CTRLB) register is set, the incoming data are discarded. UNFOVF and OVF are set. A NAK handshake is returned to the host.
The incoming data are written to the data buffer in RAM pointed to by the Endpoint Data Pointer (EP[n].OUT.DATAPTR) register. If detecting a bit-stuff error in the incoming data, the USB peripheral returns to idle and waits for the next token packet. The remainders of the received data bytes are discarded if the number of received data bytes exceeds the maximum data payload specified in the Data Size (BUFSIZE) bit field in the Endpoint CTRL. The packet is checked for bit-stuff and CRC errors. If it contains a bit-stuff or CRC error, the USB peripheral returns to idle and waits for the next token packet. The first CRC byte may be written to SRAM if receiving fewer bytes than the maximum payload specified by BUFSIZE. It will be written if the last proper data bit is written to an even address and CNT<MCNT when multipacket is enabled or CNT<EPSIZE when multipacket is not enabled.
If successfully receiving data, an ACK handshake is returned to the host, and the number of received data bytes, excluding CRC, is written to CNT.
Finally, BUSNACK and Transaction Complete Flag (TRNCOMPL) are set, and TOGGLE is toggled. The endpoint address is written to the FIFO if this is enabled.