aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-02-07 23:45:01 +0100
committerDario Nieuwenhuis <[email protected]>2023-02-08 00:30:53 +0100
commit86487db5d1773d2a764ab340051d70cfa40e4714 (patch)
treed5051ead9e65ea0a51f315a4302c867d07cb2449 /embassy-usb
parent3af991ab63d14cfad6f50d28bfb944d1895d1c70 (diff)
usb: use InterfaceNumber in msos.
Diffstat (limited to 'embassy-usb')
-rw-r--r--embassy-usb/src/builder.rs2
-rw-r--r--embassy-usb/src/msos.rs7
-rw-r--r--embassy-usb/src/types.rs2
3 files changed, 7 insertions, 4 deletions
diff --git a/embassy-usb/src/builder.rs b/embassy-usb/src/builder.rs
index 07b2a177c..305dfa02e 100644
--- a/embassy-usb/src/builder.rs
+++ b/embassy-usb/src/builder.rs
@@ -346,7 +346,7 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> {
346 } 346 }
347 347
348 if !self.builder.msos_descriptor.is_in_function_subset() { 348 if !self.builder.msos_descriptor.is_in_function_subset() {
349 self.builder.msos_descriptor.function(self.first_interface.0); 349 self.builder.msos_descriptor.function(self.first_interface);
350 } 350 }
351 351
352 #[cfg(feature = "msos-descriptor")] 352 #[cfg(feature = "msos-descriptor")]
diff --git a/embassy-usb/src/msos.rs b/embassy-usb/src/msos.rs
index 19ed34979..b1e0335ee 100644
--- a/embassy-usb/src/msos.rs
+++ b/embassy-usb/src/msos.rs
@@ -7,6 +7,7 @@
7use core::mem::size_of; 7use core::mem::size_of;
8 8
9use super::{capability_type, BosWriter}; 9use super::{capability_type, BosWriter};
10use crate::types::InterfaceNumber;
10 11
11/// A serialized Microsoft OS 2.0 Descriptor set. 12/// A serialized Microsoft OS 2.0 Descriptor set.
12/// 13///
@@ -125,7 +126,7 @@ impl<'d> MsOsDescriptorWriter<'d> {
125 } 126 }
126 127
127 /// Add a function subset. 128 /// Add a function subset.
128 pub fn function(&mut self, first_interface: u8) { 129 pub fn function(&mut self, first_interface: InterfaceNumber) {
129 assert!( 130 assert!(
130 self.config_mark.is_some(), 131 self.config_mark.is_some(),
131 "MsOsDescriptorWriter: function subset requires a configuration subset" 132 "MsOsDescriptorWriter: function subset requires a configuration subset"
@@ -376,14 +377,14 @@ impl DescriptorSet for ConfigurationSubsetHeader {
376pub struct FunctionSubsetHeader { 377pub struct FunctionSubsetHeader {
377 wLength: u16, 378 wLength: u16,
378 wDescriptorType: u16, 379 wDescriptorType: u16,
379 bFirstInterface: u8, 380 bFirstInterface: InterfaceNumber,
380 bReserved: u8, 381 bReserved: u8,
381 wSubsetLength: u16, 382 wSubsetLength: u16,
382} 383}
383 384
384impl FunctionSubsetHeader { 385impl FunctionSubsetHeader {
385 /// Creates a function subset header 386 /// Creates a function subset header
386 pub fn new(first_interface: u8) -> Self { 387 pub fn new(first_interface: InterfaceNumber) -> Self {
387 FunctionSubsetHeader { 388 FunctionSubsetHeader {
388 wLength: (size_of::<Self>() as u16).to_le(), 389 wLength: (size_of::<Self>() as u16).to_le(),
389 wDescriptorType: (Self::TYPE as u16).to_le(), 390 wDescriptorType: (Self::TYPE as u16).to_le(),
diff --git a/embassy-usb/src/types.rs b/embassy-usb/src/types.rs
index 15d195002..c7a47f7e4 100644
--- a/embassy-usb/src/types.rs
+++ b/embassy-usb/src/types.rs
@@ -3,6 +3,7 @@
3/// A handle for a USB interface that contains its number. 3/// A handle for a USB interface that contains its number.
4#[derive(Debug, Copy, Clone, Eq, PartialEq)] 4#[derive(Debug, Copy, Clone, Eq, PartialEq)]
5#[cfg_attr(feature = "defmt", derive(defmt::Format))] 5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6#[repr(transparent)]
6pub struct InterfaceNumber(pub u8); 7pub struct InterfaceNumber(pub u8);
7 8
8impl InterfaceNumber { 9impl InterfaceNumber {
@@ -20,6 +21,7 @@ impl From<InterfaceNumber> for u8 {
20/// A handle for a USB string descriptor that contains its index. 21/// A handle for a USB string descriptor that contains its index.
21#[derive(Copy, Clone, Eq, PartialEq)] 22#[derive(Copy, Clone, Eq, PartialEq)]
22#[cfg_attr(feature = "defmt", derive(defmt::Format))] 23#[cfg_attr(feature = "defmt", derive(defmt::Format))]
24#[repr(transparent)]
23pub struct StringIndex(pub u8); 25pub struct StringIndex(pub u8);
24 26
25impl StringIndex { 27impl StringIndex {