239
8331B–AVR–03/12
Atmel AVR XMEGA AU
The incoming data are written to the data buffer pointed to by DATAPTR. If a bit-stuff error is
detected in the incoming data, the USB module returns to idle and waits for the next token
packet. If the number of received data bytes exceeds the maximum data payload specified by
SIZE, the remaining received data bytes are discarded. The packet will still be checked for bit-
stuff and CRC errors. If there was a bit-stuff or CRC error in the packet, the USB module returns
to idle and waits for the next token packet.
If the endpoint is isochronous and there was a bit-stuff or CRC error in the incoming data, the
number of received data bytes, excluding CRC, is written to the endpoint CNT register. Finally,
CRC and BUSNACK0 in the endpoint and STATUS and CRCIF in INTFLAGSASET/CLR are
set.
If data was successfully received, an ACK handshake is returned to the host if the endpoint is
not isochronous, and the number of received data bytes, excluding CRC, is written to CNT. If the
number of received data bytes is the maximum data payload specified by SIZE no CRC data are
written in the data buffer. If the number of received data bytes is the maximum data payload
specified by SIZE minus one, only the first CRC data byte is written in the data buffer If the num-
ber of received data bytes is equal or less than the data payload specified by SIZE minus two,
the two CRC data bytes are written in the data buffer.
Finally, the transaction complete flag (TRNCOMPL0) and BUSNACK0 are set and TOGGLE is
toggled if the endpoint is not isochronous. The transaction complete interrupt flag (TRNIF) in
INTFLAGSBCLR/SET is set. The endpoint's configuration table address is written to the FIFO if
the transaction complete FIFO mode is enabled.
When an OUT token is detected and the device address of the token packet does not match that
of the endpoint, the packet is discarded and the USB module returns to idle and waits for the
next token packet.
20.3.4
IN
If an IN token is detected the, the USB module fetches the endpoint CTRL and STATUS register
data from the addressed input endpoint in the endpoint configuration table. If the endpoint is dis-
abled, the USB module returns to idle and waits for the next token packet.
If the STALL flag in endpoint CTRL register is set, and the endpoint is not isochronous, a STALL
handshake is returned to the host, the STALL flag in the endpoint STATUS register and the
STALL interrupt flag (STALLIF) in INTFLAGSACLR/SET are set.
If BUSNACK0 is set, OVF in the endpoint STATUS register and OVFIF in the INTFLAGSA-
CLR/SET register are set. If the endpoint is not isochronous, a NAK handshake is returned to
the host.
The data in the data buffer pointed to by the endpoint DATAPTR register are sent to the host in
a DATA0 packet if the endpoint is isochronous; otherwise, a DATA0 or DATA1 packet according
to TOGGLE is sent. When the number of data bytes specified in endpoint CNT is sent, the CRC
is appended and sent to the host. If not, a ZLP handshake is returned to the host.
For isochronous endpoints, BUSNACK0 and TRNCOMPL0 in the endpoint STATUS register are
set. TRNIF is set, and the endpoint's configuration table address is written to the FIFO if the tran-
scation complete FIFO mode is enabled.
For all non-isochronous endpoints, the USB module waits for an ACK handshake from the host.
If an ACK handshake is not received within 16 USB clock cycles, the USB module returns to idle
and waits for the next token packet. If an ACK handshake was successfully received,