nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
usb_bulk_msosv2.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7/* {CDB3B5AD-293B-4663-AA36-1AAE46463776} */
8#define CMSIS_DAP_V2_DEVICE_INTERFACE_GUID \
9 '{', 0x00, 'C', 0x00, 'D', 0x00, 'B', 0x00, '3', 0x00, 'B', 0x00, \
10 '5', 0x00, 'A', 0x00, 'D', 0x00, '-', 0x00, '2', 0x00, '9', 0x00, \
11 '3', 0x00, 'B', 0x00, '-', 0x00, '4', 0x00, '6', 0x00, '6', 0x00, \
12 '3', 0x00, '-', 0x00, 'A', 0x00, 'A', 0x00, '3', 0x00, '6', 0x00, \
13 '-', 0x00, '1', 0x00, 'A', 0x00, 'A', 0x00, 'E', 0x00, '4', 0x00, \
14 '6', 0x00, '4', 0x00, '6', 0x00, '3', 0x00, '7', 0x00, '7', 0x00, \
15 '6', 0x00, '}', 0x00, 0x00, 0x00, 0x00, 0x00
16
17#define COMPATIBLE_ID_WINUSB \
18 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00
19
20#define WINUSB_VENDOR_CODE 0x20
21
22static struct msosv2_descriptor {
23 struct msosv2_descriptor_set_header header;
24#if defined(CONFIG_USB_COMPOSITE_DEVICE)
25 struct msosv2_function_subset_header subset_header;
26#endif
27 struct msosv2_compatible_id compatible_id;
28 struct msosv2_guids_property guids_property;
29} __packed msosv2_cmsis_dap_desc = {
30 /*
31 * Microsoft OS 2.0 descriptor set. This tells Windows what kind
32 * of device this is and to install the WinUSB driver.
33 */
34 .header = {
35 .wLength = sizeof(struct msosv2_descriptor_set_header),
36 .wDescriptorType = MS_OS_20_SET_HEADER_DESCRIPTOR,
37 .dwWindowsVersion = 0x06030000,
38 .wTotalLength = sizeof(struct msosv2_descriptor),
39 },
40#if defined(CONFIG_USB_COMPOSITE_DEVICE)
41 .subset_header = {
42 .wLength = sizeof(struct msosv2_function_subset_header),
43 .wDescriptorType = MS_OS_20_SUBSET_HEADER_FUNCTION,
44 .wSubsetLength = sizeof(struct msosv2_function_subset_header)
45 + sizeof(struct msosv2_compatible_id)
46 + sizeof(struct msosv2_guids_property),
47 },
48#endif
49 .compatible_id = {
50 .wLength = sizeof(struct msosv2_compatible_id),
51 .wDescriptorType = MS_OS_20_FEATURE_COMPATIBLE_ID,
52 .CompatibleID = {COMPATIBLE_ID_WINUSB},
53 },
54 .guids_property = {
55 .wLength = sizeof(struct msosv2_guids_property),
56 .wDescriptorType = MS_OS_20_FEATURE_REG_PROPERTY,
57 .wPropertyDataType = MS_OS_20_PROPERTY_DATA_REG_MULTI_SZ,
58 .wPropertyNameLength = 42,
59 .PropertyName = {DEVICE_INTERFACE_GUIDS_PROPERTY_NAME},
60 .wPropertyDataLength = 80,
61 .bPropertyData = {CMSIS_DAP_V2_DEVICE_INTERFACE_GUID},
62 },
63};
64
65USB_DEVICE_BOS_DESC_DEFINE_CAP struct usb_bos_msosv2_desc {
66 struct usb_bos_platform_descriptor platform;
67 struct usb_bos_capability_msos cap;
68} __packed bos_cap_msosv2 = {
69 /* Microsoft OS 2.0 Platform Capability Descriptor */
70 .platform = {
71 .bLength = sizeof(struct usb_bos_platform_descriptor)
72 + sizeof(struct usb_bos_capability_msos),
73 .bDescriptorType = USB_DESC_DEVICE_CAPABILITY,
74 .bDevCapabilityType = USB_BOS_CAPABILITY_PLATFORM,
75 .bReserved = 0,
76 .PlatformCapabilityUUID = {
81 0xDF, 0x60, 0xDD, 0xD8,
82 0x89, 0x45,
83 0xC7, 0x4C,
84 0x9C, 0xD2,
85 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F,
86 },
87 },
88 .cap = {
89 /* Windows version (8.1) (0x06030000) */
90 .dwWindowsVersion = sys_cpu_to_le32(0x06030000),
91 .wMSOSDescriptorSetTotalLength =
92 sys_cpu_to_le16(sizeof(msosv2_cmsis_dap_desc)),
93 .bMS_VendorCode = WINUSB_VENDOR_CODE,
94 .bAltEnumCode = 0x00
95 },
96};
97
98static int msosv2_vendor_handle_req(struct usb_setup_packet *setup,
99 int32_t *len, uint8_t **data)
100{
101 if (usb_reqtype_is_to_device(setup)) {
102 return -ENOTSUP;
103 }
104
105 if (setup->bRequest == WINUSB_VENDOR_CODE &&
106 setup->wIndex == MS_OS_20_DESCRIPTOR_INDEX) {
107 *data = (uint8_t *)(&msosv2_cmsis_dap_desc);
108 *len = sizeof(msosv2_cmsis_dap_desc);
109
110 LOG_DBG("Get MS OS Descriptors v2");
111
112 return 0;
113 }
114
115 return -ENOTSUP;
116}
struct msosv2_guids_property guids_property
Definition: usb_bulk_msosv2.h:28
struct msosv2_compatible_id compatible_id
Definition: usb_bulk_msosv2.h:27
struct msosv2_descriptor_set_header header
Definition: usb_bulk_msosv2.h:23
Definition: usb_bulk_msosv2.h:22
struct usb_bos_capability_msos cap
Definition: usb_bulk_msosv2.h:67
struct usb_bos_platform_descriptor platform
Definition: usb_bulk_msosv2.h:66
Definition: usb_bulk_msosv2.h:65
static int setup(void)
USB_DEVICE_BOS_DESC_DEFINE_CAP struct usb_bos_msosv2_desc bos_cap_msosv2
static struct msosv2_descriptor msosv2_cmsis_dap_desc
#define COMPATIBLE_ID_WINUSB
Definition: usb_bulk_msosv2.h:17
static int msosv2_vendor_handle_req(struct usb_setup_packet *setup, int32_t *len, uint8_t **data)
Definition: usb_bulk_msosv2.h:98
#define CMSIS_DAP_V2_DEVICE_INTERFACE_GUID
Definition: usb_bulk_msosv2.h:8
#define WINUSB_VENDOR_CODE
Definition: usb_bulk_msosv2.h:20