GD32F10x User Manual
783
24.5.6.
Operation guide
This section describes the advised operation guide for USBFS.
Host 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.
2. Program USBFS_GUSBCS register according to application
’s demand, such as the
operation mode (host, device or OTG) and some parameters of OTG and USB protocols.
3. Program USBFS_GCCFG register according to application
’s demand.
4. Program USBFS_GRFLEN, USBFS_HNPTFLEN_DIEP0TFLEN and USBFS_HPTFLEN
register to configure the data FIFOs according to application
’s demand.
5. Program USBFS_GINTEN register to enable Mode Fault and Host Port interrupt and set
GINTEN bit in USBFS_GAHBCS register to enable global interrupt.
6. Program USBFS_HPCS register and set PP bit.
7. Wait for a device
’s connection, and once a device is connected, the connection interrupt
PCD in USBFS_HPCS register will be triggered. Then set PRST bit to perform a port
reset. Wait for at least 10ms and then clear PRST bit.
8. Wait PEDC interrupt in USBFS_HPCS register and then read PE bit to ensure that the
port is successfully enabled. Read PS [1:0] bits to get the connected device
’s speed and
then program USBFS_HFT register to change the SOF interval if needed.
Channel initialization and enable sequence
1. Program USBFS_HCHxCTL registers with desired transfer type, direction, packet size,
etc. Ensure that CEN and CDIS bits keep cleared during configuration.
2. Program USBFS_HCHxINTEN register. Set the desired interrupt enable bits.
3. Program USBFS_HCHxLEN register. PCNT is the number of packets in a transfer and
TLEN is the total byte number of all the transmitted or received packets in a transfer.
For OUT channel: If PCNT=1, the single packet
’s size is equal to TLEN. If PCNT>1, the
former PCNT-1 packets are considered as max-packet-length packets whose size are
defined by MPL field in USBFS_HCHxCTL register, and the last packet
’s size is
calculated based on PCNT, TLEN and MPL. If software wants to send out a zero-length
packet, it should program TLEN=0, PCNT=1.
For IN channel: Because the application doesn
’t know the actual received data size
before the IN transaction finishing, TLEN could be set to a maximum possible value
Содержание 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 ...