BOS and MS_OS_2.0 descriptors have been added. Still more descriptor work TODO.
This commit is contained in:
parent
b152c658e2
commit
1b031508e1
|
@ -43,13 +43,6 @@
|
|||
// The WebUSB support being conditionally added to this file is based on the
|
||||
// tinyusb demo examples/device/webusb_serial.
|
||||
|
||||
enum
|
||||
{
|
||||
VENDOR_REQUEST_WEBUSB = 1,
|
||||
VENDOR_REQUEST_MICROSOFT = 2
|
||||
};
|
||||
|
||||
extern uint8_t const desc_ms_os_20[];
|
||||
extern const tusb_desc_webusb_url_t desc_webusb_url;
|
||||
|
||||
static bool web_serial_connected = false;
|
||||
|
|
|
@ -629,13 +629,21 @@ extern const uint8_t hid_report_descriptor[{hid_report_descriptor_length}];
|
|||
msc_vendor=args.manufacturer[:8],
|
||||
msc_product=args.product[:16]))
|
||||
|
||||
# Currently getting compile-time errors in files like tusb_fifo.c
|
||||
# if we try do define this here (TODO figure this out!)
|
||||
#if 'VENDOR' in args.devices:
|
||||
# h_file.write("""\
|
||||
#extern const tusb_desc_webusb_url_t desc_webusb_url;
|
||||
#
|
||||
#""")
|
||||
if 'VENDOR' in args.devices:
|
||||
h_file.write("""\
|
||||
enum
|
||||
{
|
||||
VENDOR_REQUEST_WEBUSB = 1,
|
||||
VENDOR_REQUEST_MICROSOFT = 2
|
||||
};
|
||||
|
||||
extern uint8_t const desc_ms_os_20[];
|
||||
|
||||
// Currently getting compile-time errors in files like tusb_fifo.c
|
||||
// if we try do define this here (TODO figure this out!)
|
||||
//extern const tusb_desc_webusb_url_t desc_webusb_url;
|
||||
|
||||
""")
|
||||
|
||||
h_file.write("""\
|
||||
#endif // MICROPY_INCLUDED_AUTOGEN_USB_DESCRIPTOR_H
|
||||
|
@ -711,7 +719,7 @@ c_file.write("""\
|
|||
""")
|
||||
|
||||
if 'VENDOR' in args.devices:
|
||||
# Mimic what the tinyusb webusb demo does
|
||||
# Mimic what the tinyusb webusb demo does in it's main.c file
|
||||
c_file.write("""
|
||||
#define URL "{webusb_url}"
|
||||
|
||||
|
@ -723,13 +731,55 @@ const tusb_desc_webusb_url_t desc_webusb_url =
|
|||
.url = URL
|
||||
}};
|
||||
|
||||
// This next hardcoded descriptor was pulled from the usb_descriptor.c file of the
|
||||
// tinyusb webusb_serial demo. TODO - this is probably something else to integrate
|
||||
// into the adafruit_usb_descriptors project, especially with this next #define..
|
||||
#define ITF_NUM_VENDOR 6 // SWAG for now.
|
||||
// These next two hardcoded descriptor were pulled from the usb_descriptor.c file
|
||||
// of the tinyusb webusb_serial demo. TODO - this is probably something else to
|
||||
// integrate into the adafruit_usb_descriptors project, especially with this next
|
||||
// #define..
|
||||
|
||||
// SWAG for now. Will have to be manually corrected until generated by gen_usb_descriptor.py
|
||||
#define ITF_NUM_VENDOR 6i
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BOS Descriptor
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
/* Microsoft OS 2.0 registry property descriptor
|
||||
Per MS requirements https://msdn.microsoft.com/en-us/library/windows/hardware/hh450799(v=vs.85).aspx
|
||||
device should create DeviceInterfaceGUIDs. It can be done by driver and
|
||||
in case of real PnP solution device should expose MS "Microsoft OS 2.0
|
||||
registry property descriptor". Such descriptor can insert any record
|
||||
into Windows registry per device/configuration/interface. In our case it
|
||||
will insert "DeviceInterfaceGUIDs" multistring property.
|
||||
|
||||
GUID is freshly generated and should be OK to use.
|
||||
|
||||
https://developers.google.com/web/fundamentals/native-hardware/build-for-webusb/
|
||||
(Section Microsoft OS compatibility descriptors)
|
||||
*/
|
||||
|
||||
#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN)
|
||||
|
||||
#define MS_OS_20_DESC_LEN 0xB2
|
||||
|
||||
// BOS Descriptor is required for webUSB
|
||||
uint8_t const desc_bos[] =
|
||||
{{
|
||||
// total length, number of device caps
|
||||
TUD_BOS_DESCRIPTOR(BOS_TOTAL_LEN, 2),
|
||||
|
||||
// Vendor Code, iLandingPage
|
||||
TUD_BOS_WEBUSB_DESCRIPTOR(VENDOR_REQUEST_WEBUSB, 1),
|
||||
|
||||
// Microsoft OS 2.0 descriptor
|
||||
TUD_BOS_MS_OS_20_DESCRIPTOR(MS_OS_20_DESC_LEN, VENDOR_REQUEST_MICROSOFT)
|
||||
}};
|
||||
|
||||
uint8_t const * tud_descriptor_bos_cb(void)
|
||||
{{
|
||||
return desc_bos;
|
||||
}}
|
||||
|
||||
|
||||
uint8_t const desc_ms_os_20[] =
|
||||
{{
|
||||
// Set header: length, type, windows version, total length
|
||||
|
|
Loading…
Reference in New Issue