GD32F20x User Manual
885
Host mode
Global register initialization sequence
1.
Program USBFS_GAHBCS register according to application’s demand, such as the Tx
FIFO’s empty threshold, etc. GINTEN bit should be kept cleared at this time.
2.
Program USBFS_GUSBCS r
egister 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 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 to 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 are kept 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 bytes 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-lengthened 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-
lengthened 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 finishes, TLEN could be set to a maximum possible value supported
by Rx FIFO.
4.
Set CEN bit in USBFS_HCHxCTL register to enable the channel.
Channel disable sequence
Software can disable the channel by setting both CEN and CDIS bits at the same time.
Содержание GD32F20 Series
Страница 1: ...GigaDevice Semiconductor Inc GD32F20x ARM Cortex M3 32 bit MCU User Manual Revision 2 2 Oct 2019 ...
Страница 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Страница 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Страница 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Страница 385: ...GD32F20x User Manual 385 ...
Страница 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...