usbh_std.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*!
  2. \file usbh_std.h
  3. \brief header file for usbh_std.c
  4. */
  5. /*
  6. Copyright (C) 2017 GigaDevice
  7. 2017-02-10, V1.0.0, firmware for GD32F30x
  8. */
  9. #ifndef USBH_STD_H
  10. #define USBH_STD_H
  11. #include "usbh_core.h"
  12. #include "usbh_usr.h"
  13. /* standard feature selector for clear feature command */
  14. #define FEATURE_SELECTOR_ENDPOINT 0x00U
  15. #define FEATURE_SELECTOR_DEVICE 0x01U
  16. #define USBH_SETUP_PACKET_SIZE 8U /* setup packet size */
  17. #define ENUM_HANDLE_TABLE_SIZE 10U /* enumerate handle table size */
  18. extern uint8_t usbh_cfg_desc[512];
  19. extern uint8_t enum_polling_handle_flag;
  20. extern state_table_struct enum_handle_table[ENUM_HANDLE_TABLE_SIZE];
  21. typedef enum
  22. {
  23. ENUN_EVENT_IDLE = 0, /* the enum idle event */
  24. ENUM_EVENT_SET_ADDR, /* the enum set address event */
  25. ENUN_EVENT_GET_FULL_DEV_DESC, /* the enum get full device descripter event */
  26. ENUN_EVENT_GET_CFG_DESC, /* the enum get congiguration descripter event */
  27. ENUN_EVENT_GET_FULL_CFG_DESC, /* the enum get full configuration descripter event */
  28. ENUN_EVENT_GET_MFC_STRING_DESC, /* the enum get MFC string descripter event */
  29. ENUN_EVENT_GET_PRODUCT_STRING_DESC, /* the enum get product string event */
  30. ENUN_EVENT_GET_SERIALNUM_STRING_DESC, /* the enum get serialnum string event */
  31. ENUN_EVENT_SET_CONFIGURATION, /* the enum set configuration event */
  32. ENUN_EVENT_DEV_CONFIGURED /* the enum device configured event */
  33. }enum_event_enum;
  34. /* function declarations */
  35. /* the polling function of enumeration state */
  36. usbh_status_enum enum_state_polling_fun (usb_core_handle_struct *pudev, usbh_host_struct *puhost, void *pustate);
  37. /* get descriptor in usb host enumeration stage */
  38. void usbh_enum_desc_get (usb_core_handle_struct *pudev,
  39. usbh_host_struct *puhost,
  40. uint8_t *buf,
  41. uint8_t req_type,
  42. uint16_t value_idx,
  43. uint16_t len);
  44. /* set address in usb host enumeration stage */
  45. void usbh_enum_addr_set (usb_core_handle_struct *pudev, usbh_host_struct *puhost, uint8_t device_address);
  46. /* set configuration in usb host enumeration stage */
  47. void usbh_enum_cfg_set (usb_core_handle_struct *pudev, usbh_host_struct *puhost, uint16_t cfg_idx);
  48. /* parse the device descriptor */
  49. void usbh_device_desc_parse (usb_descriptor_device_struct *dev_desc, uint8_t *buf, uint16_t len);
  50. /* parse the configuration descriptor */
  51. void usbh_cfg_desc_parse (usb_descriptor_configuration_struct *cfg_desc,
  52. usb_descriptor_interface_struct *itf_desc,
  53. usb_descriptor_endpoint_struct ep_desc[][USBH_MAX_EP_NUM],
  54. uint8_t *buf,
  55. uint16_t len);
  56. /* parse the interface descriptor */
  57. void usbh_interface_desc_parse (usb_descriptor_interface_struct *itf_desc, uint8_t *buf);
  58. /* parse the endpoint descriptor */
  59. void usbh_endpoint_desc_parse (usb_descriptor_endpoint_struct *ep_desc, uint8_t *buf);
  60. /* parse the string descriptor */
  61. void usbh_string_desc_parse (uint8_t *psrc, uint8_t *pdest, uint16_t len);
  62. /* get the next descriptor header */
  63. usb_descriptor_header_struct *usbh_next_desc_get (uint8_t *pbuf, uint16_t *ptr);
  64. #endif /* USBH_STD_H */