
DocID024597 Rev 5
RM0351
USB on-the-go full-speed (OTG_FS)
1774
decrements the STUPCNT field, but the application may not be able to determine the
correct number of SETUP packets received in the Setup stage of a control transfer.
–
STUPCNT = 3 in OTG_DOEPTSIZx
2. The application must always allocate some extra space in the Receive data FIFO, to be
able to receive up to three SETUP packets on a control endpoint.
–
The space to be reserved is 10 Words. Three Words are required for the first
SETUP packet, 1 Word is required for the Setup stage done Word and 6 Words
are required to store two extra SETUP packets among all control endpoints.
–
3 Words per SETUP packet are required to store 8 bytes of SETUP data and 4
bytes of SETUP status (Setup packet pattern). The core reserves this space in the
receive data.
–
FIFO to write SETUP data only, and never uses this space for data packets.
3. The application must read the 2 Words of the SETUP packet from the receive FIFO.
4. The application must read and discard the Setup stage done Word from the receive
FIFO.
•
Internal data flow
1.
When a SETUP packet is received, the core writes the received data to the receive
FIFO, without checking for available space in the receive FIFO and irrespective of the
endpoint’s NAK and STALL bit settings.
–
The core internally sets the IN NAK and OUT NAK bits for the control IN/OUT
endpoints on which the SETUP packet was received.
2. For every SETUP packet received on the USB, 3 Words of data are written to the
receive FIFO, and the STUPCNT field is decremented by 1.
–
The first Word contains control information used internally by the core
–
The second Word contains the first 4 bytes of the SETUP command
–
The third Word contains the last 4 bytes of the SETUP command
3. When the Setup stage changes to a Data IN/OUT stage, the core writes an entry
(Setup stage done Word) to the receive FIFO, indicating the completion of the Setup
stage.
4. On the AHB side, SETUP packets are emptied by the application.
5. When the application pops the Setup stage done Word from the receive FIFO, the core
interrupts the application with an STUP interrupt (OTG_DOEPINTx), indicating it can
process the received SETUP packet.
6. The core clears the endpoint enable bit for control OUT endpoints.
•
Application programming sequence
1.
Program the OTG_DOEPTSIZx register.
–
STUPCNT = 3
2. Wait for the RXFLVL interrupt (OTG_GINTSTS) and empty the data packets from the
receive FIFO.
3. Assertion of the STUP interrupt (OTG_DOEPINTx) marks a successful completion of
the SETUP Data Transfer.
–
On this interrupt, the application must read the OTG_DOEPTSIZx register to
determine the number of SETUP packets received and process the last received
SETUP packet.