Skip to content

Commit

Permalink
Merge pull request #121 from eZioPan/StringIndex-and-IAD
Browse files Browse the repository at this point in the history
let `.iad()` accept a `Option<StringIndex>`
  • Loading branch information
ryan-summers authored Jul 20, 2023
2 parents f72934f + 40d4460 commit 98ccb7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Added support for alternate settings on interfaces ([#114](https://github.com/rust-embedded-community/usb-device/pull/114)).
* Added support for architectures without atomics ([#115](https://github.com/rust-embedded-community/usb-device/pull/115)).

### Breaking
* `DescriptorWriter::iad()` now requires a `Option<StringIndex>` to optionally specify a string for describing the function ([#121](https://github.com/rust-embedded-community/usb-device/pull/121))

### Changed
* `EndpointType` enum now has fields for isochronous synchronization and usage ([#60](https://github.com/rust-embedded-community/usb-device/pull/60)).

Expand Down
6 changes: 5 additions & 1 deletion src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,18 +178,22 @@ impl DescriptorWriter<'_> {
/// that do not conform to any class.
/// * `function_sub_class` - Sub-class code. Depends on class.
/// * `function_protocol` - Protocol code. Depends on class and sub-class.
/// * `function_string` - Index of string descriptor describing this function
pub fn iad(
&mut self,
first_interface: InterfaceNumber,
interface_count: u8,
function_class: u8,
function_sub_class: u8,
function_protocol: u8,
function_string: Option<StringIndex>,
) -> Result<()> {
if !self.write_iads {
return Ok(());
}

let str_index = function_string.map_or(0, Into::into);

self.write(
descriptor_type::IAD,
&[
Expand All @@ -198,7 +202,7 @@ impl DescriptorWriter<'_> {
function_class,
function_sub_class,
function_protocol,
0,
str_index,
],
)?;

Expand Down

0 comments on commit 98ccb7f

Please sign in to comment.