diff options
author | Brian Cully <bjc@kublai.com> | 2019-08-02 22:46:31 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-08-02 22:46:31 -0400 |
commit | 024fc1503cb73e538dcd05258a6a63059029a48f (patch) | |
tree | 55f02e523b0f59cc5bd7382df3f5473d3f2f8986 /usb-host/src/descriptor.rs | |
parent | f560a4e9ce76aca32765409f53b570bf0e3c6b4c (diff) | |
download | samd21-demo-024fc1503cb73e538dcd05258a6a63059029a48f.tar.gz samd21-demo-024fc1503cb73e538dcd05258a6a63059029a48f.zip |
Add traits for host controller and driver.
Diffstat (limited to 'usb-host/src/descriptor.rs')
-rw-r--r-- | usb-host/src/descriptor.rs | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/usb-host/src/descriptor.rs b/usb-host/src/descriptor.rs new file mode 100644 index 0000000..8461413 --- /dev/null +++ b/usb-host/src/descriptor.rs @@ -0,0 +1,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, +} |