Skip to content

Commit

Permalink
Merge branch 'master' into release/0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-summers committed Nov 13, 2023
2 parents 8e2daef + eac466e commit 00317ce
Show file tree
Hide file tree
Showing 11 changed files with 185 additions and 263 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ jobs:
components: rustfmt
- run: cargo fmt --all -- --check
- run: cargo clippy --all-features
- run: cargo clippy --features defmt
- run: cargo clippy --features control-buffer-256
- run: cargo clippy
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Breaking
* Acess numeric form of `EndpointType` variants now require a `.to_bm_attributes()`. ([#60](https://github.com/rust-embedded-community/usb-device/pull/60))
* `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))
* `.manufacturer()`, `.product()` and `.serial_number()` of `UsbDeviceBuilder` now require `&[&str]` to specify strings match with each LANGIDs supported by device. ([#122](https://github.com/rust-embedded-community/usb-device/pull/122))
* `.manufacturer()`, `.product()` and `.serial_number()` of `UsbDeviceBuilder` are now replaced with the `strings()` function that accepts a `StringDescriptor` list to allow multilanguage support ([#122](https://github.com/rust-embedded-community/usb-device/pull/122))
* Various methods of the `UsbDeviceBuilder` now return `Result<>` types instead of internally panicking.

### Changed
* `EndpointType` enum now has fields for isochronous synchronization and usage ([#60](https://github.com/rust-embedded-community/usb-device/pull/60)).
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repository = "https://github.com/mvirkkunen/usb-device"
defmt = { version = "0.3", optional = true }
portable-atomic = { version = "1.2.0", default-features = false }
num_enum = { version = "0.6.1", default-features = false }
heapless = "0.7"

[dev-dependencies]
rusb = "0.9.1"
Expand Down
6 changes: 3 additions & 3 deletions src/control_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ impl<B: UsbBus> ControlPipe<'_, B> {
| ControlState::DataInLast
| ControlState::DataInZlp
| ControlState::StatusOut => {
self.ep_out.read(&mut []).ok();
let _ = self.ep_out.read(&mut []);
self.state = ControlState::Idle;
}
_ => {
// Discard the packet
self.ep_out.read(&mut []).ok();
let _ = self.ep_out.read(&mut []);

// Unexpected OUT packet
self.set_error()
Expand Down Expand Up @@ -235,7 +235,7 @@ impl<B: UsbBus> ControlPipe<'_, B> {
_ => return Err(UsbError::InvalidState),
};

self.ep_in.write(&[]).ok();
let _ = self.ep_in.write(&[]);
self.state = ControlState::StatusIn;
Ok(())
}
Expand Down
28 changes: 23 additions & 5 deletions src/descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,29 @@ impl DescriptorWriter<'_> {
config.product_id as u8,
(config.product_id >> 8) as u8, // idProduct
config.device_release as u8,
(config.device_release >> 8) as u8, // bcdDevice
config.manufacturer.map_or(0, |_| 1), // iManufacturer
config.product.map_or(0, |_| 2), // iProduct
config.serial_number.map_or(0, |_| 3), // iSerialNumber
1, // bNumConfigurations
(config.device_release >> 8) as u8, // bcdDevice
config.string_descriptors.first().map_or(0, |lang| {
if lang.manufacturer.is_some() {
1
} else {
0
}
}),
config.string_descriptors.first().map_or(0, |lang| {
if lang.product.is_some() {
2
} else {
0
}
}),
config.string_descriptors.first().map_or(0, |lang| {
if lang.serial.is_some() {
3
} else {
0
}
}),
1, // bNumConfigurations
],
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/descriptor/lang_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl From<LangID> for u16 {
}

#[allow(missing_docs)]
#[derive(Clone, Copy, PartialEq, TryFromPrimitive)]
#[derive(Clone, Copy, PartialEq, Debug, TryFromPrimitive)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[repr(u16)]
pub enum LangID {
Expand Down Expand Up @@ -349,7 +349,7 @@ pub enum LangID {
MN_MONG_MN = 0x0C50,
DZ_BT = 0x0C51,
TMZ_MA = 0x0C5F,
QUZ_PE = 0x0C6b,
QUZ_PE = 0x0C6B,
LOCALE_CUSTOM_UNSPECIFIED = 0x1000,
AR_LY = 0x1001,
ZH_SG = 0x1004,
Expand Down
Loading

0 comments on commit 00317ce

Please sign in to comment.