1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#[derive(Clone, Copy, Debug)]
pub enum DescriptorType {
Device = 1,
Configuration = 2,
String = 3,
Interface = 4,
Endpoint = 5,
DeviceQualifier = 6,
OtherSpeed = 7,
InterfacePower = 8,
}
#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
pub struct DeviceDescriptor {
pub b_length: u8,
pub b_descriptor_type: DescriptorType,
pub bcd_usb: u16,
pub b_device_class: u8,
pub b_device_sub_class: u8,
pub b_device_protocol: u8,
pub b_max_packet_size: u8,
pub id_vendor: u16,
pub id_product: u16,
pub bcd_device: u16,
pub i_manufacturer: u8,
pub i_product: u8,
pub i_serial_number: u8,
pub b_num_configurations: u8,
}
#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
pub struct ConfigurationDescriptor {
pub b_length: u8,
pub b_descriptor_type: DescriptorType,
pub w_total_length: u16,
pub b_num_interfaces: u8,
pub b_configuration_value: u8,
pub i_configuration: u8,
pub bm_attributes: u8,
pub b_max_power: u8,
}
#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
pub struct InterfaceDescriptor {
pub b_length: u8,
pub b_descriptor_type: DescriptorType,
pub b_interface_number: u8,
pub b_alternate_setting: u8,
pub b_num_endpoints: u8,
pub b_interface_class: u8,
pub b_interface_sub_class: u8,
pub b_interface_protocol: u8,
pub i_interface: u8,
}
#[derive(Copy, Clone, Debug)]
#[repr(C, packed)]
pub struct EndpointDescriptor {
pub b_length: u8,
pub b_descriptor_type: DescriptorType,
pub b_endpoint_address: u8,
pub bm_attributes: u8,
pub w_max_packet_size: u16,
pub b_interval: u8,
}
|