GD32VF103 User Manual
465
Connection, Reset and Speed identification
As a USB host, USBFS will trigger a connection flag for application after a connection is
detected and will trigger a disconnection flag after a disconnection event.
PRST bit is used for USB reset sequence. Application may set this bit to start a USB reset
and clear this bit to finish the USB reset. This bit only takes effect when port is at connected
or enabled state.
The USBFS performs speed identification during connection, and the speed information will
be reported in PS filed in USBFS_HPCS register. USBFS identifies the device speed by the
voltage level of DM or DP. As described in USB protocol, full-speed device pulls up DP line
while low-speed device pulls up DM line.
Suspend and resume
USBFS supports suspend state and resume operation. When USBFS port is at enabled state,
writing 1 to PSP bit in USBFS_HPCS register will cause USBFS to enter suspend state. In
suspend state, USBFS stops sending SOFs on USB bus and this will cause the connected
USB device to enter suspend state after 3ms. Application can set the PREM bit in
USBFS_HPCS register to start a resume sequence to wake up the suspended device and
clear this bit to stop the resume sequence. The WKUPIF bit in USBFS_GINTF will be set and
the USBFS wake up interrupt will be triggered if a host in suspend state detects a remote
wakeup signal.
SOF generate
USBFS sends SOF tokens on USB bus in host mode. As described in USB 2.0 protocol, SOF
packets are generated (by the host controller or hub transaction translator) every 1ms in full-
speed links.
Each time after USBFS enters into enabled state, it will send the SOF packet periodically
which the time is defined in USB 2.0 protocol. In addition, application may adjust the length
of a frame by writing FRI filed in USBFS_HFT registers. The FRI bits define the number of
USB clock cycles in a frame, so its value should be calculated based on the frequency of USB
clock which is used by USBFS. The FRT filed bits show that the remaining clock cycles of the
current frame and stop changing during suspend state.
USBFS is able to generate a pulse signal each SOF packet and output it to a pin. The pulse
length is 16 HCLK cycle. If application desires to use this function, it needs to set SOFOEN
bit in USBFS_GCCFG register and configure the related pin registers in GPIO.
USB Channels and Transactions
USBFS includes 8 independent channels in host mode. Each channel is able to communicate
with an endpoint in USB device. The transfer type, direction, packet length and other
information are all configured in channel related registers such as USBFS_HCHxCTL and
USBFS_HCHxLEN.
USBFS supports all the four kinds of transfer types: control, bulk, interrupts and isochronous.