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 25 /* define to prevent recursive inclusion -------------------------------------*/ 26 #ifndef __USBH_CTRL_H 27 #define __USBH_CTRL_H 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* includes ------------------------------------------------------------------*/ 34 #include "usbh_core.h" 35 36 /** @addtogroup USBH_drivers_control 37 * @{ 38 */ 39 40 /** @defgroup USBH_ctrl_exported_types 41 * @{ 42 */ 43 44 #ifdef USE_OTG_HOST_MODE 45 46 usb_sts_type usbh_ctrl_send_setup(usbh_core_type *uhost, uint8_t *buffer, uint8_t hc_num); 47 usb_sts_type usbh_ctrl_recv_data(usbh_core_type *uhost, uint8_t *buffer, 48 uint16_t length, uint16_t hc_num); 49 usb_sts_type usbh_ctrl_send_data(usbh_core_type *uhost, uint8_t *buffer, 50 uint16_t length, uint16_t hc_num); 51 usb_sts_type usbh_ctrl_setup_handler(usbh_core_type *uhost); 52 usb_sts_type usbh_ctrl_setup_wait_handler(usbh_core_type *uhost, uint32_t *timeout); 53 usb_sts_type usbh_ctrl_data_in_handler(usbh_core_type *uhost); 54 usb_sts_type usbh_ctrl_data_in_wait_handler(usbh_core_type *uhost, uint32_t timeout); 55 usb_sts_type usbh_ctrl_data_out_handler(usbh_core_type *uhost); 56 usb_sts_type usbh_ctrl_data_out_wait_handler(usbh_core_type *uhost, uint32_t timeout); 57 usb_sts_type usbh_ctrl_status_in_handler(usbh_core_type *uhost); 58 usb_sts_type usbh_ctrl_status_in_wait_handler(usbh_core_type *uhost, uint32_t timeout); 59 usb_sts_type usbh_ctrl_status_out_handler(usbh_core_type *uhost); 60 usb_sts_type usbh_ctrl_status_out_wait_handler(usbh_core_type *uhost, uint32_t timeout); 61 usb_sts_type usbh_ctrl_error_handler(usbh_core_type *uhost); 62 usb_sts_type usbh_ctrl_stall_handler(usbh_core_type *uhost); 63 usb_sts_type usbh_ctrl_complete_handler(usbh_core_type *uhost); 64 usb_sts_type usbh_ctrl_transfer_loop(usbh_core_type *uhost); 65 usb_sts_type usbh_ctrl_request(usbh_core_type *uhost, uint8_t *buffer, uint16_t length); 66 usb_sts_type usbh_get_descriptor(usbh_core_type *uhost, uint16_t length, 67 uint8_t req_type, uint16_t wvalue, 68 uint8_t *buffer); 69 void usbh_parse_dev_desc(usbh_core_type *uhost, uint8_t *buffer, uint16_t length); 70 usb_header_desc_type *usbh_get_next_header(uint8_t *buf, uint16_t *index_len); 71 void usbh_parse_interface_desc(usb_interface_desc_type *intf, uint8_t *buf); 72 void usbh_parse_endpoint_desc(usb_endpoint_desc_type *ept_desc, uint8_t *buf); 73 usb_sts_type usbh_parse_configure_desc(usbh_core_type *uhost, 74 uint8_t *buffer, uint16_t length); 75 uint8_t usbh_find_interface(usbh_core_type *uhost, uint8_t class_code, uint8_t sub_class, uint8_t protocol); 76 void usbh_parse_string_desc(uint8_t *src, uint8_t *dest, uint16_t length); 77 usb_sts_type usbh_get_device_descriptor(usbh_core_type *uhost, uint16_t length); 78 usb_sts_type usbh_get_configure_descriptor(usbh_core_type *uhost, uint16_t length); 79 usb_sts_type usbh_get_sting_descriptor(usbh_core_type *uhost, uint8_t string_id, 80 uint8_t *buffer, uint16_t length); 81 usb_sts_type usbh_set_configuration(usbh_core_type *uhost, uint16_t config); 82 usb_sts_type usbh_set_address(usbh_core_type *uhost, uint8_t address); 83 usb_sts_type usbh_set_interface(usbh_core_type *uhost, uint8_t ept_num, uint8_t altsetting); 84 usb_sts_type usbh_set_feature(usbh_core_type *uhost, uint8_t feature, uint16_t index); 85 usb_sts_type usbh_clear_dev_feature(usbh_core_type *uhost, uint8_t feature, uint16_t index); 86 usb_sts_type usbh_clear_ept_feature(usbh_core_type *uhost, uint8_t ept_num, uint8_t hc_num); 87 88 #endif 89 90 /** 91 * @} 92 */ 93 94 /** 95 * @} 96 */ 97 98 #ifdef __cplusplus 99 } 100 #endif 101 102 #endif 103