GD32F403xx User Manual
639
PRST bit is used f or 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 perf orms speed identification during connection, and the speed inf ormation will
be reported in PS filed in USBFS_HPCS register. USBFS identifies the device speed by the
voltage level of DM or DP. As describing 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 into suspend state.
In suspend state, USBFS stops sending SOFs on USB bus, and it will lead the connected
USB device to enter into suspend state af ter 3ms. Application can set the PREM bit in
USBFS_HPCS register to start a resume sequence, so as 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 then 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 describing in USB 2.0 protocol, SOF
packets are generated (by the host controller or hub transaction translator) at each 1ms in
f ull-speed links.
Once that USBFS enterred into enabled state, it will send the SOF packet periodically which
the time is def ined in USB 2.0 protocol. In addition, application may adjust the length of a
f rame by writing FRI f iled in USBFS_HFT registers. The FRI bits define the number of USB
clock cycles in a f rame, so its value should be calculated based on the f requency of USB
clock which is used by USBFS. The FRT filed bits show that the remaining clock cycles of the
current f rame and stop changing during suspend state.
USBFS is able to generate a pulse signal f or each SOF packet and output it to a pin. The
pulse length is 12 HCLK cycle. If application desires to use this f unction, 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 transf er type, direction, packet length and other
inf ormation 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.
USB 2.0 protocol divides these transfers into 2 kinds: non-periodic transfer (control and bulk)
and periodic transfer (interrupt and isochronous). Based on this, USBFS includes two request
queues: periodic request queue and non-periodic request queue, to perf orm ef ficient
transaction schedule. A request entry in a request queue described above may represent a