mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-05 21:54:33 +02:00
refactor(usb_host): Remove val types from USB Host stack
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -89,15 +89,12 @@ typedef enum {
|
|||||||
*
|
*
|
||||||
* See Table 9-2 of USB2.0 specification for more details
|
* See Table 9-2 of USB2.0 specification for more details
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bmRequestType; /**< Characteristics of request */
|
uint8_t bmRequestType; /**< Characteristics of request */
|
||||||
uint8_t bRequest; /**< Specific request */
|
uint8_t bRequest; /**< Specific request */
|
||||||
uint16_t wValue; /**< Word-sized field that varies according to request */
|
uint16_t wValue; /**< Word-sized field that varies according to request */
|
||||||
uint16_t wIndex; /**< Word-sized field that varies according to request; typically used to pass an index or offset */
|
uint16_t wIndex; /**< Word-sized field that varies according to request; typically used to pass an index or offset */
|
||||||
uint16_t wLength; /**< Number of bytes to transfer if there is a data stage */
|
uint16_t wLength; /**< Number of bytes to transfer if there is a data stage */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_SETUP_PACKET_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_setup_packet_t;
|
} usb_setup_packet_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of usb_setup_packet_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of usb_setup_packet_t incorrect");
|
||||||
|
|
||||||
@@ -106,13 +103,10 @@ ESP_STATIC_ASSERT(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of
|
|||||||
*
|
*
|
||||||
* See Figures 9-4 Information Returned by a GetStatus() Request to a Device of USB2.0 specification for more details
|
* See Figures 9-4 Information Returned by a GetStatus() Request to a Device of USB2.0 specification for more details
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint16_t self_powered: 1; /**< 1 - Device is currently self-powered, 0 - bus powered */
|
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 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 */
|
uint16_t reserved: 14; /**< reserved */
|
||||||
} USB_DESC_ATTR; /**< Packed */
|
|
||||||
uint16_t val; /**< Device status value */
|
|
||||||
} usb_device_status_t;
|
} usb_device_status_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_device_status_t) == sizeof(uint16_t), "Size of usb_device_status_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_device_status_t) == sizeof(uint16_t), "Size of usb_device_status_t incorrect");
|
||||||
|
|
||||||
@@ -266,12 +260,9 @@ ESP_STATIC_ASSERT(sizeof(usb_device_status_t) == sizeof(uint16_t), "Size of usb_
|
|||||||
*
|
*
|
||||||
* All USB standard descriptors start with these two bytes. Use this type when traversing over configuration descriptors
|
* All USB standard descriptors start with these two bytes. Use this type when traversing over configuration descriptors
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< Descriptor Type */
|
uint8_t bDescriptorType; /**< Descriptor Type */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_STANDARD_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_standard_desc_t;
|
} usb_standard_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_standard_desc_t) == USB_STANDARD_DESC_SIZE, "Size of usb_standard_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_standard_desc_t) == USB_STANDARD_DESC_SIZE, "Size of usb_standard_desc_t incorrect");
|
||||||
|
|
||||||
@@ -287,8 +278,7 @@ ESP_STATIC_ASSERT(sizeof(usb_standard_desc_t) == USB_STANDARD_DESC_SIZE, "Size o
|
|||||||
*
|
*
|
||||||
* See Table 9-8 of USB2.0 specification for more details
|
* See Table 9-8 of USB2.0 specification for more details
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< DEVICE Descriptor Type */
|
uint8_t bDescriptorType; /**< DEVICE Descriptor Type */
|
||||||
uint16_t bcdUSB; /**< USB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H) */
|
uint16_t bcdUSB; /**< USB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H) */
|
||||||
@@ -303,8 +293,6 @@ typedef union {
|
|||||||
uint8_t iProduct; /**< Index of string descriptor describing product */
|
uint8_t iProduct; /**< Index of string descriptor describing product */
|
||||||
uint8_t iSerialNumber; /**< Index of string descriptor describing the device’s serial number */
|
uint8_t iSerialNumber; /**< Index of string descriptor describing the device’s serial number */
|
||||||
uint8_t bNumConfigurations; /**< Number of possible configurations */
|
uint8_t bNumConfigurations; /**< Number of possible configurations */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_DEVICE_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_device_desc_t;
|
} usb_device_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_device_desc_t) == USB_DEVICE_DESC_SIZE, "Size of usb_device_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_device_desc_t) == USB_DEVICE_DESC_SIZE, "Size of usb_device_desc_t incorrect");
|
||||||
|
|
||||||
@@ -356,8 +344,7 @@ ESP_STATIC_ASSERT(sizeof(usb_device_desc_t) == USB_DEVICE_DESC_SIZE, "Size of us
|
|||||||
* @note The full USB configuration includes all the interface and endpoint
|
* @note The full USB configuration includes all the interface and endpoint
|
||||||
* descriptors of that configuration.
|
* descriptors of that configuration.
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< CONFIGURATION Descriptor Type */
|
uint8_t bDescriptorType; /**< CONFIGURATION Descriptor Type */
|
||||||
uint16_t wTotalLength; /**< Total length of data returned for this configuration */
|
uint16_t wTotalLength; /**< Total length of data returned for this configuration */
|
||||||
@@ -366,8 +353,6 @@ typedef union {
|
|||||||
uint8_t iConfiguration; /**< Index of string descriptor describing this configuration */
|
uint8_t iConfiguration; /**< Index of string descriptor describing this configuration */
|
||||||
uint8_t bmAttributes; /**< Configuration characteristics */
|
uint8_t bmAttributes; /**< Configuration characteristics */
|
||||||
uint8_t bMaxPower; /**< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. */
|
uint8_t bMaxPower; /**< Maximum power consumption of the USB device from the bus in this specific configuration when the device is fully operational. */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_CONFIG_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_config_desc_t;
|
} usb_config_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_config_desc_t) == USB_CONFIG_DESC_SIZE, "Size of usb_config_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_config_desc_t) == USB_CONFIG_DESC_SIZE, "Size of usb_config_desc_t incorrect");
|
||||||
|
|
||||||
@@ -384,13 +369,12 @@ ESP_STATIC_ASSERT(sizeof(usb_config_desc_t) == USB_CONFIG_DESC_SIZE, "Size of us
|
|||||||
/**
|
/**
|
||||||
* @brief Size of a USB interface association descriptor in bytes
|
* @brief Size of a USB interface association descriptor in bytes
|
||||||
*/
|
*/
|
||||||
#define USB_IAD_DESC_SIZE 9
|
#define USB_IAD_DESC_SIZE 8
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Structure representing a USB interface association descriptor
|
* @brief Structure representing a USB interface association descriptor
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< INTERFACE ASSOCIATION Descriptor Type */
|
uint8_t bDescriptorType; /**< INTERFACE ASSOCIATION Descriptor Type */
|
||||||
uint8_t bFirstInterface; /**< Interface number of the first interface that is associated with this function */
|
uint8_t bFirstInterface; /**< Interface number of the first interface that is associated with this function */
|
||||||
@@ -399,8 +383,6 @@ typedef union {
|
|||||||
uint8_t bFunctionSubClass; /**< Subclass code (assigned by USB-IF) */
|
uint8_t bFunctionSubClass; /**< Subclass code (assigned by USB-IF) */
|
||||||
uint8_t bFunctionProtocol; /**< Protocol code (assigned by USB-IF) */
|
uint8_t bFunctionProtocol; /**< Protocol code (assigned by USB-IF) */
|
||||||
uint8_t iFunction; /**< Index of string descriptor describing this function */
|
uint8_t iFunction; /**< Index of string descriptor describing this function */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_IAD_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_iad_desc_t;
|
} usb_iad_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_iad_desc_t) == USB_IAD_DESC_SIZE, "Size of usb_iad_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_iad_desc_t) == USB_IAD_DESC_SIZE, "Size of usb_iad_desc_t incorrect");
|
||||||
|
|
||||||
@@ -416,8 +398,7 @@ ESP_STATIC_ASSERT(sizeof(usb_iad_desc_t) == USB_IAD_DESC_SIZE, "Size of usb_iad_
|
|||||||
*
|
*
|
||||||
* See Table 9-12 of USB2.0 specification for more details
|
* See Table 9-12 of USB2.0 specification for more details
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< INTERFACE Descriptor Type */
|
uint8_t bDescriptorType; /**< INTERFACE Descriptor Type */
|
||||||
uint8_t bInterfaceNumber; /**< Number of this interface. */
|
uint8_t bInterfaceNumber; /**< Number of this interface. */
|
||||||
@@ -427,8 +408,6 @@ typedef union {
|
|||||||
uint8_t bInterfaceSubClass; /**< Subclass code (assigned by the USB-IF) */
|
uint8_t bInterfaceSubClass; /**< Subclass code (assigned by the USB-IF) */
|
||||||
uint8_t bInterfaceProtocol; /**< Protocol code (assigned by the USB) */
|
uint8_t bInterfaceProtocol; /**< Protocol code (assigned by the USB) */
|
||||||
uint8_t iInterface; /**< Index of string descriptor describing this interface */
|
uint8_t iInterface; /**< Index of string descriptor describing this interface */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_INTF_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_intf_desc_t;
|
} usb_intf_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_intf_desc_t) == USB_INTF_DESC_SIZE, "Size of usb_intf_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_intf_desc_t) == USB_INTF_DESC_SIZE, "Size of usb_intf_desc_t incorrect");
|
||||||
|
|
||||||
@@ -444,16 +423,13 @@ ESP_STATIC_ASSERT(sizeof(usb_intf_desc_t) == USB_INTF_DESC_SIZE, "Size of usb_in
|
|||||||
*
|
*
|
||||||
* See Table 9-13 of USB2.0 specification for more details
|
* See Table 9-13 of USB2.0 specification for more details
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< ENDPOINT Descriptor Type */
|
uint8_t bDescriptorType; /**< ENDPOINT Descriptor Type */
|
||||||
uint8_t bEndpointAddress; /**< The address of the endpoint on the USB device described by this descriptor */
|
uint8_t bEndpointAddress; /**< The address of the endpoint on the USB device described by this descriptor */
|
||||||
uint8_t bmAttributes; /**< This field describes the endpoint’s attributes when it is configured using the bConfigurationValue. */
|
uint8_t bmAttributes; /**< This field describes the endpoint’s attributes when it is configured using the bConfigurationValue. */
|
||||||
uint16_t wMaxPacketSize; /**< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. */
|
uint16_t wMaxPacketSize; /**< Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. */
|
||||||
uint8_t bInterval; /**< Interval for polling Isochronous and Interrupt endpoints. Expressed in frames or microframes depending on the device operating speed (1 ms for Low-Speed and Full-Speed or 125 us for USB High-Speed and above). */
|
uint8_t bInterval; /**< Interval for polling Isochronous and Interrupt endpoints. Expressed in frames or microframes depending on the device operating speed (1 ms for Low-Speed and Full-Speed or 125 us for USB High-Speed and above). */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_EP_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_ep_desc_t;
|
} usb_ep_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_ep_desc_t) == USB_EP_DESC_SIZE, "Size of usb_ep_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_ep_desc_t) == USB_EP_DESC_SIZE, "Size of usb_ep_desc_t incorrect");
|
||||||
|
|
||||||
@@ -508,13 +484,10 @@ ESP_STATIC_ASSERT(sizeof(usb_ep_desc_t) == USB_EP_DESC_SIZE, "Size of usb_ep_des
|
|||||||
/**
|
/**
|
||||||
* @brief Structure representing a USB string descriptor
|
* @brief Structure representing a USB string descriptor
|
||||||
*/
|
*/
|
||||||
typedef union {
|
typedef struct USB_DESC_ATTR {
|
||||||
struct {
|
|
||||||
uint8_t bLength; /**< Size of the descriptor in bytes */
|
uint8_t bLength; /**< Size of the descriptor in bytes */
|
||||||
uint8_t bDescriptorType; /**< STRING Descriptor Type */
|
uint8_t bDescriptorType; /**< STRING Descriptor Type */
|
||||||
uint16_t wData[]; /**< UTF-16LE encoded */
|
uint16_t wData[]; /**< UTF-16LE encoded */
|
||||||
} USB_DESC_ATTR; /**< USB descriptor attributes */
|
|
||||||
uint8_t val[USB_STR_DESC_SIZE]; /**< Descriptor value */
|
|
||||||
} usb_str_desc_t;
|
} usb_str_desc_t;
|
||||||
ESP_STATIC_ASSERT(sizeof(usb_str_desc_t) == USB_STR_DESC_SIZE, "Size of usb_str_desc_t incorrect");
|
ESP_STATIC_ASSERT(sizeof(usb_str_desc_t) == USB_STR_DESC_SIZE, "Size of usb_str_desc_t incorrect");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user