aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb/src/descriptor.rs
diff options
context:
space:
mode:
authorHaobo Gu <[email protected]>2024-08-15 10:58:10 +0800
committerHaobo Gu <[email protected]>2024-08-15 11:26:24 +0800
commita63d46507de7fbb44233ba5557630791f62a985a (patch)
treec38e1360a721ea3a08bc9c8dc051292656f18fd6 /embassy-usb/src/descriptor.rs
parent7a26e117ccd5f8669548cc8c2424be4691c1c402 (diff)
feat(usb): add device qualifier descriptor
Signed-off-by: Haobo Gu <[email protected]>
Diffstat (limited to 'embassy-usb/src/descriptor.rs')
-rw-r--r--embassy-usb/src/descriptor.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/embassy-usb/src/descriptor.rs b/embassy-usb/src/descriptor.rs
index eb3d1f53a..f1773fa8a 100644
--- a/embassy-usb/src/descriptor.rs
+++ b/embassy-usb/src/descriptor.rs
@@ -13,6 +13,8 @@ pub mod descriptor_type {
13 pub const STRING: u8 = 3; 13 pub const STRING: u8 = 3;
14 pub const INTERFACE: u8 = 4; 14 pub const INTERFACE: u8 = 4;
15 pub const ENDPOINT: u8 = 5; 15 pub const ENDPOINT: u8 = 5;
16 pub const DEVICE_QUALIFIER: u8 = 6;
17 pub const OTHER_SPEED_CONFIGURATION: u8 = 7;
16 pub const IAD: u8 = 11; 18 pub const IAD: u8 = 11;
17 pub const BOS: u8 = 15; 19 pub const BOS: u8 = 15;
18 pub const CAPABILITY: u8 = 16; 20 pub const CAPABILITY: u8 = 16;
@@ -272,6 +274,25 @@ pub(crate) fn device_descriptor(config: &Config) -> [u8; 18] {
272 ] 274 ]
273} 275}
274 276
277/// Create a new Device Qualifier Descriptor array.
278///
279/// All device qualifier descriptors are always 10 bytes, so there's no need for
280/// a variable-length buffer or DescriptorWriter.
281pub(crate) fn device_qualifier_descriptor(config: &Config) -> [u8; 10] {
282 [
283 10, // bLength
284 0x06, // bDescriptorType
285 0x10,
286 0x02, // bcdUSB 2.1
287 config.device_class, // bDeviceClass
288 config.device_sub_class, // bDeviceSubClass
289 config.device_protocol, // bDeviceProtocol
290 config.max_packet_size_0, // bMaxPacketSize0
291 1, // bNumConfigurations
292 0, // Reserved
293 ]
294}
295
275/// A writer for Binary Object Store descriptor. 296/// A writer for Binary Object Store descriptor.
276pub struct BosWriter<'a> { 297pub struct BosWriter<'a> {
277 pub(crate) writer: DescriptorWriter<'a>, 298 pub(crate) writer: DescriptorWriter<'a>,