-
Notifications
You must be signed in to change notification settings - Fork 817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow custom bcd usb version #3599
Conversation
embassy-usb/src/descriptor.rs
Outdated
config.device_sub_class, // bDeviceSubClass | ||
config.device_protocol, // bDeviceProtocol | ||
config.max_packet_size_0, // bMaxPacketSize0 | ||
(config.bcd_usb >> 8) as u8, // bcdUSB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the 0x10
above is also part of bcd_usb
, it's the lower byte. for example USB 2.1 is 0x0210
.
The config default should also be 0x0210
instead of 0x02
what's the use case for this? in what cases do you want to force the USB version down to 2.0 or 1.x? Would these use cases still be satisfied if the API was a "usb version" enum instead of a freeform u16? IMO that'd be more user-friendly because it'd prevent invalid values. Also, do we need to disable some features that weren't available in older USBs? |
I think in many cases where you are trying to emulate a specific device. When using 2.1 the host assumes you are using a bos_descriptor since that is what 2.1 is. By forcing the use of 2.0 you are disabling unused features. Maybe the same is true for 1.x, but I'm not sure what other changes might be required for that use case.
I think so, I can easily create one for 2.1, and 2.0 and others can include others when needed.
In my testing, no everything seems to work as is. |
embassy-usb/src/builder.rs
Outdated
/// Device BCD USB version. | ||
/// | ||
/// Default: `0x0210` ("2.1") | ||
pub bcd_usb: BcdUsbVersion, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name this just UsbVersion
.
"BCD" is a reference to Binary Coded Decimal, ie how it's coded in binary. if it's an enum the user no longer cares about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! 🚀
Allows a custom bcdusb version like 1.1 (0x011) but leaves the default to 2.0/2.1