From 08293b8e0cb8d1af8e98fe10e0a0452cc8c005f8 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Thu, 11 Aug 2022 11:11:48 +0100 Subject: [PATCH] usb/microsoft: Implemented more of the descriptor structures --- include/libopencm3/usb/microsoft.h | 36 +++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/include/libopencm3/usb/microsoft.h b/include/libopencm3/usb/microsoft.h index c009e25e..04146120 100644 --- a/include/libopencm3/usb/microsoft.h +++ b/include/libopencm3/usb/microsoft.h @@ -41,6 +41,8 @@ LGPL License Terms @ref lgpl_license #include #include +BEGIN_DECLS + enum microsoft_req { MICROSOFT_GET_DESCRIPTOR_SET = 7, MICROSOFT_SET_ALTERNATE_ENUM = 8, @@ -88,11 +90,41 @@ typedef struct __attribute__((packed)) microsoft_os_descriptor_set_information { #define MICROSOFT_OS_DESCRIPTOR_SET_INFORMATION_SIZE sizeof(microsoft_os_descriptor_set_information) -typedef struct __attribute__((packed)) microsoft_os_descriptor_set_header { +typedef struct microsoft_os_descriptor_function_subset_header { + uint16_t wLength; + uint16_t wDescriptorType; + uint8_t bFirstInterface; + uint8_t bReserved; + uint16_t wTotalLength; +} microsoft_os_descriptor_function_subset_header; + +#define MICROSOFT_OS_DESCRIPTOR_FUNCTION_SUBSET_HEADER_SIZE 8U + +typedef struct microsoft_os_descriptor_config_subset_header { + uint16_t wLength; + uint16_t wDescriptorType; + uint8_t bConfigurationValue; + uint8_t bReserved; + uint16_t wTotalLength; + + /* Descriptor ends here. The following are used internally: */ + const microsoft_os_descriptor_function_subset_header *function_subset_headers; + uint8_t num_function_subset_headers; +} microsoft_os_descriptor_config_subset_header; + +#define MICROSOFT_OS_DESCRIPTOR_CONFIG_SUBSET_HEADER_SIZE 8U + +typedef struct microsoft_os_descriptor_set_header { uint16_t wLength; uint16_t wDescriptorType; uint32_t dwWindowsVersion; uint16_t wTotalLength; + + /* Descriptor ends here. The following are used internally: */ + uint8_t vendor_code; + uint8_t num_config_subset_headers; + const microsoft_os_descriptor_config_subset_header *config_subset_headers; + } microsoft_os_descriptor_set_header; #define MICROSOFT_OS_DESCRIPTOR_SET_HEADER_SIZE 10U @@ -100,6 +132,8 @@ typedef struct __attribute__((packed)) microsoft_os_descriptor_set_header { extern void microsoft_os_register_descriptor_sets(usbd_device *dev, const microsoft_os_descriptor_set_header *sets, uint8_t num_sets); +END_DECLS + #endif /**@}*/