summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-09-17 21:58:06 +0800
committersakumisu <[email protected]>2022-09-17 21:58:06 +0800
commit887dbd33e32262b233ce013ea02b9c508348cb8d (patch)
tree8fd90cde4d26ea490676aa246ebb4170324fdaae
parent946b978053ace0caa9eefff467a266a2e37f0212 (diff)
add usb3.0 speed support
-rw-r--r--common/usb_def.h12
-rw-r--r--core/usbh_core.c31
2 files changed, 18 insertions, 25 deletions
diff --git a/common/usb_def.h b/common/usb_def.h
index 9e3fc41a..5aab5292 100644
--- a/common/usb_def.h
+++ b/common/usb_def.h
@@ -13,11 +13,13 @@
#define USB_2_1 0x0210
/* Device speeds */
-#define USB_SPEED_UNKNOWN 0 /* Transfer rate not yet set */
-#define USB_SPEED_LOW 1 /* USB 1.1 */
-#define USB_SPEED_FULL 2 /* USB 1.1 */
-#define USB_SPEED_HIGH 3 /* USB 2.0 */
-#define USB_SPEED_VARIABLE 4 /* Wireless USB 2.5 */
+#define USB_SPEED_UNKNOWN 0 /* Transfer rate not yet set */
+#define USB_SPEED_LOW 1 /* USB 1.1 */
+#define USB_SPEED_FULL 2 /* USB 1.1 */
+#define USB_SPEED_HIGH 3 /* USB 2.0 */
+#define USB_SPEED_WIRELESS 4 /* Wireless USB 2.5 */
+#define USB_SPEED_SUPER 5 /* USB 3.0 */
+#define USB_SPEED_SUPER_PLUS 5 /* USB 3.1 */
/* Maximum number of devices per controller */
#define USB_MAX_DEVICES (127)
diff --git a/core/usbh_core.c b/core/usbh_core.c
index b03cf632..ea36721e 100644
--- a/core/usbh_core.c
+++ b/core/usbh_core.c
@@ -388,33 +388,24 @@ int usbh_enumerate(struct usbh_hubport *hport)
struct usb_setup_packet *setup;
uint8_t descsize;
int dev_addr;
- uint8_t ep_mps;
+ uint16_t ep_mps;
int ret;
#define USB_REQUEST_BUFFER_SIZE 256
setup = &hport->setup;
- /* Pick an appropriate packet size for this device
- *
- * USB 2.0, Paragraph 5.5.3 "Control Transfer Packet Size Constraints"
- *
- * "An endpoint for control transfers specifies the maximum data
- * payload size that the endpoint can accept from or transmit to
- * the bus. The allowable maximum control transfer data payload
- * sizes for full-speed devices is 8, 16, 32, or 64 bytes; for
- * high-speed devices, it is 64 bytes and for low-speed devices,
- * it is 8 bytes. This maximum applies to the data payloads of the
- * Data packets following a Setup..."
- */
-
- if (hport->speed == USB_SPEED_HIGH) {
- /* For high-speed, we must use 64 bytes */
- ep_mps = 64;
- descsize = USB_SIZEOF_DEVICE_DESC;
- } else {
- /* For low or full, we use 8 bytes */
+ if ((hport->speed == USB_SPEED_SUPER) || (hport->speed == USB_SPEED_SUPER_PLUS)) {
+ /* For super speed , we must use 512 bytes */
+ ep_mps = 512;
+ descsize = 8;
+ } else if (hport->speed == USB_SPEED_LOW) {
+ /* For low speed, we use 8 bytes */
ep_mps = 8;
descsize = 8;
+ } else {
+ /* For full or high speed, we use 64 bytes */
+ ep_mps = 64;
+ descsize = 8;
}
/* Configure EP0 with the initial maximum packet size */