English
Language : 

SAM4L Datasheet, PDF (351/1185 Pages) ATMEL Corporation – ATSAM ARM-based Flash MCU
OUT
RXOUTI
ATSAM4L4/L2
Figure 17-13. Example of an OUT endpoint with two data banks
DATA
(bank 0)
ACK
OUT
DATA
(bank 1)
ACK
HW
SW
HW
SW
FIFOCON
read data from CPU
BANK 0
SW
read data from CPU
BANK 1
• Detailed description
Before using the OUT endpoint, one should properly initialize its descriptor for each bank. See
Figure 17-6 on page 344.
The data is read, according to this sequence:
• When the bank is full, RXOUTI and FIFOCON are set, which triggers an EPnINT interrupt if
RXOUTE is one.
• The user acknowledges the interrupt by writing a one to RXOUTIC in order to clear RXOUTI.
• The user reads the UESTAX.CURRBK field to know the current bank number.
• The user reads the byte count of the current bank from the descriptor in RAM
(EPn_PCKSIZE_BK0/1.BYTE_COUNT) to know how many bytes to read.
• The user reads the data in the current bank, located in RAM as described by its descriptor:
EPn_ADDR_BK0/1.
• The user frees the bank and switches to the next bank (if any) by clearing FIFOCON.
If the endpoint uses several banks, the current one can be read while the next is being written by
the host. When the user clears FIFOCON, the following bank may already be ready and RXOUTI
will be immediately set.
• Multi packet mode for OUT endpoints
In multi packet mode, the user can extend the size of the bank allowing the storage of n USB
packets in the bank.
To enable the multi packet mode, the user should configure the endpoint descriptor
(EPn_PCKSIZE_BK0/1.MULTI_PACKET_SIZE) to match the size of the multi packet. This
value should be a multiple of the endpoint size (UECFGn.EPSIZE).
Since the EPn_PCKSIZE_BK0/1.BYTE_COUNT is incremented (by the received packet size)
after each successful transaction, it should be set to zero when setting up a new multi packet
transfer.
As for single packet mode, the number of received data bytes is stored in the BYTE_CNT field.
The bank is considered as “valid” and the RX_OUT flag is set when:
42023C–SAM–02/2013
351