GD32W51x User Manual
833
received data packet into the Rx FIFO and triggers ACK flag. Otherwise, the status flag
(NAK) reports the transaction result.
7. If the IN transaction described in step 5 is successful and PCNT is larger than 1 in step2,
return to step 3 and continues to receive the remaining packets. If the IN transaction
described in step 5 is not successful, return to step 3 to re-receive the packet again.
8. After all the transactions in a transfer are successfully received on USB bus, USBFS
pushes a TF status entry into the Rx FIFO on top of the last packet data. Thus after
reading and poping all the received data packet, the TF status entry is need, USBFS
generates TF flag to indicate that the transfer successfully finishes.
9. Disable the channel. Now the channel is in IDLE state and is ready for other transfers.
OUT transfers operation sequence
1. Initialize USBFS global registers.
2. Initialize and enable the channel.
3. Write
a packet into the channel’s Tx FIFO (Periodic Tx FIFO or non-periodic Tx FIFO).
After the whole packet data is written into the FIFO, USBFS generates a Tx request entry
in the corresponding request queue and decreases the TLEN field in USBFS_HCHxLEN
regis
ter by the written packet’s size.
4. When the request entry reaches the top of the request queue, USBFS begins to process
this request entry. If bus time for the transaction indicated by the request entry is enough,
USBFS starts the OUT transaction on USB bus.
5. When the OUT transaction indicated by the request entry finishes on USB bus, PCNT in
USBFS_HCHxLEN register is decreased by 1. If the transaction finishes successfully
(ACK handshake received), the ACK flag is triggered. Otherwise, the status flag (NAK)
reports the transaction result.
6. If the OUT transaction described in step 5 is successful and PCNT is larger than 1 in
step2, return to step 3 and continues to send the remaining packets. If the OUT
transaction described in step 5 is not successful, return to step 3 to resend the packet
again.
7. After all the transactions in a transfer are successfully sent on USB bus, USBFS
generates TF flag to indicate that the transfer successfully finishes.
8. Disable the channel. Now the channel is in IDLE state and is ready for other transfers.
Device mode
Global register initialization sequence
1.
Program USBFS_GAHBCS register according to application’s demand, such as the
TxFIFO’s empty threshold, etc. GINTEN bit should be kept cleared at this time.