238
8331B–AVR–03/12
Atmel AVR XMEGA AU
Finally, the setup transaction complete flag (SETUP), data buffer 0 not acknowledge flag
(NACK0), and data toggle flag (TOGGLE) are set, while the remaining flags in the endpoint sta-
tus register (STATUS) are cleared for the addressed input and output endpoints. The setup
transaction complete interrupt flag (SETUPIF) in INTFLAGSBCLR/SET is set. The STALL flag in
the endpoint CTRL register is cleared for the addressed input and output endpoints.
When a SETUP 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.3
OUT
When an OUT token is detected, the USB module fetches the endpoint CTRL and STATUS reg-
ister data from the addressed output endpoint in its endpoint configuration table. If the endpoint
is disabled, the USB module returns to idle and waits for the next token packet.
Figure 20-4.
OUT transaction.
The USB module then fetches the endpoint DATAPTR register and waits for a DATA0 or DATA1
packet. If a PID error or any other PID than DATA0 or DATA1 is detected, the USB module
returns to idle and waits for the next token packet.
If the STALL flag in the endpoint CTRL register is set, the incoming data are discarded. If the
endpoint is not isochronous, and the bit stuffing and CRC of the received data are OK, a STALL
handshake is returned to the host, and the STALL interrupt flag is set.
For isochronous endpoints, data from both a DATA0 and DATA1 packet will be accepted. For
other endpoint types, the PID is checked against TOGGLE. If they don't match, the incoming
data are discarded and a NAK handshake is returned to the host. If BUSNACK0 is set, the
incoming data are discarded. The overflow flag (OVF) in the endpoint STATUS register and the
overflow interrupt flag (OVFIF) in the INTFLAGSASET/CLR register are set. If the endpoint is
not isochronous, a NAK handshake is returned to the host.
OUT
TOKEN
ADDRESS
ADDRESS
MATCH?
ENDPOINT
LEGAL
ENDPOINT?
EP STATUS
ENABLED?
PID
PID OK?
DATA
BIT STUFF
BIT STUFF
OK?
CRC OK?
ACK
IDLE
o
N
o
N
o
N
o
N
o
N
STALL &
ISO?
STALL?
STALL
ISO?
DATA
No
BUSNACK0
SET?
NAK
o
N
s
e
Y
No
No
READ
CONFIG
UPDATE
STATUS
STORE
DATA
STORE
DATA
No
s
e
Y
s
e
Y
s
e
Y
s
e
Y
Yes
Yes
Yes
READ
CONFIG
PIDO/1
OK?
NAK
UPDATE
STATUS
No
Yes
DATA
BIT STUFF
CRC
BIT STUFF
OK?
CRC OK?
BUSNACK0
SET?
CRC
o
N
s
e
Y
Yes
Yes
No
Yes
No
Yes