diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-11-08 23:08:50 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-11-08 23:21:52 +0100 |
| commit | 0b015bd727547d1eade5cd12c8b6a1b77483e6db (patch) | |
| tree | 77f8a52f5a7eb5a8cc5981eae16e9871614015c7 /embassy-usb/src/builder.rs | |
| parent | 79acb560ecb9089e31efdea29c6046225971fee3 (diff) | |
usb: remove msos-descriptor feature.
Diffstat (limited to 'embassy-usb/src/builder.rs')
| -rw-r--r-- | embassy-usb/src/builder.rs | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/embassy-usb/src/builder.rs b/embassy-usb/src/builder.rs index b4ddccd71..c4705d041 100644 --- a/embassy-usb/src/builder.rs +++ b/embassy-usb/src/builder.rs | |||
| @@ -3,7 +3,6 @@ use heapless::Vec; | |||
| 3 | use crate::config::MAX_HANDLER_COUNT; | 3 | use crate::config::MAX_HANDLER_COUNT; |
| 4 | use crate::descriptor::{BosWriter, DescriptorWriter}; | 4 | use crate::descriptor::{BosWriter, DescriptorWriter}; |
| 5 | use crate::driver::{Driver, Endpoint, EndpointType}; | 5 | use crate::driver::{Driver, Endpoint, EndpointType}; |
| 6 | #[cfg(feature = "msos-descriptor")] | ||
| 7 | use crate::msos::{DeviceLevelDescriptor, FunctionLevelDescriptor, MsOsDescriptorWriter}; | 6 | use crate::msos::{DeviceLevelDescriptor, FunctionLevelDescriptor, MsOsDescriptorWriter}; |
| 8 | use crate::types::{InterfaceNumber, StringIndex}; | 7 | use crate::types::{InterfaceNumber, StringIndex}; |
| 9 | use crate::{Handler, Interface, UsbDevice, MAX_INTERFACE_COUNT, STRING_INDEX_CUSTOM_START}; | 8 | use crate::{Handler, Interface, UsbDevice, MAX_INTERFACE_COUNT, STRING_INDEX_CUSTOM_START}; |
| @@ -133,7 +132,6 @@ pub struct Builder<'d, D: Driver<'d>> { | |||
| 133 | config_descriptor: DescriptorWriter<'d>, | 132 | config_descriptor: DescriptorWriter<'d>, |
| 134 | bos_descriptor: BosWriter<'d>, | 133 | bos_descriptor: BosWriter<'d>, |
| 135 | 134 | ||
| 136 | #[cfg(feature = "msos-descriptor")] | ||
| 137 | msos_descriptor: MsOsDescriptorWriter<'d>, | 135 | msos_descriptor: MsOsDescriptorWriter<'d>, |
| 138 | } | 136 | } |
| 139 | 137 | ||
| @@ -149,7 +147,7 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 149 | device_descriptor_buf: &'d mut [u8], | 147 | device_descriptor_buf: &'d mut [u8], |
| 150 | config_descriptor_buf: &'d mut [u8], | 148 | config_descriptor_buf: &'d mut [u8], |
| 151 | bos_descriptor_buf: &'d mut [u8], | 149 | bos_descriptor_buf: &'d mut [u8], |
| 152 | #[cfg(feature = "msos-descriptor")] msos_descriptor_buf: &'d mut [u8], | 150 | msos_descriptor_buf: &'d mut [u8], |
| 153 | control_buf: &'d mut [u8], | 151 | control_buf: &'d mut [u8], |
| 154 | ) -> Self { | 152 | ) -> Self { |
| 155 | // Magic values specified in USB-IF ECN on IADs. | 153 | // Magic values specified in USB-IF ECN on IADs. |
| @@ -189,14 +187,12 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 189 | config_descriptor, | 187 | config_descriptor, |
| 190 | bos_descriptor, | 188 | bos_descriptor, |
| 191 | 189 | ||
| 192 | #[cfg(feature = "msos-descriptor")] | ||
| 193 | msos_descriptor: MsOsDescriptorWriter::new(msos_descriptor_buf), | 190 | msos_descriptor: MsOsDescriptorWriter::new(msos_descriptor_buf), |
| 194 | } | 191 | } |
| 195 | } | 192 | } |
| 196 | 193 | ||
| 197 | /// Creates the [`UsbDevice`] instance with the configuration in this builder. | 194 | /// Creates the [`UsbDevice`] instance with the configuration in this builder. |
| 198 | pub fn build(mut self) -> UsbDevice<'d, D> { | 195 | pub fn build(mut self) -> UsbDevice<'d, D> { |
| 199 | #[cfg(feature = "msos-descriptor")] | ||
| 200 | let msos_descriptor = self.msos_descriptor.build(&mut self.bos_descriptor); | 196 | let msos_descriptor = self.msos_descriptor.build(&mut self.bos_descriptor); |
| 201 | 197 | ||
| 202 | self.config_descriptor.end_configuration(); | 198 | self.config_descriptor.end_configuration(); |
| @@ -206,7 +202,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 206 | info!("USB: device_descriptor used: {}", self.device_descriptor.position()); | 202 | info!("USB: device_descriptor used: {}", self.device_descriptor.position()); |
| 207 | info!("USB: config_descriptor used: {}", self.config_descriptor.position()); | 203 | info!("USB: config_descriptor used: {}", self.config_descriptor.position()); |
| 208 | info!("USB: bos_descriptor used: {}", self.bos_descriptor.writer.position()); | 204 | info!("USB: bos_descriptor used: {}", self.bos_descriptor.writer.position()); |
| 209 | #[cfg(feature = "msos-descriptor")] | ||
| 210 | info!("USB: msos_descriptor used: {}", msos_descriptor.len()); | 205 | info!("USB: msos_descriptor used: {}", msos_descriptor.len()); |
| 211 | info!("USB: control_buf size: {}", self.control_buf.len()); | 206 | info!("USB: control_buf size: {}", self.control_buf.len()); |
| 212 | 207 | ||
| @@ -217,10 +212,9 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 217 | self.device_descriptor.into_buf(), | 212 | self.device_descriptor.into_buf(), |
| 218 | self.config_descriptor.into_buf(), | 213 | self.config_descriptor.into_buf(), |
| 219 | self.bos_descriptor.writer.into_buf(), | 214 | self.bos_descriptor.writer.into_buf(), |
| 215 | msos_descriptor, | ||
| 220 | self.interfaces, | 216 | self.interfaces, |
| 221 | self.control_buf, | 217 | self.control_buf, |
| 222 | #[cfg(feature = "msos-descriptor")] | ||
| 223 | msos_descriptor, | ||
| 224 | ) | 218 | ) |
| 225 | } | 219 | } |
| 226 | 220 | ||
| @@ -251,7 +245,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 251 | builder: self, | 245 | builder: self, |
| 252 | iface_count_index, | 246 | iface_count_index, |
| 253 | 247 | ||
| 254 | #[cfg(feature = "msos-descriptor")] | ||
| 255 | first_interface, | 248 | first_interface, |
| 256 | } | 249 | } |
| 257 | } | 250 | } |
| @@ -275,7 +268,6 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 275 | StringIndex::new(index) | 268 | StringIndex::new(index) |
| 276 | } | 269 | } |
| 277 | 270 | ||
| 278 | #[cfg(feature = "msos-descriptor")] | ||
| 279 | /// Add an MS OS 2.0 Descriptor Set. | 271 | /// Add an MS OS 2.0 Descriptor Set. |
| 280 | /// | 272 | /// |
| 281 | /// Panics if called more than once. | 273 | /// Panics if called more than once. |
| @@ -283,13 +275,11 @@ impl<'d, D: Driver<'d>> Builder<'d, D> { | |||
| 283 | self.msos_descriptor.header(windows_version, vendor_code); | 275 | self.msos_descriptor.header(windows_version, vendor_code); |
| 284 | } | 276 | } |
| 285 | 277 | ||
| 286 | #[cfg(feature = "msos-descriptor")] | ||
| 287 | /// Add an MS OS 2.0 Device Level Feature Descriptor. | 278 | /// Add an MS OS 2.0 Device Level Feature Descriptor. |
| 288 | pub fn msos_feature<T: DeviceLevelDescriptor>(&mut self, desc: T) { | 279 | pub fn msos_feature<T: DeviceLevelDescriptor>(&mut self, desc: T) { |
| 289 | self.msos_descriptor.device_feature(desc); | 280 | self.msos_descriptor.device_feature(desc); |
| 290 | } | 281 | } |
| 291 | 282 | ||
| 292 | #[cfg(feature = "msos-descriptor")] | ||
| 293 | /// Gets the underlying [`MsOsDescriptorWriter`] to allow adding subsets and features for classes that | 283 | /// Gets the underlying [`MsOsDescriptorWriter`] to allow adding subsets and features for classes that |
| 294 | /// do not add their own. | 284 | /// do not add their own. |
| 295 | pub fn msos_writer(&mut self) -> &mut MsOsDescriptorWriter<'d> { | 285 | pub fn msos_writer(&mut self) -> &mut MsOsDescriptorWriter<'d> { |
| @@ -306,13 +296,11 @@ pub struct FunctionBuilder<'a, 'd, D: Driver<'d>> { | |||
| 306 | builder: &'a mut Builder<'d, D>, | 296 | builder: &'a mut Builder<'d, D>, |
| 307 | iface_count_index: Option<usize>, | 297 | iface_count_index: Option<usize>, |
| 308 | 298 | ||
| 309 | #[cfg(feature = "msos-descriptor")] | ||
| 310 | first_interface: InterfaceNumber, | 299 | first_interface: InterfaceNumber, |
| 311 | } | 300 | } |
| 312 | 301 | ||
| 313 | impl<'a, 'd, D: Driver<'d>> Drop for FunctionBuilder<'a, 'd, D> { | 302 | impl<'a, 'd, D: Driver<'d>> Drop for FunctionBuilder<'a, 'd, D> { |
| 314 | fn drop(&mut self) { | 303 | fn drop(&mut self) { |
| 315 | #[cfg(feature = "msos-descriptor")] | ||
| 316 | self.builder.msos_descriptor.end_function(); | 304 | self.builder.msos_descriptor.end_function(); |
| 317 | } | 305 | } |
| 318 | } | 306 | } |
| @@ -344,7 +332,6 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> { | |||
| 344 | } | 332 | } |
| 345 | } | 333 | } |
| 346 | 334 | ||
| 347 | #[cfg(feature = "msos-descriptor")] | ||
| 348 | /// Add an MS OS 2.0 Function Level Feature Descriptor. | 335 | /// Add an MS OS 2.0 Function Level Feature Descriptor. |
| 349 | pub fn msos_feature<T: FunctionLevelDescriptor>(&mut self, desc: T) { | 336 | pub fn msos_feature<T: FunctionLevelDescriptor>(&mut self, desc: T) { |
| 350 | if !self.builder.msos_descriptor.is_in_config_subset() { | 337 | if !self.builder.msos_descriptor.is_in_config_subset() { |
| @@ -355,7 +342,6 @@ impl<'a, 'd, D: Driver<'d>> FunctionBuilder<'a, 'd, D> { | |||
| 355 | self.builder.msos_descriptor.function(self.first_interface); | 342 | self.builder.msos_descriptor.function(self.first_interface); |
| 356 | } | 343 | } |
| 357 | 344 | ||
| 358 | #[cfg(feature = "msos-descriptor")] | ||
| 359 | self.builder.msos_descriptor.function_feature(desc); | 345 | self.builder.msos_descriptor.function_feature(desc); |
| 360 | } | 346 | } |
| 361 | } | 347 | } |
