mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-16 15:04:22 +00:00
feat(ext_hub): Added External Hub driver
This commit is contained in:
@@ -66,7 +66,34 @@ typedef enum {
|
||||
} usb_hub_port_feature_t;
|
||||
|
||||
/**
|
||||
* @brief Size of a USB Hub Port Status and Hub Change results
|
||||
* @brief USB Hub characteristics
|
||||
*
|
||||
* See USB 2.0 spec Table 11-13, offset 3
|
||||
*/
|
||||
#define USB_W_HUB_CHARS_PORT_PWR_CTRL_ALL (0) /**< All ports power control at once */
|
||||
#define USB_W_HUB_CHARS_PORT_PWR_CTRL_INDV (1) /**< Individual port power control */
|
||||
#define USB_W_HUB_CHARS_PORT_PWR_CTRL_NO (2) /**< No power switching */
|
||||
|
||||
#define USB_W_HUB_CHARS_PORT_OVER_CURR_ALL (0) /**< All ports Over-Current reporting */
|
||||
#define USB_W_HUB_CHARS_PORT_OVER_CURR_INDV (1) /**< Individual port Over-current reporting */
|
||||
#define USB_W_HUB_CHARS_PORT_OVER_CURR_NO (2) /**< No Over-current Protection support */
|
||||
|
||||
#define USB_W_HUB_CHARS_TTTT_8_BITS (0) /**< TT requires at most 8 FS bit times of inter transaction gap on a full-/low-speed downstream bus */
|
||||
#define USB_W_HUB_CHARS_TTTT_16_BITS (1) /**< TT requires at most 16 FS bit times */
|
||||
#define USB_W_HUB_CHARS_TTTT_24_BITS (2) /**< TT requires at most 24 FS bit times */
|
||||
#define USB_W_HUB_CHARS_TTTT_32_BITS (3) /**< TT requires at most 32 FS bit times */
|
||||
|
||||
/**
|
||||
* @brief USB Hub bDeviceProtocol
|
||||
*/
|
||||
#define USB_B_DEV_PROTOCOL_HUB_FS (0) /**< Full speed hub */
|
||||
#define USB_B_DEV_PROTOCOL_HUB_HS_NO_TT (0) /**< Hi-speed hub without TT */
|
||||
#define USB_B_DEV_PROTOCOL_HUB_HS_SINGLE_TT (1) /**< Hi-speed hub with single TT */
|
||||
#define USB_B_DEV_PROTOCOL_HUB_HS_MULTI_TT (2) /**< Hi-speed hub with multiple TT */
|
||||
#define USB_B_DEV_PROTOCOL_HUB_SS (3) /**< Super speed hub */
|
||||
|
||||
/**
|
||||
* @brief USB Hub Port Status and Hub Change results size
|
||||
*/
|
||||
#define USB_PORT_STATUS_SIZE 4
|
||||
|
||||
@@ -148,7 +175,17 @@ typedef struct {
|
||||
uint8_t bDescLength; /**< Number of bytes in this descriptor, including this byte */
|
||||
uint8_t bDescriptorType; /**< Descriptor Type, value: 29H for Hub descriptor */
|
||||
uint8_t bNbrPorts; /**< Number of downstream facing ports that this Hub supports */
|
||||
uint16_t wHubCharacteristics; /**< Logical Power Switching Mode, Compound Device, Over-current Protection Mode, TT Think Time, Port Indicators Supported */
|
||||
union {
|
||||
struct {
|
||||
uint16_t power_switching: 2;
|
||||
uint16_t compound: 1;
|
||||
uint16_t ovr_current_protect: 2;
|
||||
uint16_t tt_think_time: 2;
|
||||
uint16_t indicator_support: 1;
|
||||
uint16_t reserved: 8;
|
||||
};
|
||||
uint16_t val; /**< Hub Characteristics value */
|
||||
} wHubCharacteristics; /**< Hub Characteristics */
|
||||
uint8_t bPwrOn2PwrGood; /**< Time (in 2 ms intervals) from the time the power-on sequence begins on a port until power is good on that port */
|
||||
uint8_t bHubContrCurrent; /**< Maximum current requirements of the Hub Controller electronics in mA. */
|
||||
} __attribute__((packed)) usb_hub_descriptor_t;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -101,6 +101,21 @@ typedef union {
|
||||
} usb_setup_packet_t;
|
||||
ESP_STATIC_ASSERT(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of usb_setup_packet_t incorrect");
|
||||
|
||||
/**
|
||||
* @brief Structure representing a USB device status
|
||||
*
|
||||
* See Figures 9-4 Information Returned by a GetStatus() Request to a Device of USB2.0 specification for more details
|
||||
*/
|
||||
typedef union {
|
||||
struct {
|
||||
uint16_t self_powered: 1; /**< 1 - Device is currently self-powered, 0 - bus powered */
|
||||
uint16_t remote_wakeup: 1; /**< 1 - the ability of the device to signal remote wakeup is enabled, 0 - the ability of the device to signal remote wakeup is disabled. */
|
||||
uint16_t reserved: 14; /**< reserved */
|
||||
} USB_DESC_ATTR; /**< Packed */
|
||||
uint16_t val; /**< Device status value */
|
||||
} usb_device_status_t;
|
||||
ESP_STATIC_ASSERT(sizeof(usb_device_status_t) == sizeof(uint16_t), "Size of usb_device_status_t incorrect");
|
||||
|
||||
/**
|
||||
* @brief Bit masks belonging to the bmRequestType field of a setup packet
|
||||
*/
|
||||
@@ -144,6 +159,19 @@ ESP_STATIC_ASSERT(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of
|
||||
#define USB_W_VALUE_DT_OTHER_SPEED_CONFIG 0x07
|
||||
#define USB_W_VALUE_DT_INTERFACE_POWER 0x08
|
||||
|
||||
/**
|
||||
* @brief Initializer for a GET_STATUS request
|
||||
*
|
||||
* Sets the address of a connected device
|
||||
*/
|
||||
#define USB_SETUP_PACKET_INIT_GET_STATUS(setup_pkt_ptr) ({ \
|
||||
(setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_IN | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(setup_pkt_ptr)->bRequest = USB_B_REQUEST_GET_STATUS; \
|
||||
(setup_pkt_ptr)->wValue = 0; \
|
||||
(setup_pkt_ptr)->wIndex = 0; \
|
||||
(setup_pkt_ptr)->wLength = 2; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Initializer for a SET_ADDRESS request
|
||||
*
|
||||
|
Reference in New Issue
Block a user