usb: use InterfaceNumber in msos.
This commit is contained in:
		| @@ -346,7 +346,7 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> { | ||||
|         } | ||||
|  | ||||
|         if !self.builder.msos_descriptor.is_in_function_subset() { | ||||
|             self.builder.msos_descriptor.function(self.first_interface.0); | ||||
|             self.builder.msos_descriptor.function(self.first_interface); | ||||
|         } | ||||
|  | ||||
|         #[cfg(feature = "msos-descriptor")] | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
| use core::mem::size_of; | ||||
|  | ||||
| use super::{capability_type, BosWriter}; | ||||
| use crate::types::InterfaceNumber; | ||||
|  | ||||
| /// A serialized Microsoft OS 2.0 Descriptor set. | ||||
| /// | ||||
| @@ -125,7 +126,7 @@ impl<'d> MsOsDescriptorWriter<'d> { | ||||
|     } | ||||
|  | ||||
|     /// Add a function subset. | ||||
|     pub fn function(&mut self, first_interface: u8) { | ||||
|     pub fn function(&mut self, first_interface: InterfaceNumber) { | ||||
|         assert!( | ||||
|             self.config_mark.is_some(), | ||||
|             "MsOsDescriptorWriter: function subset requires a configuration subset" | ||||
| @@ -376,14 +377,14 @@ impl DescriptorSet for ConfigurationSubsetHeader { | ||||
| pub struct FunctionSubsetHeader { | ||||
|     wLength: u16, | ||||
|     wDescriptorType: u16, | ||||
|     bFirstInterface: u8, | ||||
|     bFirstInterface: InterfaceNumber, | ||||
|     bReserved: u8, | ||||
|     wSubsetLength: u16, | ||||
| } | ||||
|  | ||||
| impl FunctionSubsetHeader { | ||||
|     /// Creates a function subset header | ||||
|     pub fn new(first_interface: u8) -> Self { | ||||
|     pub fn new(first_interface: InterfaceNumber) -> Self { | ||||
|         FunctionSubsetHeader { | ||||
|             wLength: (size_of::<Self>() as u16).to_le(), | ||||
|             wDescriptorType: (Self::TYPE as u16).to_le(), | ||||
|   | ||||
| @@ -3,6 +3,7 @@ | ||||
| /// A handle for a USB interface that contains its number. | ||||
| #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||||
| #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||||
| #[repr(transparent)] | ||||
| pub struct InterfaceNumber(pub u8); | ||||
|  | ||||
| impl InterfaceNumber { | ||||
| @@ -20,6 +21,7 @@ impl From<InterfaceNumber> for u8 { | ||||
| /// A handle for a USB string descriptor that contains its index. | ||||
| #[derive(Copy, Clone, Eq, PartialEq)] | ||||
| #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||||
| #[repr(transparent)] | ||||
| pub struct StringIndex(pub u8); | ||||
|  | ||||
| impl StringIndex { | ||||
|   | ||||
| @@ -12,6 +12,7 @@ use embassy_nrf::{interrupt, pac}; | ||||
| use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | ||||
| use embassy_usb::driver::EndpointError; | ||||
| use embassy_usb::msos::{self, windows_version}; | ||||
| use embassy_usb::types::InterfaceNumber; | ||||
| use embassy_usb::{Builder, Config}; | ||||
| use {defmt_rtt as _, panic_probe as _}; | ||||
|  | ||||
| @@ -77,7 +78,7 @@ async fn main(_spawner: Spawner) { | ||||
|     // Inside a class constructor, you would just need to call `FunctionBuilder::msos_feature` instead. | ||||
|     let msos_writer = builder.msos_writer(); | ||||
|     msos_writer.configuration(0); | ||||
|     msos_writer.function(0); | ||||
|     msos_writer.function(InterfaceNumber(0)); | ||||
|     msos_writer.function_feature(msos::CompatibleIdFeatureDescriptor::new("WINUSB", "")); | ||||
|     msos_writer.function_feature(msos::RegistryPropertyFeatureDescriptor::new( | ||||
|         "DeviceInterfaceGUIDs", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user