mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
make baremetal work with windows CDC-ACM without special drivers
This commit is contained in:
parent
82c5b7e970
commit
01957c3b65
2 changed files with 22 additions and 1 deletions
|
|
@ -148,7 +148,7 @@ pub fn get_descriptor_request(this: &mut CorigineUsb, value: u16, _index: usize,
|
||||||
|
|
||||||
match (value >> 8) as u8 {
|
match (value >> 8) as u8 {
|
||||||
USB_DT_DEVICE => {
|
USB_DT_DEVICE => {
|
||||||
let mut dd = DeviceDescriptor::default_composite();
|
let mut dd = DeviceDescriptor::composite_with_iad();
|
||||||
dd.b_max_packet_size0 = 64;
|
dd.b_max_packet_size0 = 64;
|
||||||
let len = length.min(core::mem::size_of::<DeviceDescriptor>());
|
let len = length.min(core::mem::size_of::<DeviceDescriptor>());
|
||||||
ep0_buf[..len].copy_from_slice(&dd.as_ref()[..len]);
|
ep0_buf[..len].copy_from_slice(&dd.as_ref()[..len]);
|
||||||
|
|
|
||||||
|
|
@ -167,6 +167,7 @@ impl DeviceDescriptor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn default_composite() -> Self {
|
pub fn default_composite() -> Self {
|
||||||
Self {
|
Self {
|
||||||
b_length: core::mem::size_of::<Self>() as u8,
|
b_length: core::mem::size_of::<Self>() as u8,
|
||||||
|
|
@ -185,6 +186,26 @@ impl DeviceDescriptor {
|
||||||
b_num_configurations: 1,
|
b_num_configurations: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Windows-friendly composite: EF/02/01 indicates IAD-present composite
|
||||||
|
pub fn composite_with_iad() -> Self {
|
||||||
|
Self {
|
||||||
|
b_length: core::mem::size_of::<Self>() as u8,
|
||||||
|
b_descriptor_type: USB_DT_DEVICE,
|
||||||
|
b_cd_usb: 0x0200,
|
||||||
|
b_device_class: 0xEF, // Miscellaneous
|
||||||
|
b_device_sub_class: 0x02, // Common Class
|
||||||
|
b_device_protocol: 0x01, // Interface Association Descriptor (IAD)
|
||||||
|
b_max_packet_size0: 0x40,
|
||||||
|
id_vendor: VENDOR_ID,
|
||||||
|
id_product: PRODUCT_ID,
|
||||||
|
b_cd_device: 0x0101,
|
||||||
|
i_manufacturer: 0x01,
|
||||||
|
i_product: 0x02,
|
||||||
|
i_serial_number: 0x03,
|
||||||
|
b_num_configurations: 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<[u8]> for DeviceDescriptor {
|
impl AsRef<[u8]> for DeviceDescriptor {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue