AT32F425
Series Reference Manual
2022.03.30
Page 370
Ver 2.01
Figure 20-11 SETUP data packet flowchart
Waiting for DOEPINTn.SETUP
rem_supcnt =
rd_reg(DOEPTSIZn)
ctrl-rd/wr/2 stage
Find setup cmd type
setup_cmd[31:0] = mem[4-2* rem_supcnt]
setup_cmd[63:32] = mem[5-2* rem_supcnt]
setup_np_in_pkt
Status IN phase
rcv_out_pkt
Data OUT phase
setup_np_in_pkt
Data IN phase
Write
Read
2-stage
B2BSTUP
Interrupt bit set?
setup_cmd[31:0] = mem[setup_addr-8]
setup_cmd[63:32] = mem[setup_addr-4]
setup_addr =
rd_reg(DOEPDMAn)
No
Yes
(
2
)
Handling more than three consecutive SETUP packets
Per the USB 2.0 specification, typically, a host does not send more than three consecutive SETUP
packets to the same endpoint during a SETUP packet error. However, the USB2.0 specification does
not limit the number of consecutive SETUP packets a host can send to the same endpoint. If this
condition occurs, the OTGFS controller generates an interrupt (B2BSTUP bit in the OTGFS_DOEPINTx
register).
20.5.4.13
IN data transfers
This section describes the internal data flow during IN data transfers and how the application handles
IN data transfers.
1. The application can either select a polling or an interrupt mode.
In polling mode, the application monitors the status of the endpoint transmit data FIFO by
reading the OTGFS_DTXFSTSx register to determine whether there is enough space in the data
FIFO.
In interrupt mode, the application must wait for the TXFEMP interrupt bit in the
OTGFS_DIEPINTx register, and then read the OTGFS_DTXFSTSx register to determine whether
there is enough space in the data FIFO.
To write a single non-zero-length data packet, there must be enough space to write the entire
data packet in the data FIFO.
To write zero-length data packet, the application does not need to check the FIFO space.
2. Either way, when the application determines that there is enough space to write a transmit packet, the