usb: use InterfaceNumber in msos.

This commit is contained in:
Dario Nieuwenhuis
2023-02-07 23:45:01 +01:00
parent 3af991ab63
commit 86487db5d1
4 changed files with 9 additions and 5 deletions

View File

@ -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")]

View File

@ -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(),

View File

@ -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 {