EasyManua.ls Logo

GigaDevice Semiconductor GD32VF103 - Page 474

GigaDevice Semiconductor GD32VF103
536 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
GD32VF103 User Manual
474
2. Program USBFS_GUSBCS register according to applications 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 applications demand.
4. Program USBFS_GRFLEN, USBFS_HNPTFLEN_DIEP0TFLEN, USBFS_DIEPxTFLEN
register to configure the data FIFOs according to applications demand.
5. Program USBFS_GINTEN register to enable Mode Fault, Suspend, SOF, Enumeration
Done and USB Reset interrupt and then, set GINTEN bit in USBFS_GAHBCS register to
enable global interrupt.
6. Program USBFS_DCFG register according to applications demand, such as the device
address, etc.
7. After the device is connected to a host, the host will perform port reset on USB bus and
this will trigger the RST interrupt in USBFS_GINTF register.
8. Wait for ENUMF interrupt in USBFS_GINTF register.
Endpoint initialization and enable sequence
1. Program USBFS_DIEPxCTL or USBFS_DOEPxCTL register with desired transfer type,
packet size, etc.
2. Program USBFS_DIEPINTEN or USBFS_DOEPINTEN register. Set the desired interrupt
enable bits.
3. Program USBFS_DIEPxLEN or USBFS_DOEPxLEN 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 IN endpointIf PCNT=1, the single packets 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_DIEPxCTL register, and the last packets size is
calculated based on PCNT, TLEN and MPL. If a zero-length packet is required to be sent,
it should program TLEN=0, PCNT=1.
For OUT endpointBecause the application doesnt know the actual received data size
before the OUT transaction finishes, TLEN can be set to a maximum possible value
supported by Rx FIFO.
4. Set EPEN bit in USBFS_DIEPxCTL or USBFS_DOEPxCTL register to enable the
endpoint.
Endpoint disable sequence
The endpoint can be disabled anytime when the EPEN bit in USBFS_DIEPxCTL or
USBFS_DOEPxCTL registers is cleared.
IN transfers operation sequence

Table of Contents

Related product manuals