Skip to content

Commit

Permalink
Use pre-LangID usb-device -- much smaller size
Browse files Browse the repository at this point in the history
The LangID try_from_primitive took up a huge amount of space
  • Loading branch information
KoviRobi committed Dec 21, 2023
1 parent f44a2fa commit 6d3f2db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 154 deletions.
160 changes: 18 additions & 142 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ cortex-m-rt = "0.7.3"
embedded-hal = "0.2.7"
panic-probe = "0.3.1"
rp-pico = { version = "0.8.0", features = ["rp2040-e5"] }
usb-device = "0.3.1"
usbd-serial = "0.2.0"

[patch.crates-io]
rp2040-hal = { git = "https://github.com/rp-rs/rp-hal.git", branch = "main" }
usb-device = "0.2.9"
usbd-serial = "0.1.1"

[build-dependencies]
cc = "1.0.83"
2 changes: 1 addition & 1 deletion src/cmsis_dap/usb_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<B: UsbBus, const MAX_PACKET_SIZE: usize> usb_device::class::UsbClass<B>
Ok(())
}

fn get_string(&self, index: StringIndex, lang_id: LangID) -> Option<&str> {
fn get_string(&self, index: StringIndex, lang_id: u16) -> Option<&str> {
let _ = lang_id;
if index == self.serial_string {
Some("CMSIS-DAP interface")
Expand Down
9 changes: 3 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ fn main() -> ! {
}

let usb_dev = UsbDeviceBuilder::new(bus_ref, UsbVidPid(0x04b4, 0xf138))
.strings(&[StringDescriptors::new(LangID::EN_US)
.manufacturer("KoviRobi")
.product("CMSIS-DAP")
.serial_number("Test")])
.unwrap()
.manufacturer("KoviRobi")
.product("CMSIS-DAP")
.serial_number("Test")
.device_class(2)
.composite_with_iads()
.max_packet_size_0(64)
.unwrap()
.build();

unsafe {
Expand Down

0 comments on commit 6d3f2db

Please sign in to comment.