AN050
GD32 USBFS&USBHS Firmware Library User Guide
21
Figure 5-2. Device class file path
Descriptor mainly include device descriptor, configuration descriptor and string descriptor, etc.
There is some specific descriptor for some device class, such as HID device support report
descriptor, high speed device support other speed configuration descriptor and qualifier
descriptor.
Descriptor is sent to host in enumeration phase, corresponding device library code is
introduced in device/core/usbd_enum.c file. Specifically, in the standard enumeration phase,
the following two pointer arrays are implemented by callback function.
static
usb_reqsta
(*
_std_dev_req
[])(
usb_core_driver
*
udev
,
usb_req
*
req
)
=
{
[
USB_GET_STATUS
]
=
_usb_std_getstatus
,
[
USB_CLEAR_FEATURE
]
=
_usb_std_clearfeature
,
[
USB_RESERVED2
]
=
_usb_std_reserved
,
[
USB_SET_FEATURE
]
=
_usb_std_setfeature
,
[
USB_RESERVED4
]
=
_usb_std_reserved
,
[
USB_SET_ADDRESS
]
=
_usb_std_setaddress
,
[
USB_GET_DESCRIPTOR
]
=
_usb_std_getdescriptor
, // get descriptor
[
USB_SET_DESCRIPTOR
]
=
_usb_std_setdescriptor
,
[
USB_GET_CONFIGURATION
]
=
_usb_std_getconfiguration
,
[
USB_SET_CONFIGURATION
]
=
_usb_std_setconfiguration
,
[
USB_GET_INTERFACE
]
=
_usb_std_getinterface
,
[
USB_SET_INTERFACE
]
=
_usb_std_setinterface
,
[
USB_SYNCH_FRAME
]
=
_usb_std_synchframe
,
};
/* get standard descriptor handler */
static
uint8_t
*
(*
std_desc_get
[])(
usb_core_driver
*
udev
,
uint8_t
index
,
uint16_t
*
len
)
=
{
[(
uint8_t
)
USB_DESCTYPE_DEV
-
1U
]
=
_usb_dev_desc_get
,
[(
uint8_t
)
USB_DESCTYPE_CONFIG
-
1U
]
=
_usb_config_desc_get
,