usbh_ctrl.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. **************************************************************************
  3. * @file usbh_ctrl.h
  4. * @brief usb header file
  5. **************************************************************************
  6. * Copyright notice & Disclaimer
  7. *
  8. * The software Board Support Package (BSP) that is made available to
  9. * download from Artery official website is the copyrighted work of Artery.
  10. * Artery authorizes customers to use, copy, and distribute the BSP
  11. * software and its related documentation for the purpose of design and
  12. * development in conjunction with Artery microcontrollers. Use of the
  13. * software is governed by this copyright notice and the following disclaimer.
  14. *
  15. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  16. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  17. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  18. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  19. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  21. *
  22. **************************************************************************
  23. */
  24. /* define to prevent recursive inclusion -------------------------------------*/
  25. #ifndef __USBH_CTRL_H
  26. #define __USBH_CTRL_H
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* includes ------------------------------------------------------------------*/
  31. #include "usbh_core.h"
  32. /** @addtogroup USBH_drivers_control
  33. * @{
  34. */
  35. /** @defgroup USBH_ctrl_exported_types
  36. * @{
  37. */
  38. #ifdef USE_OTG_HOST_MODE
  39. usb_sts_type usbh_ctrl_send_setup(usbh_core_type *uhost, uint8_t *buffer, uint8_t hc_num);
  40. usb_sts_type usbh_ctrl_recv_data(usbh_core_type *uhost, uint8_t *buffer,
  41. uint16_t length, uint16_t hc_num);
  42. usb_sts_type usbh_ctrl_send_data(usbh_core_type *uhost, uint8_t *buffer,
  43. uint16_t length, uint16_t hc_num);
  44. usb_sts_type usbh_ctrl_setup_handler(usbh_core_type *uhost);
  45. usb_sts_type usbh_ctrl_setup_wait_handler(usbh_core_type *uhost, uint32_t *timeout);
  46. usb_sts_type usbh_ctrl_data_in_handler(usbh_core_type *uhost);
  47. usb_sts_type usbh_ctrl_data_in_wait_handler(usbh_core_type *uhost, uint32_t timeout);
  48. usb_sts_type usbh_ctrl_data_out_handler(usbh_core_type *uhost);
  49. usb_sts_type usbh_ctrl_data_out_wait_handler(usbh_core_type *uhost, uint32_t timeout);
  50. usb_sts_type usbh_ctrl_status_in_handler(usbh_core_type *uhost);
  51. usb_sts_type usbh_ctrl_status_in_wait_handler(usbh_core_type *uhost, uint32_t timeout);
  52. usb_sts_type usbh_ctrl_status_out_handler(usbh_core_type *uhost);
  53. usb_sts_type usbh_ctrl_status_out_wait_handler(usbh_core_type *uhost, uint32_t timeout);
  54. usb_sts_type usbh_ctrl_error_handler(usbh_core_type *uhost);
  55. usb_sts_type usbh_ctrl_stall_handler(usbh_core_type *uhost);
  56. usb_sts_type usbh_ctrl_complete_handler(usbh_core_type *uhost);
  57. usb_sts_type usbh_ctrl_transfer_loop(usbh_core_type *uhost);
  58. usb_sts_type usbh_ctrl_request(usbh_core_type *uhost, uint8_t *buffer, uint16_t length);
  59. usb_sts_type usbh_get_descriptor(usbh_core_type *uhost, uint16_t length,
  60. uint8_t req_type, uint16_t wvalue,
  61. uint8_t *buffer);
  62. void usbh_parse_dev_desc(usbh_core_type *uhost, uint8_t *buffer, uint16_t length);
  63. usb_header_desc_type *usbh_get_next_header(uint8_t *buf, uint16_t *index_len);
  64. void usbh_parse_interface_desc(usb_interface_desc_type *intf, uint8_t *buf);
  65. void usbh_parse_endpoint_desc(usb_endpoint_desc_type *ept_desc, uint8_t *buf);
  66. usb_sts_type usbh_parse_configure_desc(usbh_core_type *uhost,
  67. uint8_t *buffer, uint16_t length);
  68. uint8_t usbh_find_interface(usbh_core_type *uhost, uint8_t class_code, uint8_t sub_class, uint8_t protocol);
  69. void usbh_parse_string_desc(uint8_t *src, uint8_t *dest, uint16_t length);
  70. usb_sts_type usbh_get_device_descriptor(usbh_core_type *uhost, uint16_t length);
  71. usb_sts_type usbh_get_configure_descriptor(usbh_core_type *uhost, uint16_t length);
  72. usb_sts_type usbh_get_sting_descriptor(usbh_core_type *uhost, uint8_t string_id,
  73. uint8_t *buffer, uint16_t length);
  74. usb_sts_type usbh_set_configuration(usbh_core_type *uhost, uint16_t config);
  75. usb_sts_type usbh_set_address(usbh_core_type *uhost, uint8_t address);
  76. usb_sts_type usbh_set_interface(usbh_core_type *uhost, uint8_t ept_num, uint8_t altsetting);
  77. usb_sts_type usbh_set_feature(usbh_core_type *uhost, uint8_t feature, uint16_t index);
  78. usb_sts_type usbh_clear_dev_feature(usbh_core_type *uhost, uint8_t feature, uint16_t index);
  79. usb_sts_type usbh_clear_ept_feature(usbh_core_type *uhost, uint8_t ept_num, uint8_t hc_num);
  80. #endif
  81. /**
  82. * @}
  83. */
  84. /**
  85. * @}
  86. */
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif