Add Windows Compatible ID descriptors
This commit is contained in:
@ -130,13 +130,17 @@ static usb_request_status_t usb_send_descriptor(
|
|||||||
static usb_request_status_t usb_send_descriptor_string(
|
static usb_request_status_t usb_send_descriptor_string(
|
||||||
usb_endpoint_t* const endpoint
|
usb_endpoint_t* const endpoint
|
||||||
) {
|
) {
|
||||||
|
if ((endpoint->setup.value_l == 0xee) &&
|
||||||
|
(endpoint->device->wcid_string_descriptor != NULL)) { /* MS WCID string */
|
||||||
|
return usb_send_descriptor(endpoint, endpoint->device->wcid_string_descriptor);
|
||||||
|
} else {
|
||||||
uint_fast8_t index = endpoint->setup.value_l;
|
uint_fast8_t index = endpoint->setup.value_l;
|
||||||
for( uint_fast8_t i=0; endpoint->device->descriptor_strings[i] != 0; i++ ) {
|
for( uint_fast8_t i=0; endpoint->device->descriptor_strings[i] != 0; i++ ) {
|
||||||
if( i == index ) {
|
if( i == index ) {
|
||||||
return usb_send_descriptor(endpoint, endpoint->device->descriptor_strings[i]);
|
return usb_send_descriptor(endpoint, endpoint->device->descriptor_strings[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return USB_REQUEST_STATUS_STALL;
|
return USB_REQUEST_STATUS_STALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +216,26 @@ static usb_request_status_t usb_standard_request_get_descriptor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usb_request_status_t usb_vendor_request_read_wcid(
|
||||||
|
usb_endpoint_t* const endpoint,
|
||||||
|
const usb_transfer_stage_t stage
|
||||||
|
) {
|
||||||
|
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||||
|
if ((endpoint->setup.index == 0x04) &&
|
||||||
|
(endpoint->device->wcid_feature_descriptor != NULL)) {
|
||||||
|
usb_send_descriptor(endpoint, endpoint->device->wcid_feature_descriptor);
|
||||||
|
return USB_REQUEST_STATUS_OK;
|
||||||
|
}
|
||||||
|
if ((endpoint->setup.index == 0x05) &&
|
||||||
|
(endpoint->device->wcid_extended_properties_descriptor != NULL)) {
|
||||||
|
usb_send_descriptor(endpoint, endpoint->device->wcid_extended_properties_descriptor);
|
||||||
|
return USB_REQUEST_STATUS_OK;
|
||||||
|
}
|
||||||
|
return USB_REQUEST_STATUS_STALL;
|
||||||
|
}
|
||||||
|
return USB_REQUEST_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
static usb_request_status_t usb_standard_request_set_address_setup(
|
static usb_request_status_t usb_standard_request_set_address_setup(
|
||||||
|
@ -29,6 +29,11 @@ void usb_set_configuration_changed_cb(
|
|||||||
void (*callback)(usb_device_t* const)
|
void (*callback)(usb_device_t* const)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
usb_request_status_t usb_vendor_request_read_wcid(
|
||||||
|
usb_endpoint_t* const endpoint,
|
||||||
|
const usb_transfer_stage_t stage
|
||||||
|
);
|
||||||
|
|
||||||
usb_request_status_t usb_standard_request(
|
usb_request_status_t usb_standard_request(
|
||||||
usb_endpoint_t* const endpoint,
|
usb_endpoint_t* const endpoint,
|
||||||
const usb_transfer_stage_t stage
|
const usb_transfer_stage_t stage
|
||||||
|
@ -127,6 +127,9 @@ typedef struct {
|
|||||||
const uint8_t* const qualifier_descriptor;
|
const uint8_t* const qualifier_descriptor;
|
||||||
usb_configuration_t* (*configurations)[];
|
usb_configuration_t* (*configurations)[];
|
||||||
const usb_configuration_t* configuration;
|
const usb_configuration_t* configuration;
|
||||||
|
uint8_t* wcid_string_descriptor;
|
||||||
|
uint8_t* wcid_feature_descriptor;
|
||||||
|
uint8_t* wcid_extended_properties_descriptor;
|
||||||
} usb_device_t;
|
} usb_device_t;
|
||||||
|
|
||||||
typedef struct usb_endpoint_t usb_endpoint_t;
|
typedef struct usb_endpoint_t usb_endpoint_t;
|
||||||
|
@ -139,6 +139,7 @@ static const usb_request_handler_fn vendor_request_handler[] = {
|
|||||||
NULL,
|
NULL,
|
||||||
#endif
|
#endif
|
||||||
usb_vendor_request_set_freq_explicit,
|
usb_vendor_request_set_freq_explicit,
|
||||||
|
usb_vendor_request_read_wcid, // USB_WCID_VENDOR_REQ
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint32_t vendor_request_handler_count =
|
static const uint32_t vendor_request_handler_count =
|
||||||
|
@ -55,7 +55,7 @@ uint8_t usb_descriptor_device[] = {
|
|||||||
USB_MAX_PACKET0, // bMaxPacketSize0
|
USB_MAX_PACKET0, // bMaxPacketSize0
|
||||||
USB_WORD(USB_VENDOR_ID), // idVendor
|
USB_WORD(USB_VENDOR_ID), // idVendor
|
||||||
USB_WORD(USB_PRODUCT_ID), // idProduct
|
USB_WORD(USB_PRODUCT_ID), // idProduct
|
||||||
USB_WORD(0x0100), // bcdDevice
|
USB_WORD(0x0101), // bcdDevice
|
||||||
0x01, // iManufacturer
|
0x01, // iManufacturer
|
||||||
0x02, // iProduct
|
0x02, // iProduct
|
||||||
0x04, // iSerialNumber
|
0x04, // iSerialNumber
|
||||||
@ -252,3 +252,30 @@ uint8_t* usb_descriptor_strings[] = {
|
|||||||
usb_descriptor_string_serial_number,
|
usb_descriptor_string_serial_number,
|
||||||
0, // TERMINATOR
|
0, // TERMINATOR
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint8_t wcid_string_descriptor[] = {
|
||||||
|
18, // bLength
|
||||||
|
USB_DESCRIPTOR_TYPE_STRING, // bDescriptorType
|
||||||
|
'M', 0x00,
|
||||||
|
'S', 0x00,
|
||||||
|
'F', 0x00,
|
||||||
|
'T', 0x00,
|
||||||
|
'1', 0x00,
|
||||||
|
'0', 0x00,
|
||||||
|
'0', 0x00,
|
||||||
|
USB_WCID_VENDOR_REQ, // vendor request code for further descriptor
|
||||||
|
0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
uint8_t wcid_feature_descriptor[] = {
|
||||||
|
0x28, 0x00, 0x00, 0x00, // bLength
|
||||||
|
USB_WORD(0x0100), // WCID version
|
||||||
|
USB_WORD(0x0004), // WICD descriptor index
|
||||||
|
0x01, //bNumSections
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00, //Reserved
|
||||||
|
0x00, //bInterfaceNumber
|
||||||
|
0x01, //Reserved
|
||||||
|
'W', 'I', 'N', 'U', 'S', 'B', 0x00,0x00, //Compatible ID, padded with zeros
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //Sub-compatible ID
|
||||||
|
0x00,0x00,0x00,0x00,0x00,0x00 //Reserved
|
||||||
|
};
|
||||||
|
@ -34,3 +34,7 @@ extern uint8_t usb_descriptor_string_product[];
|
|||||||
extern uint8_t usb_descriptor_string_serial_number[];
|
extern uint8_t usb_descriptor_string_serial_number[];
|
||||||
|
|
||||||
extern uint8_t* usb_descriptor_strings[];
|
extern uint8_t* usb_descriptor_strings[];
|
||||||
|
|
||||||
|
#define USB_WCID_VENDOR_REQ 0x19
|
||||||
|
extern uint8_t wcid_string_descriptor[];
|
||||||
|
extern uint8_t wcid_feature_descriptor[];
|
||||||
|
@ -51,4 +51,6 @@ usb_device_t usb_device = {
|
|||||||
.qualifier_descriptor = usb_descriptor_device_qualifier,
|
.qualifier_descriptor = usb_descriptor_device_qualifier,
|
||||||
.configurations = &usb_configurations,
|
.configurations = &usb_configurations,
|
||||||
.configuration = 0,
|
.configuration = 0,
|
||||||
|
.wcid_string_descriptor = wcid_string_descriptor,
|
||||||
|
.wcid_feature_descriptor = wcid_feature_descriptor,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user