AN050
GD32 USBFS&USBHS Firmware Library User Guide
58
6.6.
USB Host Library Device Class Interface
USB device class interface is implemented through the below structure.
/* device class callbacks */
typedef
struct
{
uint8_t
class_code
;
/*!< USB class type */
usbh_status
(*
class_init
)
(
struct
_usbh_host
*
phost
);
void
(*
class_deinit
)
(
struct
_usbh_host
*
phost
);
usbh_status
(*
class_requests
)
(
struct
_usbh_host
*
phost
);
usbh_status
(*
class_machine
)
(
struct
_usbh_host
*
phost
);
usbh_status
(*
class_sof
)
(
struct
_usbh_host
*
uhost
);
void
*
class_data
;
}
usbh_class
;
The structure initialization is implemented separately by each device class. Interface file of
each device class is reserved in host/class path device class folder
.
Figure 6-4. Host device class interface file path
The structure is implemented to operate initialization, deinitialization, device class request
and data transfer.
6.6.1.
HID device class
The HID device is initialized as follows:
usbh_class usbh_hid
=
{
USB_HID_CLASS
,
usbh_hid_itf_init
,
usbh_hid_itf_deinit
,
usbh_hid_class_req
,
usbh_hid_handle
,