GigaDevice Semiconductor GD32 Series User Manual

GigaDevice Semiconductor GD32 Series User Manual

Hide thumbs Also See for GD32 Series:
Table of Contents

Advertisement

GigaDevice Semiconductor Inc.
GD32 USBFS&USBHS
Firmware Library User Guide
Application Note
AN050

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the GD32 Series and is the answer not in the manual?

Questions and answers

Summary of Contents for GigaDevice Semiconductor GD32 Series

  • Page 1 GigaDevice Semiconductor Inc. GD32 USBFS&USBHS Firmware Library User Guide Application Note AN050...
  • Page 2: Table Of Contents

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Table of Contents Table of Contents ......................2 List of Figures ........................ 4 List of Tables ........................5 Introduction ......................7 Library architecture and file structure ..............8 2.1. Library Architecture ....................8 2.2.
  • Page 3 AN050 GD32 USBFS&USBHS Firmware Library User Guide 6.1.2. usb_conf.h ..........................49 6.2. Host VBUS Configuration ..................50 6.3. Interrupt handling ...................... 52 6.4. State Machine Process ....................56 6.5. USB Host Library User Interface ................56 6.6. USB Host Library Device Class Interface ..............58 6.6.1.
  • Page 4: List Of Figures

    AN050 GD32 USBFS&USBHS Firmware Library User Guide List of Figures Figure 2-1. GD32 USBFS firmware library framework ..............8 Figure 2-2. USBFS Firmware Library Folder ..................9 Figure 2-3. Device folder ........................9 Figure 2-4. Driver folder ........................10 Figure 2-5. Host folder ........................10 Figure 2-6.
  • Page 5: List Of Tables

    AN050 GD32 USBFS&USBHS Firmware Library User Guide List of Tables Table 1-1. Applicable products ......................7 Table 3-1. USBFS underlying file...................... 12 Table 3-2. usb_core.h/.c file function ....................12 Table 4-1. USBFS middle layer driver file ..................13 Table 4-2. drv_usb_host.h/.c file function ..................13 Table 4-3.
  • Page 6 AN050 GD32 USBFS&USBHS Firmware Library User Guide Table 6-2. usb_conf.h Configuration description ................50 Table 6-3. USBFS host interrupt ....................... 52 Table 6-4. USB host library user interface function ............... 57 Table 6-5. HID host class library function ..................59 Table 6-6.
  • Page 7: Introduction

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Introduction This application note is provided specifically for the GD32 MCU Universal Serial Bus full- speed interface USBFS module. USBHS modules are the same as USBFS in general, corresponding difference between USBFS and USBHS will be marked in the article. The purpose of this note is to make it easier for customers to use the USBFS and USBHS firmware library and to use this library for project development faster.
  • Page 8: Library Architecture And File Structure

    GD32 USBFS&USBHS Firmware Library User Guide Library architecture and file structure Library Architecture 2.1. USBFS module firmware structure of GD32 series is shown in Figure 2-1. GD32 USBFS firmware library framework. The figure show USBFS host and device structure, user application call the USBFS firmware library to realize the USB data commuction.
  • Page 9: File Structure

    AN050 GD32 USBFS&USBHS Firmware Library User Guide File structure 2.2. Take firmware library of GD32F4xx as an example, include the following four file folders. Figure 2-2. USBFS Firmware Library Folder Device file folder include Protocol layer files and device class files, which is required by USB device.
  • Page 10: Figure 2-4. Driver Folder

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 2-4. Driver folder Host folder include register definition, bottom layer driver and USB interrupt handler, which is required by USB host. Figure 2-5. Host folder The folder ustd include common device class file and standard enumeration file, which is called by host and device.
  • Page 11: Figure 2-6. Ustd Folder

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 2-6. Ustd folder...
  • Page 12: Usbfs Bottom Driver

    AN050 GD32 USBFS&USBHS Firmware Library User Guide USBFS bottom driver The file of USBFS bottom driver located in the driver folder. Bottom driver of whole firmware library is directly relate to USB hardware module, which include register read-write and FIFO operation, As shown in Table 3-1.
  • Page 13: Usbfs Middle Layer Driver

    AN050 GD32 USBFS&USBHS Firmware Library User Guide USBFS middle layer driver The middle driver layer is divided into host middle layer and device middle layer. Device middle layer packages the transaction and basic function of USB device transfer. Host middle layer packages the transaction and basic function of USB host transfer.
  • Page 14: Table 4-4. Usbh_Core.h/.C File Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Function name Functional description usbh_int_txfifoempty handle the TX FIFO empty interrupt Table 4-4. usbh_core.h/.c file function Function name Functional description usbh_init USB host stack initializations usbh_deinit de-initialize USB host usbh_class_register USB host register device class usbh_core_task USB host core main state machine process usbh_error_handler...
  • Page 15: Device Middle Layer Driver Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Function name Functional description usbh_pipe_update modify a pipe usbh_pipe_allocate allocate a new pipe usbh_pipe_free free a pipe usbh_pipe_delete delete all USB host pipe usbh_freepipe_get get a free pipe number for allocation Table 4-7. usbh_transc.h/.c file function Function name Functional description usbh_ctlsetup_send...
  • Page 16: Table 4-9. Drv_Usbd_Int.h/.C File Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Function name Functional description usb_devaddr_set set the USB device address usb_oepintnum_read read device all OUT endpoint interrupt register usb_oepintr_read read device OUT endpoint interrupt flag register usb_iepintnum_read read device all IN endpoint interrupt register usb_rwkup_set set remote wakeup signalling usb_rwkup_reset...
  • Page 17: Table 4-12. Usbd_Transc.h/.C File Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Function name Functional description _usb_std_reserved no operation, just for reserved _usb_dev_desc_get get the device descriptor _usb_config_desc_get get the configuration descriptor _usb_bos_desc_get get the BOS descriptor _usb_str_desc_get get string descriptor _usb_std_getstatus handle Get_Status request _usb_std_clearfeature handle USB Clear_Feature request _usb_std_setfeature...
  • Page 18: Usbfs Device Library

    AN050 GD32 USBFS&USBHS Firmware Library User Guide USBFS Device Library USBFS device library is based on the above underlying layer and middle layer driver, which include device library configuration, descriptor, interrupt, user interface, device class interface and example introduction. Device Library Configuration 5.1.
  • Page 19: Firmware Library Process

    AN050 GD32 USBFS&USBHS Firmware Library User Guide #ifdef USB_FS_CORE #define RX_FIFO_FS_SIZE #define TX0_FIFO_FS_SIZE #define TX1_FIFO_FS_SIZE #define TX2_FIFO_FS_SIZE #define TX3_FIFO_FS_SIZE #endif /* USB_FS_CORE */ #define USB_SOF_OUTPUT #define USB_LOW_POWER //#define VBUS_SENSING_ENABLED //#define USE_HOST_MODE #define USE_DEVICE_MODE //#define USE_OTG_MODE Table 5-2. usb_conf.h configuration description Configuration name Functional description RX FIFO size configuration...
  • Page 20: Descriptor

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-1. Firmware library flowchart start Corresponding function USB clock configuration usb_rcu_config USB timer configuration usb_timer_init User interface function register hid_itfop_register Device class interface function register udev->dev.class_core = class_core; Get serial string serial_string_get USB basic / core initialization usb_basic_init / usb_core_init USB device disconnect...
  • Page 21: Figure 5-2. Device Class File Path

    AN050 GD32 USBFS&USBHS Firmware Library User Guide 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.
  • Page 22: Interrupt Handling

    AN050 GD32 USBFS&USBHS Firmware Library User Guide [(uint8_t)USB_DESCTYPE_STR - 1U] = _usb_str_desc_get, #ifdef USE_USB_HS [(uint8_t)USB_DESCTYPE_DEV_QUALIFIER - 3U] = _usb_qualifier_desc_get, [(uint8_t)USB_DESCTYPE_OTHER_SPD_CONFIG - 3U] = _usb_other_speed_config_desc_get, #endif Interrupt handling 5.4. Table 5-3. USBFS device interruption. The interrupt of USBFS device interface is shown in Every interrupt flag corresponds to process handler of interrupt fuction, OEPIF, IEPIF and RXFNEIF flag is concerned about data transfer.
  • Page 23 AN050 GD32 USBFS&USBHS Firmware Library User Guide The interrupt handler function of OUT endpoint is shown as below: static uint32_t usbd_int_epout (usb_core_driver *udev) uint32_t epintnum = 0U; uint8_t ep_num = 0U; (epintnum usb_oepintnum_read (udev); epintnum; epintnum >>= 1, ep_num++) { (epintnum &...
  • Page 24 AN050 GD32 USBFS&USBHS Firmware Library User Guide return In OUT endpoint interrupt handler function, depending on the interrupt flag register, out_endp_intr function judge the event of OUT endpoint interrupt, which include transfer finished interrupt and setup phase finished interrupt. After corresponding OUT endpoint interrupt event generated, MCU execute the corresponding interrupt handler function through polling interrupt flag.
  • Page 25 AN050 GD32 USBFS&USBHS Firmware Library User Guide In interrupt handler function of IN endpoint, process transfer finished interrupt and transmit FIFO empty interrupt. After corresponding IN endpoint interrupt event generated, MCU execute the corresponding interrupt handler function through polling interrupt flag. The interrupt handler function of Rx FIFO non empty is shown as below: static uint32_t usbd_int_rxfifo (usb_core_driver...
  • Page 26: Usb Device Class Interface

    AN050 GD32 USBFS&USBHS Firmware Library User Guide case RSTAT_SETUP_COMP: /* trigger the OUT endpoint interrupt */ break; case RSTAT_SETUP_UPDT: ((0U == transc->ep_addr.num) && == bcount) && (DPID_DATA0 == data_PID)) { /* copy the setup packet received in FIFO into the setup buffer in RAM */ (void)usb_rxfifo_read (&udev->regs, (uint8_t...
  • Page 27: Figure 5-3. Device Class File

    AN050 GD32 USBFS&USBHS Firmware Library User Guide uint8_t (*req_proc) (usb_dev *udev, usb_req *req); /*!< device request handler */ uint8_t (*set_intf) (usb_dev *udev, usb_req *req); /*!< device set interface callback */ uint8_t (*ctlx_in) (usb_dev *udev); /*!< device contrl in callback */ uint8_t (*ctlx_out) (usb_dev...
  • Page 28: Data Transmission Process

    AN050 GD32 USBFS&USBHS Firmware Library User Guide usb_class_core usbd_hid_cb .command = NO_CMD, .alter_set = 0U, .init = hid_init, .deinit = hid_deinit, .req_proc = hid_req, .data_in hid_data_in The above initialization could implement initialization, deinitialization, device class request and data transfer of device class. Data transmission process 5.6.
  • Page 29: Usb Device Class Routine

    AN050 GD32 USBFS&USBHS Firmware Library User Guide usbd_out_transc function. data_out callback function actually call the cdc_acm_out function. Once enter in cdc_acm_out function, it is indicated that some data are received by device, and then call function cdc_acm_data_receive, so as to prepare next data packet. uint8_t usbd_out_transc (usb_core_driver *udev,...
  • Page 30: Table 5-5. Audio Device Class Interface Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Descriptor name Functional description usb_desc_input_terminal input terminal descriptor usb_desc_mono_feature_unit mono feature unit descriptor usb_desc_output_terminal output terminal descriptor usb_desc_AS_itf AS interface descriptor usb_desc_format_type format type descriptor usb_desc_std_ep standard endpoint descriptor usb_desc_AS_ep AS endpoint descriptor AUDIO device class interface AUDIO device class interface is shown as below struct, the function of struct is referred to Table 5-5.
  • Page 31: Figure 5-5. Audio Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Request name Functional description AUDIO_REQ_SET_MAX set maximum value request AUDIO_REQ_GET_MAX get maximum value request AUDIO_REQ_SET_RES set resolution request AUDIO_REQ_GET_RES get resolution request AUDIO user interface AUDIO user interface definition is shown as below struct. audio_fops_struct audio_out_fops init, deinit,...
  • Page 32: Figure 5-6. Audio Playback File

    AN050 GD32 USBFS&USBHS Firmware Library User Guide 1) data OUT phase Opening audio file in host is shown in Figure 5-6. Audio playback file, the playing audio file in host is heared through headphone which is connected to EVAL board. Figure 5-6.
  • Page 33: Cdc

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-7. Audio system sound configuration Enter in “record” item, and double click on the microphone. In microphone attribute, select “monitor” interface, check “monitor this device” and select default playing device in “monitor” interface.
  • Page 34: Table 5-8. Cdc Relevant Descriptors

    AN050 GD32 USBFS&USBHS Firmware Library User Guide CDC descriptor introduction Device descriptor include CDC device VID(0x28e9) and PID(0x018a). In configuration descriptor set, include CDC corresponding descriptor item, two interface, one command interface and one data interface, command interface corresponding descriptor is shown as Table 5-8.
  • Page 35: Figure 5-9. Cdc Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide CDC device class request. Table 5-10. CDC device class request Request name Functional description SEND_ENCAPSULATED_COMMAND Not used GET_ENCAPSULATED_RESPONSE Not used SET_COMM_FEATURE Not used GET_COMM_FEATURE Not used CLEAR_COMM_FEATURE Not used SET_LINE_CODING set serial port parameters GET_LINE_CODING get serial port parameters SET_CONTROL_LINE_STATE...
  • Page 36: Dfu

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-10. Virtual serial data transmitting and receiving For mass data test, it is necessary to add send byte number, and configure Timing sending function in serial debugging assistant, which is shown in Figure 5-11.
  • Page 37: Figure 5-12. Dfu State Machine Flow Chart

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-12. DFU state machine flow chart DFU_DETACH APP_IDLE APP_DETACH DETACH TIMEOUT Application Program Mode DFU Program Mode USB Reset Any status except OK Any State (except 0 or 1) DFU_ERROR State 2,3,5,6,9 USB reset Corrupt Power On reset...
  • Page 38: Table 5-13. Dfu Device Class Interface Functions

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Table 5-13. DFU device class interface functions. usb_class_core dfu_class .init = dfu_init, .deinit = dfu_deinit, .req_proc = dfu_req_handler, .ctlx_in dfu_ctlx_in Table 5-13. DFU device class interface functions Function name Functional description dfu_init initialize DFU device dfu_deinit deinitialize DFU device dfu_req_handler...
  • Page 39: Figure 5-13. Dfu Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide The functions of each function are shown in the following Table 5-15. DFU user interface functions: Table 5-15. DFU user interface functions Function name Functional description flash_if_init Memory medium interface initialization flash_if_deinit Memory medium interface deinitialization flash_if_erase Memory medium erase operation flash_if_write...
  • Page 40: Figure 5-14. All In One Connection

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-14. All in one connection 1) Download Select the target file and configure the corresponding download address, after downloading, reset the chip, and then execute application. 2) Upload Select the target file, click OK and then pop out “selected pages” interface, select the upload page and then get the corresponding data.
  • Page 41: Figure 5-15. All In One Uploading

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-15. All in one uploading 3) Option Byte operation Double click “Edit Option Bytes”, and then pop out the option byte corresponding information, which is shown as Figure 5-16. All in one Option Byte operation.
  • Page 42: Msc

    AN050 GD32 USBFS&USBHS Firmware Library User Guide 5.7.4. MSC device is mass storage device, include U-disk and CDROM. MSC descriptor introduction Device descriptor include MSC device VID(0x28e9) and PID(0x028f). In configuration descriptor set, include configure descriptor, interface descriptor and endpoint descriptor, which is shown as below.
  • Page 43: Table 5-18. Msc User Interface Functions

    AN050 GD32 USBFS&USBHS Firmware Library User Guide usbd_mem_cb USBD_Internal_Storage_fops .mem_init = STORAGE_Init, .mem_ready = STORAGE_IsReady, .mem_protected = STORAGE_IsWriteProtected, .mem_read = STORAGE_Read, .mem_write = STORAGE_Write, .mem_maxlun = STORAGE_GetMaxLun, .mem_inquiry_data {(uint8_t *)STORAGE_InquiryData}, .mem_block_size = {ISRAM_BLOCK_SIZE}, .mem_block_len = {ISRAM_BLOCK_NUM} Individual functions and variable functions is shown as Table 5-18.
  • Page 44: Figure 5-17. Msc Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 5-17. MSC device class In my computer, the newly added disk is visible, because disk is lack of file system, so it is necessary to format the disk firstly, which is shown in Figure 5-18.
  • Page 45: Hid

    AN050 GD32 USBFS&USBHS Firmware Library User Guide 5.7.5. HID device class is implement human-machine interaction interface, HID device has a wide usage range, not only include mouse, keyboard and touch device, but also include customed HID device. HID descriptor introduction Device descriptor include HID device VID(0x28e9) and PID(0x0380).
  • Page 46: Figure 5-20. Hid Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Request name value Functional description GET_PROTOCOL 0x03 Get protocol SET_REPORT 0x09 Set report SET_IDLE 0x0A Set idle SET_PROTOCOL 0x0B Set protocol HID user interface HID user interface is enumerated as keyboard, which is shown in below structure. hid_fop_handler fop_handler .hid_itf_config = key_config,...
  • Page 47: Usb Printer

    AN050 GD32 USBFS&USBHS Firmware Library User Guide fail. USB printer 5.7.6. Printer descriptor introduction Device descriptor include Printer device VID(0x28e9) and PID(0x028d). In printer configuration descriptor set, include configuration, interface and endpoint descriptor, corresponding descriptor is shown as below. Printer device class interface Printer device class interface is shown in below structure, and structure function is shown in below Table 5-23.
  • Page 48: Figure 5-21. Printer Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide function. Printer routine operation guide Download the Printer rountine to EVAL board, a newly added printer device is visible in device Figure 5-21. printer device class. manager.As shown in Figure 5-21. printer device class...
  • Page 49: Usbfs Host Library

    AN050 GD32 USBFS&USBHS Firmware Library User Guide USBFS Host Library Host Library Configuration 6.1. usbh_conf.h 6.1.1. File configuration item is shown as below. #define USBH_MAX_EP_NUM #define USBH_MAX_INTERFACES_NUM #define USBH_MAX_ALT_SETTING #define USBH_MAX_SUPPORTED_CLASS #define USBH_DATA_BUF_MAX_LEN 0x200 #define USBH_CFGSET_MAX_LEN 0x200 Each configuration is defined as Table 6-1.
  • Page 50: Host Vbus Configuration

    AN050 GD32 USBFS&USBHS Firmware Library User Guide #ifdef USE_EMBEDDED_PHY #define USB_EMBEDDED_PHY_ENABLED #endif #define USB_HS_INTERNAL_DMA_ENABLED #endif #define USB_SOF_OUTPUT #define USB_LOW_POWER //#define USB_LOW_PWR_ENABLE /****************** USB OTG MODE CONFIGURATION ********************************/ #define USE_HOST_MODE //#define USE_DEVICE_MODE //#define USE_OTG_MODE Table 6-2. usb_conf.h Configuration description Configuration name Functional description USB_RX_FIFO_FS_SIZE Received FIFO size...
  • Page 51: Figure 6-1. Construct Circuit Through Triode To Control Vbus

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 6-1. Construct circuit through triode to control VBUS 10KΩ PD13 S8550 470R E4 16V/10uF,AVX +U5V USB_VBUS VBUS PA11 USB_DM PA12 USB_DP Shield OTG_FS 1MΩ 50V/4700pF As shown in Figure 6-1. Construct circuit through triode to control VBUS, PD13 is configured to be GPIO open drain mode(OD).
  • Page 52: Interrupt Handling

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 6-2. Control VBUS by Logic Chip Circuit 10KΩ PD13 OUTA VBUS_FS_5V 10KΩ FLGA +3V3 FLGB 10KΩ OUTB LED6 50V/0.1uF 16V/10uF,AVX SP2526A-1EN ENA and ENB active HIGH 470Ω LED RED R100 CPEN 10KΩ EXTVBUS RBIAS VBUS_HS_5V...
  • Page 53 AN050 GD32 USBFS&USBHS Firmware Library User Guide Interrupt Flag Description Operation Mode HCIF Host channels interrupt flag Host Mode HPIF Host port interrupt flag Host Mode ISOONCIF/PXNCIF Periodic transfer Not Complete Interrupt Host or device mode flag /Isochronous OUT transfer Not Complete Interrupt Flag NPTXFEIF Non-Periodic Tx FIFO empty interrupt...
  • Page 54 AN050 GD32 USBFS&USBHS Firmware Library User Guide __IO uint32_t pp_ctl = udev->regs.pr[pp_num]->HCHCTL; pp_ctl |= HCHCTL_CEN; pp_ctl &= ~HCHCTL_CDIS; udev->regs.pr[pp_num]->HCHCTL = pp_ctl; break; case GRXSTS_PKTSTS_IN_XFER_COMP: break; case GRXSTS_PKTSTS_DATA_TOGGLE_ERR: count (rx_stat & GRSTATRP_BCOUNT) >> 4U; while (count > 0U) { rx_stat = udev->regs.gr->GRSTATP; count--;...
  • Page 55 AN050 GD32 USBFS&USBHS Firmware Library User Guide else if (PIPE_PERIOD == pp_mode) { txfiforeg = &udev->regs.hr->HPTFQSTAT; else return txfifostate = *txfiforeg; pp_num (uint8_t)((txfifostate & TFQSTAT_CNUM) >> 27U); word_count (uint16_t)(udev->host.pipe[pp_num].xfer_len + 3U) / 4U; while (((txfifostate & TFQSTAT_TXFS) >= word_count) && udev->host.pipe[pp_num].xfer_len)) { (uint16_t)(txfifostate &...
  • Page 56: State Machine Process

    AN050 GD32 USBFS&USBHS Firmware Library User Guide State Machine Process 6.4. Based on the below state machine, USB implement device operation, such as connecting, detecting and enumeration. state machine is loop executing in main function. Figure 6-3. USB host state machine Host start HOST_DEFAULT Detect device...
  • Page 57: Table 6-4. Usb Host Library User Interface Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide usbh_user_device_reset, usbh_user_device_disconnected, usbh_user_over_current_detected, usbh_user_device_speed_detected, usbh_user_device_desc_available, usbh_user_device_address_assigned, usbh_user_configuration_descavailable, usbh_user_manufacturer_string, usbh_user_product_string, usbh_user_serialnum_string, usbh_user_enumeration_finish, usbh_user_userinput, usbh_usr_msc_application, usbh_user_device_not_supported, usbh_user_unrecovered_error The functions of each function are described in Table 6-4. USB host library user interface function. Table 6-4. USB host library user interface function Function name Functional description usbh_user_init...
  • Page 58: Usb Host Library Device Class Interface

    AN050 GD32 USBFS&USBHS Firmware Library User Guide USB Host Library Device Class Interface 6.6. 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);...
  • Page 59: Table 6-5. Hid Host Class Library Function

    AN050 GD32 USBFS&USBHS Firmware Library User Guide usbh_hid_sof The initialization function of structure is shown in usbh_hid_core.c file, except for include structure initialization, and include other HID device class function and corresponding function, shown in Table 6-5. HID host class library function.
  • Page 60: Msc Device Class

    AN050 GD32 USBFS&USBHS Firmware Library User Guide MSC device class 6.6.2. The MSC device is initialized as follows: usbh_class usbh_msc USB_CLASS_MSC, usbh_msc_itf_init, usbh_msc_itf_deinit, usbh_msc_req, usbh_msc_handle, The initialization function of structure is shown in usbh_msc_core.c file, except for include structure initialization, and include other MSC device class function and corresponding function, shown in Table 6-6.
  • Page 61: Usb Host Library Routine

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Device class File name Function name Description si.c device send 'Test unit ready' command usbh_msc_test_unitready to the device send the read capacity usbh_msc_read_capacity10 command to the device send the mode sense6 usbh_msc_mode_sense6 command to the device send the Request Sense usbh_msc_request_sense command to the device...
  • Page 62: Msc Host

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Figure 6-5. Hid host routine operation diagram Figure 6-6. Routine for mouse-over display of HID host Figure 6-7. Routine for HID host keyboard display MSC HOST 6.7.2. MSC host rountine could be used to identify the U-disk, enumeration course and data transfer phase is displayed in display screen.
  • Page 63: Figure 6-8. Msc Host Routine Operation Steps

    AN050 GD32 USBFS&USBHS Firmware Library User Guide The operation steps of MSC host rountine is shown as below figure, firstly, insert OTG cable into USB connector, and then download MSC_Host program file to EVAL board and run the application. If one U-disk is connected, U-disk enumeration information could be displayed on the display screen.
  • Page 64: Revision History

    AN050 GD32 USBFS&USBHS Firmware Library User Guide Revision history Table 7-1. Revision history Revision No. Descriptor Date Initial Release Mar.28, 2022...
  • Page 65 Important Notice This document is the property of GigaDevice Semiconductor Inc. and its subsidiaries (the "Company"). This document, including any product of the Company described in this document (the “Product”), is owned by the Company under the intellectual property laws and treaties of the People’s Republic of China and other jurisdictions worldwide.

Table of Contents