custom bcd usb version

This commit is contained in:
sawyer bristol 2024-11-29 20:29:43 -07:00
parent 1a1d5c4689
commit d0b1819aa5
2 changed files with 18 additions and 12 deletions

View File

@ -15,6 +15,11 @@ pub struct Config<'a> {
pub(crate) vendor_id: u16, pub(crate) vendor_id: u16,
pub(crate) product_id: u16, pub(crate) product_id: u16,
/// Device BCD USB version.
///
/// Default: `0x02` ("2.1")
pub bcd_usb: u16,
/// Device class code assigned by USB.org. Set to `0xff` for vendor-specific /// Device class code assigned by USB.org. Set to `0xff` for vendor-specific
/// devices that do not conform to any class. /// devices that do not conform to any class.
/// ///
@ -108,6 +113,7 @@ impl<'a> Config<'a> {
vendor_id: vid, vendor_id: vid,
product_id: pid, product_id: pid,
device_release: 0x0010, device_release: 0x0010,
bcd_usb: 0x02,
manufacturer: None, manufacturer: None,
product: None, product: None,
serial_number: None, serial_number: None,

View File

@ -326,11 +326,11 @@ pub(crate) fn device_descriptor(config: &Config) -> [u8; 18] {
18, // bLength 18, // bLength
0x01, // bDescriptorType 0x01, // bDescriptorType
0x10, 0x10,
0x02, // bcdUSB 2.1 (config.bcd_usb >> 8) as u8, // bcdUSB
config.device_class, // bDeviceClass config.device_class, // bDeviceClass
config.device_sub_class, // bDeviceSubClass config.device_sub_class, // bDeviceSubClass
config.device_protocol, // bDeviceProtocol config.device_protocol, // bDeviceProtocol
config.max_packet_size_0, // bMaxPacketSize0 config.max_packet_size_0, // bMaxPacketSize0
config.vendor_id as u8, config.vendor_id as u8,
(config.vendor_id >> 8) as u8, // idVendor (config.vendor_id >> 8) as u8, // idVendor
config.product_id as u8, config.product_id as u8,
@ -353,13 +353,13 @@ pub(crate) fn device_qualifier_descriptor(config: &Config) -> [u8; 10] {
10, // bLength 10, // bLength
0x06, // bDescriptorType 0x06, // bDescriptorType
0x10, 0x10,
0x02, // bcdUSB 2.1 (config.bcd_usb >> 8) as u8, // bcdUSB
config.device_class, // bDeviceClass config.device_class, // bDeviceClass
config.device_sub_class, // bDeviceSubClass config.device_sub_class, // bDeviceSubClass
config.device_protocol, // bDeviceProtocol config.device_protocol, // bDeviceProtocol
config.max_packet_size_0, // bMaxPacketSize0 config.max_packet_size_0, // bMaxPacketSize0
1, // bNumConfigurations 1, // bNumConfigurations
0, // Reserved 0, // Reserved
] ]
} }