Crates.io | usbd-microsoft-os |
lib.rs | usbd-microsoft-os |
version | 0.1.0 |
source | src |
created_at | 2023-05-15 11:32:10.998464 |
updated_at | 2023-05-15 11:32:10.998464 |
description | Microsoft OS USB descriptors for usb-device |
homepage | |
repository | https://github.com/jedrzejboczar/usbd-microsoft-os |
max_upload_size | |
id | 864942 |
size | 52,060 |
Implementation of Microsoft OS USB descriptors for usb-device. Currently only the new Microsoft OS 2.0 Descriptors standard is supported. Version 1.0 may be added in the future if needed.
This crate provides class MsOsUsbClass
that is responsible for sending MS OS USB descriptors
and appropriate BOS capabilities. It is meant to be configured using const
structures that
describe the descriptors, and const fn
methods that generate raw descriptor data, e.g. for WinUSB:
use usbd_microsoft_os::{os_20, MsOsUsbClass, WindowsVersion, utf16_lit, utf16_null_le_bytes};
const DESCRIPTOR_SET: os_20::DescriptorSet = os_20::DescriptorSet {
version: WindowsVersion::MINIMAL,
features: &[],
configurations: &[
os_20::ConfigurationSubset {
configuration: 0,
features: &[],
functions: &[
os_20::FunctionSubset {
first_interface: 3,
features: &[
os_20::FeatureDescriptor::CompatibleId {
id: b"WINUSB\0\0",
sub_id: b"\0\0\0\0\0\0\0\0",
},
os_20::FeatureDescriptor::RegistryProperty {
data_type: os_20::PropertyDataType::RegMutliSz,
name: &utf16_lit::utf16_null!("DeviceInterfaceGUIDs"),
data: &utf16_null_le_bytes!("{6b09aac4-333f-4467-9e23-f88b9e9d95f7}\0"),
},
]
}
]
}
],
};
const CAPABILITIES: os_20::Capabilities = os_20::Capabilities {
infos: &[
os_20::CapabilityInfo {
descriptors: &DESCRIPTOR_SET,
alt_enum_cmd: os_20::ALT_ENUM_CODE_NOT_SUPPORTED,
}
],
};
const DESCRIPTOR_SET_BYTES: [u8; DESCRIPTOR_SET.size()] = DESCRIPTOR_SET.descriptor();
const CAPABILITIES_BYTES: [u8; CAPABILITIES.data_len()] = CAPABILITIES.descriptor_data();
pub const fn class() -> MsOsUsbClass {
MsOsUsbClass {
os_20_capabilities_data: &CAPABILITIES_BYTES,
os_20_descriptor_sets: &[&DESCRIPTOR_SET_BYTES],
}
}
Check test cases to see more examples from the specification.