Atmel ARM-Based Evaluation Kit AT91SAM9N12-EK AT91SAM9N12-EK Data Sheet

Product codes
AT91SAM9N12-EK
Page of 1104
523
SAM9N12/SAM9CN11/SAM9CN12 [DATASHEET]
11063K–ATARM–05-Nov-13
33.6.2  Handling Transactions with USB V2.0 Device Peripheral
33.6.2.1 Setup Transaction
Setup is a special type of host-to-device transaction used during control transfers. Control transfers must be performed
using endpoints with no ping-pong attributes. A setup transaction needs to be handled as soon as possible by the
firmware. It is used to transmit requests from the host to the device. These requests are then handled by the USB device
and may require more arguments. The arguments are sent to the device by a Data OUT transaction which follows the
setup transaction. These requests may also return data. The data is carried out to the host by the next Data IN
transaction which follows the setup transaction. A status transaction ends the control transfer.
When a setup transfer is received by the USB endpoint:
The USB device automatically acknowledges the setup packet
?
RXSETUP is set in the UDP_CSRx register
An endpoint interrupt is generated while the RXSETUP is not cleared. This interrupt is carried out to the 
microcontroller if interrupts are enabled for this endpoint.
Thus, firmware must detect the RXSETUP polling the UDP_CSRx or catching an interrupt, read the setup packet in the
FIFO, then clear the RXSETUP. RXSETUP cannot be cleared before the setup packet has been read in the FIFO.
Otherwise, the USB device would accept the next Data OUT transfer and overwrite the setup packet in the FIFO.
Figure 33-5.  Setup Transaction Followed by a Data OUT Transaction 
33.6.2.2 Data IN Transaction
Data IN transactions are used in control, isochronous, bulk and interrupt transfers and conduct the transfer of data from
the device to the host. Data IN transactions in isochronous transfer must be done using endpoints with ping-pong
attributes.
Using Endpoints Without Ping-pong Attributes
To perform a Data IN transaction using a non ping-pong endpoint:
1.
The application checks if it is possible to write in the FIFO by polling TXPKTRDY in the endpoint’s UDP_CSRx reg-
ister (TXPKTRDY must be cleared).
2.
The application writes the first packet of data to be sent in the endpoint’s FIFO, writing zero or more byte values in 
the endpoint’s UDP_FDRx register,
3.
The application notifies the USB peripheral it has finished by setting the TXPKTRDY in the endpoint’s UDP_CSRx 
register.
RX_Data_BKO
(UDP_CSRx)
ACK
PID
Data OUT
Data OUT
PID
NAK
PID
ACK
PID
Data Setup
Setup
PID
USB
Bus Packets
RXSETUP Flag
Set by USB Device 
Cleared by Firmware
Set by USB 
Device Peripheral
FIFO (DPR) 
Content
Data Setup
Data
XX
XX
OUT
Interrupt Pending
Setup Received
Setup Handled by Firmware
Data Out Received
Data OUT
Data OUT
PID