Skip to content

Commit 36ae2eb

Browse files
committed
Move ms_os_20_desc into header
1 parent d50659c commit 36ae2eb

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

src/common/pico_usb_reset_interface_headers/include/pico/usb_reset_interface.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,31 @@
9999
TUD_RPI_RESET_DESC_LEN, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_VENDOR_SPECIFIC, RESET_INTERFACE_SUBCLASS, RESET_INTERFACE_PROTOCOL, _stridx
100100

101101

102+
// Microsoft OS 2.0 Descriptor
103+
#define RPI_RESET_MS_OS_20_DESC_LEN (0x08 + 0x14 + 0x80)
104+
#define RPI_RESET_MS_OS_20_DESCRIPTOR(itf_num) \
105+
/* Function Subset header: length, type, first interface, reserved, subset length */ \
106+
U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), itf_num, 0, U16_TO_U8S_LE(RPI_RESET_MS_OS_20_DESC_LEN), \
107+
\
108+
/* MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID */ \
109+
U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, \
110+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* sub-compatible */ \
111+
\
112+
/* MS OS 2.0 Registry property descriptor: length, type */ \
113+
U16_TO_U8S_LE(0x0080), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), \
114+
U16_TO_U8S_LE(0x0001), U16_TO_U8S_LE(0x0028), /* wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUID" in UTF-16 */ \
115+
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, \
116+
'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00, \
117+
U16_TO_U8S_LE(0x004E), /* wPropertyDataLength */ \
118+
/* Vendor-defined Property Data: {bc7398c1-73cd-4cb7-98b8-913a8fca7bf6} */ \
119+
'{', 0, 'b', 0, 'c', 0, '7', 0, '3', 0, '9', 0, \
120+
'8', 0, 'c', 0, '1', 0, '-', 0, '7', 0, '3', 0, \
121+
'c', 0, 'd', 0, '-', 0, '4', 0, 'c', 0, 'b', 0, \
122+
'7', 0, '-', 0, '9', 0, '8', 0, 'b', 0, '8', 0, \
123+
'-', 0, '9', 0, '1', 0, '3', 0, 'a', 0, '8', 0, \
124+
'f', 0, 'c', 0, 'a', 0, '7', 0, 'b', 0, 'f', 0, \
125+
'6', 0, '}', 0, 0, 0
126+
102127
#include "stdint.h"
103128
#include "device/usbd_pvt.h"
104129

src/rp2_common/pico_usb_reset_interface/usb_reset_interface.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static uint8_t itf_num;
2323
// Support for Microsoft OS 2.0 descriptor
2424
#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN)
2525

26-
#define MS_OS_20_DESC_LEN 166
26+
#define MS_OS_20_DESC_LEN (RPI_RESET_MS_OS_20_DESC_LEN + 0x0A)
2727

2828
uint8_t const desc_bos[] =
2929
{
@@ -46,27 +46,7 @@ static const uint8_t desc_ms_os_20[] =
4646
// Set header: length, type, windows version, total length
4747
U16_TO_U8S_LE(0x000A), U16_TO_U8S_LE(MS_OS_20_SET_HEADER_DESCRIPTOR), U32_TO_U8S_LE(0x06030000), U16_TO_U8S_LE(MS_OS_20_DESC_LEN),
4848

49-
// Function Subset header: length, type, first interface, reserved, subset length
50-
U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF, 0, U16_TO_U8S_LE(MS_OS_20_DESC_LEN-0x000A),
51-
52-
// MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID
53-
U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00,
54-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // sub-compatible
55-
56-
// MS OS 2.0 Registry property descriptor: length, type
57-
U16_TO_U8S_LE(0x0080), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY),
58-
U16_TO_U8S_LE(0x0001), U16_TO_U8S_LE(0x0028), // wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUID" in UTF-16
59-
'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00,
60-
'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00,
61-
U16_TO_U8S_LE(0x004E), // wPropertyDataLength
62-
// Vendor-defined Property Data: {bc7398c1-73cd-4cb7-98b8-913a8fca7bf6}
63-
'{', 0, 'b', 0, 'c', 0, '7', 0, '3', 0, '9', 0,
64-
'8', 0, 'c', 0, '1', 0, '-', 0, '7', 0, '3', 0,
65-
'c', 0, 'd', 0, '-', 0, '4', 0, 'c', 0, 'b', 0,
66-
'7', 0, '-', 0, '9', 0, '8', 0, 'b', 0, '8', 0,
67-
'-', 0, '9', 0, '1', 0, '3', 0, 'a', 0, '8', 0,
68-
'f', 0, 'c', 0, 'a', 0, '7', 0, 'b', 0, 'f', 0,
69-
'6', 0, '}', 0, 0, 0
49+
RPI_RESET_MS_OS_20_DESCRIPTOR(PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF)
7050
};
7151

7252
TU_VERIFY_STATIC(sizeof(desc_ms_os_20) == MS_OS_20_DESC_LEN, "Incorrect size");

0 commit comments

Comments
 (0)