GD32F10x User Manual
761
illegal. The application software can implement double-buffering to improve performance. By
swapping transmission and reception data packet buffer on each transaction, the application
software can copy the data into or out of a buffer, at the same time the USB peripheral handle
the data transmission or reception of data in another buffer. The DTOG bit indicates which
buffer that the USB peripheral is currently using.
The application software initializes the DTOG according to the first buffer to be used. At the
end of each transaction, the RX_ST or TX_ST bit is set, depending on the enabled direction
regardless of CRC errors or buffer-overrun conditions (if errors occur, the ERRIF bit will be
set). At the same time, The USB peripheral will toggle the DTOG bit, but will not affect the
STAT bit.
23.6.3.
USB events and interrupts
Each USB action is always initiated by the application software, driven by one USB interrupt
or event. After system reset, the application needs to wait for a succession of USB interrupts
and events.
Reset events
System and power-on reset
Upon system and power-on reset, the application software should first provide all required
clock to the USB module and interface, then de-assert its reset signal so to be able to access
its registers, last switch on the analog part of the device related to the USB transceiver.
The USB firmware should do as follows:
Reset CLOSE bit in USBD_CTL register.
Wait for the internal reference voltage to be stable.
Clear SETRST bit in USBD_CTL register.
Clear the USBD_INTF register to remove the spurious pending interrupt and then enable
other unit.
USB reset (RESET interrupt)
When this event occurs, the USB peripheral status is the same as the moment system reset.
The USB firmware should do as follows:
Set USBEN bit in USBD_DADDR register to enable USB module in 10ms.
Initialize the USBD_EP0CS register and its related packet buffers.
Suspend and resume events
The USB module can be forced to place in low-power mode (SUSPEND mode) by writing in
the USB control register (USBD_CTL) whenever required. At this time, all static power
consumption is avoided and the USB clock can be slowed down or stopped. It will be resumed
when detect activity at the USB bus while in low-power mode.
Summary of Contents for GD32F10 Series
Page 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Page 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Page 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Page 427: ...GD32F10x User Manual 427 value ...
Page 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...