You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/10/26 17:04:07 UTC
[mynewt-core] branch master updated: tinyusb: Add WINUSB descriptor
support
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 35b0596 tinyusb: Add WINUSB descriptor support
35b0596 is described below
commit 35b0596bd2bd9a459c042254e8b7d305974dcb36
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Thu Sep 30 16:19:31 2021 +0200
tinyusb: Add WINUSB descriptor support
This adds setting that allows device to be recognized as
WINUSB device.
---
.../tinyusb/std_descriptors/src/std_descriptors.c | 52 ++++++++++++++++++++++
hw/usb/tinyusb/std_descriptors/syscfg.yml | 13 ++++++
2 files changed, 65 insertions(+)
diff --git a/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c b/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c
index cd11dcf..194e5f6 100755
--- a/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c
+++ b/hw/usb/tinyusb/std_descriptors/src/std_descriptors.c
@@ -255,6 +255,53 @@ const char *string_desc_arr[] = {
static uint16_t desc_string[MYNEWT_VAL(USBD_STRING_DESCRIPTOR_MAX_LENGTH) + 1];
+#if MYNEWT_VAL(USBD_WINDOWS_COMP_ID)
+
+#define MICROSOFT_OS_STRING_DESCRIPTOR 0xEE
+#define COMPATIBILITY_FEATURE_REQUEST 0xFE
+
+static const uint8_t microsoft_os_string_descriptor[] = {
+ 0x12, /* BYTE Descriptor length (18 bytes) */
+ 0x03, /* BYTE Descriptor type (3 = String) */
+ 0x4D, 0x00, 0x53, 0x00, /* 7 WORDS Unicode String (LE) Signature: "MSFT100" */
+ 0x46, 0x00, 0x54, 0x00,
+ 0x31, 0x00, 0x30, 0x00,
+ 0x30, 0x00,
+ COMPATIBILITY_FEATURE_REQUEST, /* BYTE Vendor Code */
+ 0x00 /* BYTE Padding */
+};
+
+struct {
+ uint32_t len;
+ uint16_t version;
+ uint16_t four;
+ uint8_t number_of_sections;
+ uint8_t reserved1[7];
+ uint8_t itf;
+ uint8_t reserved2;
+ uint8_t compatible_id[8];
+ uint8_t sub_compatible_id[8];
+ uint8_t reserved3[6];
+} static windows_compat_id = {
+ .len = tu_htole32(40),
+ .version = tu_htole16(0x100),
+ .four = tu_htole16(4),
+ .number_of_sections = 1,
+ .reserved2 = 1,
+ .itf = MYNEWT_VAL(USBD_WINDOWS_COMP_INTERFACE),
+ .compatible_id = MYNEWT_VAL(USBD_WINDOWS_COMP_ID_STRING),
+};
+
+bool
+tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, const tusb_control_request_t *request)
+{
+ if (request->wIndex == 0x04 && request->bRequest == COMPATIBILITY_FEATURE_REQUEST) {
+ return tud_control_xfer(rhport, request, (void *)&windows_compat_id, 40);
+ }
+ return false;
+}
+#endif
+
/*
* Invoked when received GET STRING DESCRIPTOR request
* Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
@@ -266,6 +313,11 @@ tud_descriptor_string_cb(uint8_t index, uint16_t langid)
int i;
const char *str;
+#if MYNEWT_VAL(USBD_WINDOWS_COMP_ID)
+ if (index == MICROSOFT_OS_STRING_DESCRIPTOR) {
+ return (const uint16_t *)microsoft_os_string_descriptor;
+ }
+#endif
if (index == 0) {
desc_string[1] = MYNEWT_VAL(USBD_LANGID);
char_num = 1;
diff --git a/hw/usb/tinyusb/std_descriptors/syscfg.yml b/hw/usb/tinyusb/std_descriptors/syscfg.yml
index 9c2b675..6a10a70 100644
--- a/hw/usb/tinyusb/std_descriptors/syscfg.yml
+++ b/hw/usb/tinyusb/std_descriptors/syscfg.yml
@@ -148,3 +148,16 @@ syscfg.defs:
USBD_BTH_DATA_EP_SIZE:
description: BTH data endpoints size
value:
+
+ USBD_WINDOWS_COMP_ID:
+ description: >
+ Add Windows compatibility descriptor.
+ value: 0
+ USBD_WINDOWS_COMP_ID_STRING:
+ description: >
+ Windows Compatibility ID String.
+ value: '"WINUSB"'
+ USBD_WINDOWS_COMP_INTERFACE:
+ description: >
+ Interface number associated with USBD_WINDOWS_COMP_ID.
+ value: 0