GD32F10x User Manual
763
5. Wait for the reset interrupt (RSTIF).
6. In the reset interrupt, initialize default control endpoint 0 to start enumeration process and
program USBD_BADDR to set the device address to 0 and enable USB module function.
7. Configure endpoint 0 and prepare to receive SETUP packet.
Endpoint initialization sequence
1. Program USBD_EPxTBADDR or USBD_EPxRBADDR registers with transmission or
reception data buffer address.
2. Program the EP_CTL and EP_KCTL bits in USBD_EPxCS register to set endpoint type
and buffer kind according to the endpoint usage.
3. If the endpoint is a single buffer endpoint:
1)
Initialize the endpoint data toggle bit by programming the TX_DTG or RX_DTG bit
in USBD_EPxCS register, but endpoint 0 needs to set them to 1 and 0 respectively
for control transfer.
2)
Configure endpoint status by programming the TX_STA bit or RX_STA bit in
USBD_EPxCS
register, but both of them are set to ‘10 (NAK) if use endpoint 0 to
initialize the control transfer.
If the endpoint is a double buffer endpoint:
1)
Both transmission and reception toggle fields need to be programmed. If the endpoint
is a Tx endpoint, clear the TX_DTG and RX_DTG bit in USBD_EPxCS register, or if
endpoint is a Rx endpoint, it needs to toggle TX_DTG bit.
2)
Program USBD_EPxTBCNT and USBD_EPxRBCNT register to set transfer data bit
count.
3)
Endpoint transmission and reception status both need to be configured. If the
endpoint is a Tx endpoint, set the TX_STA bit to be NAK and RX_STA bit to be
DISABLED, or the endpoint is a Rx endpoint, set the RX_STA bit to be VALID and
TX_STA bit to be DISABLED.
SETUP and OUT data transfers
1. Program USBD_EPxRBCNT register to set BLKSIZ and EPRCNT filed, these filed
defines the endpoint buffer length.
2. Configure the endpoint status to be VALID to enable the endpoint to receive data by
programming USBD_EPxCS register.
3. Wait for successful transfer interrupt (STIF).
4. In the interrupt handler, application can get the transaction type by reading the STEUP
Содержание GD32F10 Series
Страница 1: ...GigaDevice Semiconductor Inc GD32F10x Arm Cortex M3 32 bit MCU User Manual Revision 2 6 Jun 2022 ...
Страница 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Страница 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Страница 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Страница 427: ...GD32F10x User Manual 427 value ...
Страница 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...