feat: Add support for USB 3.0
This commit is contained in:
parent
c4bacc62ce
commit
c9113ee08f
|
@ -182,7 +182,7 @@ __FORCEINLINE void DAP_SPI_Send_Header(const uint8_t packetHeaderData, uint8_t *
|
||||||
*/
|
*/
|
||||||
__FORCEINLINE void DAP_SPI_Read_Data(uint32_t *resData, uint8_t *resParity)
|
__FORCEINLINE void DAP_SPI_Read_Data(uint32_t *resData, uint8_t *resParity)
|
||||||
{
|
{
|
||||||
uint64_t dataBuf;
|
volatile uint64_t dataBuf;
|
||||||
uint32_t *pU32Data = (uint32_t *)&dataBuf;
|
uint32_t *pU32Data = (uint32_t *)&dataBuf;
|
||||||
|
|
||||||
DAP_SPI.user.usr_mosi = 0;
|
DAP_SPI.user.usr_mosi = 0;
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
* @file MSOS20Descriptors.c
|
* @file MSOS20Descriptors.c
|
||||||
* @author windowsair
|
* @author windowsair
|
||||||
* @brief Store related data of Microsoft OS 2.0 descriptor
|
* @brief Store related data of Microsoft OS 2.0 descriptor
|
||||||
* @version 0.1
|
* @change: 2021-5-12 Add support for USB 3.0
|
||||||
* @date 2019-11-21
|
* @version 0.2
|
||||||
|
* @date 2021-5-12
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2019
|
* @copyright Copyright (c) 2021
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -57,22 +58,48 @@ const uint8_t msOs20DescriptorSetHeader[kLengthOfMsOS20] =
|
||||||
|
|
||||||
const uint8_t bosDescriptor[kLengthOfBos] =
|
const uint8_t bosDescriptor[kLengthOfBos] =
|
||||||
{
|
{
|
||||||
// Universal Serial Bus 3.0 Specification, Table 9-9.
|
// USB 3.0 Specification, Table 9-9.
|
||||||
0x05, // bLength of this descriptor
|
0x05, // bLength of this descriptor
|
||||||
USB_DESCRIPTOR_TYPE_BOS, // BOS Descriptor type(Constant)
|
USB_DESCRIPTOR_TYPE_BOS, // BOS Descriptor type(Constant)
|
||||||
USBShort(kLengthOfBos), // wLength
|
USBShort(kLengthOfBos), // wLength
|
||||||
|
|
||||||
|
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
0x03, // bNumDeviceCaps -> USB2.0 extension & SuperSpeed USB Device & OS2.0 descriptor
|
||||||
|
#else
|
||||||
0x01, // bNumDeviceCaps -> only 0x01 for OS2.0 descriptor
|
0x01, // bNumDeviceCaps -> only 0x01 for OS2.0 descriptor
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
// USB 2.0 extension, USB 3.0 Specification, Table 9-12.
|
||||||
|
0x07, // bLength of this descriptor
|
||||||
|
USB_DESCRIPTOR_TYPE_DEVICE_CAPABILITY, // DEVICE CAPABILITY Descriptor type
|
||||||
|
USB_DEVICE_CAPABILITY_TYPE_USB2_0_EXTENSION, // Capability type: USB 2.0 EXTENSION
|
||||||
|
0x02, 0x00, 0x00, 0x00, // bmAttributes -> LPM Support
|
||||||
|
|
||||||
|
// SuperSpeed USB Device, USB 3.0 Specification, Table 9-13.
|
||||||
|
0x0A, // bLength of this descriptor
|
||||||
|
USB_DESCRIPTOR_TYPE_DEVICE_CAPABILITY, // DEVICE CAPABILITY Descriptor type
|
||||||
|
USB_DEVICE_CAPABILITY_TYPE_SUPERSPEED_USB, // Capability type: SUPERSPEED_USB
|
||||||
|
0x00, // bmAttributes -> LTM Capable
|
||||||
|
0x08, 0x00, // wSpeedsSupported -> only support SuperSpeed
|
||||||
|
0x03, // bFunctionalitySupport
|
||||||
|
0x00, // bU1DevExitLat -> 0 may be ok
|
||||||
|
0x00, 0x00, // wU2DevExitLat -> 0 may be ok
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Microsoft OS 2.0 platform capability descriptor header (Table 4)
|
// Microsoft OS 2.0 platform capability descriptor header (Table 4)
|
||||||
// See also:
|
// See also:
|
||||||
// Universal Serial Bus 3.0 Specification : Format of a Device Capability Descriptor, Table 9-10.
|
// USB 3.0 Specification : Format of a Device Capability Descriptor, Table 9-10.
|
||||||
|
|
||||||
0x1C, // bLength of this first device capability descriptor
|
0x1C, // bLength of this first device capability descriptor
|
||||||
// bLength -> The total length of the remaining arrays containing this field
|
// bLength -> The total length of the remaining arrays containing this field
|
||||||
USB_DESCRIPTOR_TYPE_DEVICE_CAPABILITY, // bDescriptorType
|
USB_DESCRIPTOR_TYPE_DEVICE_CAPABILITY, // bDescriptorType
|
||||||
USB_DEVICE_CAPABILITY_TYPE_PLATFORM, // bDevCapabilityType
|
USB_DEVICE_CAPABILITY_TYPE_PLATFORM, // bDevCapabilityType
|
||||||
|
|
||||||
// Capability-Dependent (See USB3.0 Specification Table 9-10.)
|
// Capability-Dependent (See USB 3.0 Specification Table 9-10.)
|
||||||
0x00, // bReserved
|
0x00, // bReserved
|
||||||
USB_DEVICE_CAPABILITY_UUID, // MS_OS_20_Platform_Capability_ID
|
USB_DEVICE_CAPABILITY_UUID, // MS_OS_20_Platform_Capability_ID
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,26 @@
|
||||||
* @file MSOS20Descriptors.h
|
* @file MSOS20Descriptors.h
|
||||||
* @author windowsair
|
* @author windowsair
|
||||||
* @brief
|
* @brief
|
||||||
* @version 0.1
|
* @version 0.2
|
||||||
* @date 2019-11-21
|
* @date 2021-5-12
|
||||||
*
|
*
|
||||||
* @copyright Copyright (c) 2019
|
* @copyright Copyright (c) 2021
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __MSOS20DESCRIPTORS_H__
|
#ifndef __MSOS20DESCRIPTORS_H__
|
||||||
#define __MSOS20DESCRIPTORS_H__
|
#define __MSOS20DESCRIPTORS_H__
|
||||||
|
|
||||||
|
#include "dap_configuration.h"
|
||||||
|
|
||||||
#define kLengthOfMsOS20 0xA2
|
#define kLengthOfMsOS20 0xA2
|
||||||
|
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
#define kLengthOfBos 0x32
|
||||||
|
#else
|
||||||
#define kLengthOfBos 0x21
|
#define kLengthOfBos 0x21
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
#define kValueOfbMS_VendorCode 0x01// Just set to 0x01
|
#define kValueOfbMS_VendorCode 0x01// Just set to 0x01
|
||||||
extern const uint8_t bosDescriptor[kLengthOfBos];
|
extern const uint8_t bosDescriptor[kLengthOfBos];
|
||||||
extern const uint8_t msOs20DescriptorSetHeader[kLengthOfMsOS20];
|
extern const uint8_t msOs20DescriptorSetHeader[kLengthOfMsOS20];
|
||||||
|
@ -23,6 +31,11 @@ extern const uint8_t msOs20DescriptorSetHeader[kLengthOfMsOS20];
|
||||||
// Platform capability BOS descriptor, Table 1.
|
// Platform capability BOS descriptor, Table 1.
|
||||||
#define USB_DEVICE_CAPABILITY_TYPE_PLATFORM 5
|
#define USB_DEVICE_CAPABILITY_TYPE_PLATFORM 5
|
||||||
|
|
||||||
|
// USB 2.0 Extension Descriptor, USB3.0 Specification Table 9-11
|
||||||
|
#define USB_DEVICE_CAPABILITY_TYPE_USB2_0_EXTENSION 2
|
||||||
|
// SuperSpeed USB specific device level capabilities, USB3.0 Specification Table 9-11
|
||||||
|
#define USB_DEVICE_CAPABILITY_TYPE_SUPERSPEED_USB 3
|
||||||
|
|
||||||
// Platform capability UUID, Table 3.
|
// Platform capability UUID, Table 3.
|
||||||
// {D8DD60DF-4589-4CC7-9CD2-659D9E648A9F}
|
// {D8DD60DF-4589-4CC7-9CD2-659D9E648A9F}
|
||||||
#define USB_DEVICE_CAPABILITY_UUID 0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, 0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F
|
#define USB_DEVICE_CAPABILITY_UUID 0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, 0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
/**
|
/**
|
||||||
* @file USBd_config.c
|
* @file USBd_config.c
|
||||||
* @brief Standard USB Descriptor Definitions
|
* @brief Standard USB Descriptor Definitions
|
||||||
fix bugs 2020-1-23
|
* @change: 2020-1-23 : fix bugs
|
||||||
|
* 2021-5-12 : Add support for USB 3.0
|
||||||
* @version 0.2
|
* @version 0.2
|
||||||
* @date 2020-1-23
|
* @date 2020-1-23
|
||||||
*
|
*
|
||||||
|
@ -13,7 +14,7 @@
|
||||||
#include "USBd_config.h"
|
#include "USBd_config.h"
|
||||||
#include "usb_defs.h"
|
#include "usb_defs.h"
|
||||||
|
|
||||||
#define USBShort(ui16Value) ((ui16Value) & 0xff), ((ui16Value) >> 8) //((ui16Value) & 0xFF),(((ui16Value) >> 8) & 0xFF)
|
#define USBShort(ui16Value) ((ui16Value) & 0xff), ((ui16Value) >> 8)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,10 +29,16 @@ const uint8_t kUSBd0DeviceDescriptor[0x12] =
|
||||||
USB_DT_DEVICE, // bDescriptorType
|
USB_DT_DEVICE, // bDescriptorType
|
||||||
|
|
||||||
#if (USE_WINUSB == 1)
|
#if (USE_WINUSB == 1)
|
||||||
USBShort(0x0210), // bcdUSB
|
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
USBShort(0x0300), // bcdUSB
|
||||||
|
#else
|
||||||
|
USBShort(0x210), // bcdUSB
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
USBShort(0x0200), // bcdUSB
|
USBShort(0x0200), // bcdUSB
|
||||||
#endif
|
#endif // (USE_WINUSB == 1)
|
||||||
////TODO: Is it also available elsewhere?
|
////TODO: Is it also available elsewhere?
|
||||||
|
|
||||||
// We need to use a device other than the USB-IF standard, set to 0x00
|
// We need to use a device other than the USB-IF standard, set to 0x00
|
||||||
|
@ -39,7 +46,11 @@ const uint8_t kUSBd0DeviceDescriptor[0x12] =
|
||||||
0x00, // bDeviceSubClass
|
0x00, // bDeviceSubClass
|
||||||
0x00, // bDeviceProtocol
|
0x00, // bDeviceProtocol
|
||||||
|
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
0x09, // bMaxPacketSize0, for USB 3.0 must set to 0x09(2^9)
|
||||||
|
#else
|
||||||
USBD0_MAX_PACKET0, // bMaxPacketSize0 Maximum packet size for default pipe.
|
USBD0_MAX_PACKET0, // bMaxPacketSize0 Maximum packet size for default pipe.
|
||||||
|
#endif
|
||||||
USBShort(USBD0_DEV_DESC_IDVENDOR), // idVendor Vendor ID (VID).
|
USBShort(USBD0_DEV_DESC_IDVENDOR), // idVendor Vendor ID (VID).
|
||||||
USBShort(USBD0_DEV_DESC_IDPRODUCT), // idProduct Product ID (PID).
|
USBShort(USBD0_DEV_DESC_IDPRODUCT), // idProduct Product ID (PID).
|
||||||
USBShort(USBD0_DEV_DESC_BCDDEVICE), // bcdDevice Device Version BCD.
|
USBShort(USBD0_DEV_DESC_BCDDEVICE), // bcdDevice Device Version BCD.
|
||||||
|
@ -61,7 +72,7 @@ const uint8_t kUSBd0DeviceDescriptor[0x12] =
|
||||||
// Standard Interface Descriptor
|
// Standard Interface Descriptor
|
||||||
|
|
||||||
#if (USE_WINUSB ==1)
|
#if (USE_WINUSB ==1)
|
||||||
const uint8_t kUSBd0InterfaceDescriptor[0x1E]=
|
const uint8_t kUSBd0InterfaceDescriptor[]=
|
||||||
{
|
{
|
||||||
0x09, // bLength
|
0x09, // bLength
|
||||||
USB_DT_INTERFACE, // bDescriptorType
|
USB_DT_INTERFACE, // bDescriptorType
|
||||||
|
@ -98,10 +109,19 @@ const uint8_t kUSBd0InterfaceDescriptor[0x1E]=
|
||||||
USB_DT_ENDPOINT, // bDescriptorType
|
USB_DT_ENDPOINT, // bDescriptorType
|
||||||
0x01, // bEndpointAddress
|
0x01, // bEndpointAddress
|
||||||
USB_ENDPOINT_ATTR_BULK, // bmAttributes
|
USB_ENDPOINT_ATTR_BULK, // bmAttributes
|
||||||
USBShort(512), // wMaxPacketSize
|
USBShort(USB_ENDPOINT_SIZE), // wMaxPacketSize
|
||||||
// We assume that it always runs in High Speed.
|
|
||||||
0x00, // bInterval
|
0x00, // bInterval
|
||||||
|
|
||||||
|
/* SuperSpeed Endpoint Companion */
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
0x06, // bLength
|
||||||
|
USB_DT_SUPERSPEED_USB_ENDPOINT_COMPANION, // bDescriptorType
|
||||||
|
0x00, // bMaxBurst
|
||||||
|
0x00, // bmAttributes(MaxStream for Bulk)
|
||||||
|
0x00, 0x00, // wBytesPerInterval -> 0 for Bulk
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
|
|
||||||
/* Pysical endpoint 1 */
|
/* Pysical endpoint 1 */
|
||||||
|
|
||||||
// "Endpoint 2: Bulk In – used for responses send to host PC." Device -> PC
|
// "Endpoint 2: Bulk In – used for responses send to host PC." Device -> PC
|
||||||
|
@ -109,9 +129,19 @@ const uint8_t kUSBd0InterfaceDescriptor[0x1E]=
|
||||||
USB_DT_ENDPOINT, // bDescriptorType
|
USB_DT_ENDPOINT, // bDescriptorType
|
||||||
0x81, // bEndpointAddress
|
0x81, // bEndpointAddress
|
||||||
USB_ENDPOINT_ATTR_BULK, // bmAttributes
|
USB_ENDPOINT_ATTR_BULK, // bmAttributes
|
||||||
USBShort(512), // wMaxPacketSize
|
USBShort(USB_ENDPOINT_SIZE), // wMaxPacketSize
|
||||||
0x00, // bInterval
|
0x00, // bInterval
|
||||||
|
|
||||||
|
/* SuperSpeed Endpoint Companion */
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
0x06, // bLength
|
||||||
|
USB_DT_SUPERSPEED_USB_ENDPOINT_COMPANION, // bDescriptorType
|
||||||
|
0x00, // bMaxBurst
|
||||||
|
0x00, // bmAttributes(MaxStream for Bulk)
|
||||||
|
0x00, 0x00, // wBytesPerInterval -> 0 for Bulk
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
|
|
||||||
/* Pysical endpoint 2 */
|
/* Pysical endpoint 2 */
|
||||||
|
|
||||||
// "Endpoint 3: Bulk In (optional) – used for streaming SWO trace" Device -> PC
|
// "Endpoint 3: Bulk In (optional) – used for streaming SWO trace" Device -> PC
|
||||||
|
@ -119,9 +149,17 @@ const uint8_t kUSBd0InterfaceDescriptor[0x1E]=
|
||||||
USB_DT_ENDPOINT, // bDescriptorType
|
USB_DT_ENDPOINT, // bDescriptorType
|
||||||
0x82, // bEndpointAddress
|
0x82, // bEndpointAddress
|
||||||
USB_ENDPOINT_ATTR_BULK, // bmAttributes
|
USB_ENDPOINT_ATTR_BULK, // bmAttributes
|
||||||
USBShort(512), // wMaxPacketSize
|
USBShort(USB_ENDPOINT_SIZE), // wMaxPacketSize
|
||||||
0x00, // bInterval
|
0x00, // bInterval
|
||||||
|
|
||||||
|
/* SuperSpeed Endpoint Companion */
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
0x06, // bLength
|
||||||
|
USB_DT_SUPERSPEED_USB_ENDPOINT_COMPANION, // bDescriptorType
|
||||||
|
0x00, // bMaxBurst
|
||||||
|
0x00, // bmAttributes(MaxStream for Bulk)
|
||||||
|
0x00, 0x00, // wBytesPerInterval -> 0 for Bulk
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,13 @@ extern const uint8_t kProductString[0x18];
|
||||||
extern const uint8_t kSerialNumberString[0x1A];
|
extern const uint8_t kSerialNumberString[0x1A];
|
||||||
|
|
||||||
#if (USE_WINUSB == 1)
|
#if (USE_WINUSB == 1)
|
||||||
|
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
extern const uint8_t kUSBd0InterfaceDescriptor[0x30];
|
||||||
|
#else
|
||||||
extern const uint8_t kUSBd0InterfaceDescriptor[0x1E];
|
extern const uint8_t kUSBd0InterfaceDescriptor[0x1E];
|
||||||
|
#endif // USE_USB_3_0 == 1
|
||||||
|
|
||||||
extern const uint8_t kUSBd0ConfigDescriptor[0x09];
|
extern const uint8_t kUSBd0ConfigDescriptor[0x09];
|
||||||
extern const uint8_t kInterfaceString[0x2C];
|
extern const uint8_t kInterfaceString[0x2C];
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ typedef struct
|
||||||
#define USB_DT_OTHER_SPEED_CONFIGURATION 7
|
#define USB_DT_OTHER_SPEED_CONFIGURATION 7
|
||||||
#define USB_DT_INTERFACE_POWER 8
|
#define USB_DT_INTERFACE_POWER 8
|
||||||
#define USB_DT_BOS 15
|
#define USB_DT_BOS 15
|
||||||
|
#define USB_DT_SUPERSPEED_USB_ENDPOINT_COMPANION 48
|
||||||
/* From ECNs */
|
/* From ECNs */
|
||||||
#define USB_DT_OTG 9
|
#define USB_DT_OTG 9
|
||||||
#define USB_DT_DEBUG 10
|
#define USB_DT_DEBUG 10
|
||||||
|
|
|
@ -13,6 +13,21 @@
|
||||||
*/
|
*/
|
||||||
#define USE_SPI_SIO 1
|
#define USE_SPI_SIO 1
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Specify to enable USB 3.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define USE_USB_3_0 0
|
||||||
|
|
||||||
|
|
||||||
|
// For USB 3.0, it must be 1024 byte.
|
||||||
|
#if (USE_USB_3_0 == 1)
|
||||||
|
#define USB_ENDPOINT_SIZE 1024U
|
||||||
|
#else
|
||||||
|
#define USB_ENDPOINT_SIZE 512U
|
||||||
|
#endif
|
||||||
|
|
||||||
/// Maximum Package Size for Command and Response data.
|
/// Maximum Package Size for Command and Response data.
|
||||||
/// This configuration settings is used to optimize the communication performance with the
|
/// This configuration settings is used to optimize the communication performance with the
|
||||||
/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
|
/// debugger and depends on the USB peripheral. Typical vales are 64 for Full-speed USB HID or WinUSB,
|
||||||
|
|
|
@ -37,7 +37,7 @@ int kSock = -1;
|
||||||
|
|
||||||
void tcp_server_task(void *pvParameters)
|
void tcp_server_task(void *pvParameters)
|
||||||
{
|
{
|
||||||
uint8_t tcp_rx_buffer[1024];
|
uint8_t tcp_rx_buffer[1500];
|
||||||
char addr_str[128];
|
char addr_str[128];
|
||||||
int addr_family;
|
int addr_family;
|
||||||
int ip_protocol;
|
int ip_protocol;
|
||||||
|
|
Loading…
Reference in New Issue