
GD32L23x User Manual
620
Table 27-2. Double-buffering buffer flag definition
Buffer flag
Tx endpoint
Rx endpoint
DTG
TX_DTG (USBD_EPxCS bit 6)
RX_DTG (USBD_EPxCS bit 14)
SW_BUF
USBD_EPxCS bit 14
USBD_EPxCS bit 6
The DTG bit and the SW_BUF bit are responsible for the flow control. When a transfer
completes, the USB peripheral toggle the DTG bit; when the data have been copied, the
application software need to toggle the SW_BUF bit. Except for the first time, if the value of
DTG bit is equal to the SW_BUF’s, the transfer will pause, and the host is NAK. When the
two bits are not equal, the transfer resume.
Table 27-3. Double buffer usage
Endpoint
Type
DTOG
SW_BUF
Packet buffer used by the
USB peripheral
Packet buffer used by the
application software
OUT
0
1
EPxRBADDR/EPxRBCNT
buffer description table
locations.
EPxTBADDR/EPxTBCNT
buffer description table
locations.
1
0
EPxTBADDR/EPxTBCNT
buffer description table
locations.
EPxRBADDR/EPxRBCNT
buffer description table
locations.
IN
0
1
EPxTBADDR/EPxTBCNT
buffer description table
locations.
EPxRBADDR/EPxRBCNT
buffer description table
locations.
1
0
EPxRBADDR/EPxRBCNT
buffer description table
locations.
EPxTBADDR/EPxTBCNT
buffer description table
locations.
Endpoint memory requests arbitration
As the USBD is connected to the APB1 bus through an APB1 interface, so USB APB1
interface will accept memory requests coming from the APB1 bus and from the USB interface.
The arbiter will resolve the conflicts by giving priority to APB1 accesses, while always
reserving half of the memory bandwidth to complete all USB transfers. This time-duplex
scheme implements a virtual dual-port SRAM that allows memory access, when an USB
transaction is happening. Multiword APB1 transfers of any length are also allowed by this
scheme.
27.6.2.
Operation procedure
USB transaction process
After the endpoint is configured and a transaction is required, the hardware will detect the
token packet. When a token is recognized by the USBD, the data transfer is performed. When
all the data has been transferred, the proper handshake packet over the USBD is generated
or expected according to the direction of the transfer.