From 4d424ff9bb67e7df112ee57b11c488c699979e90 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 20 Nov 2023 10:47:55 +0100 Subject: [PATCH 1/4] Updating usb crates --- CHANGELOG.md | 1 + Cargo.toml | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d72624ef..b5bd57bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Bugfix, usb: On RM0455 and RM0468 parts, PA11/PA12 do not have an alternate function (AF) for USB. Use `into_analog()` when passing pins to `USB1/2::new` on these parts [#464] +* [breaking] `usb-device` updated to v0.3.0 ## [v0.15.0] 2023-10-09 diff --git a/Cargo.toml b/Cargo.toml index 9e2370b4..b3aef94c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ bare-metal = "1.0.0" sdio-host = { version = "0.9", optional = true } embedded-sdmmc = { version = "0.5", optional = true } stm32-fmc = { version = "0.3", optional = true } -synopsys-usb-otg = { version = "^0.3.0", features = ["cortex-m"], optional = true } +synopsys-usb-otg = { version = "0.4", features = ["cortex-m"], optional = true } embedded-display-controller = { version = "^0.1.0", optional = true } log = { version = "0.4.14", optional = true} # see also the dev-dependencies section fdcan = { version = "0.2", optional = true } @@ -76,8 +76,8 @@ cortex-m-log = { version = "0.8.0", features = ["itm", "semihosting", "log-integ cortex-m-semihosting = "0.5.0" panic-itm = { version = "~0.4.1" } panic-semihosting = "0.6" -usb-device = "0.2.5" -usbd-serial = "0.1.0" +usb-device = "0.3" +usbd-serial = "0.2.0" numtoa = "0.2.3" tinybmp = "0.5" embedded-graphics = "0.8" From 086d5747f130799bbb8cc27d4e41da440907fe46 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 20 Nov 2023 11:25:20 +0100 Subject: [PATCH 2/4] Updating examples --- examples/usb_passthrough.rs | 8 +++++--- examples/usb_phy_serial_interrupt.rs | 10 ++++++---- examples/usb_rtic.rs | 8 +++++--- examples/usb_serial.rs | 8 +++++--- src/usb_hs.rs | 6 +++--- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/examples/usb_passthrough.rs b/examples/usb_passthrough.rs index 0c8dc1cc..e1a4982d 100644 --- a/examples/usb_passthrough.rs +++ b/examples/usb_passthrough.rs @@ -73,9 +73,11 @@ fn main() -> ! { let mut serial1 = usbd_serial::SerialPort::new(&usb1_bus); let mut usb1_dev = UsbDeviceBuilder::new(&usb1_bus, UsbVidPid(0x16c0, 0x27dd)) - .manufacturer("Fake company") - .product("Serial port") - .serial_number("TEST PORT 1") + .strings(&[usb_device::device::StringDescriptors::default() + .manufacturer("Fake company") + .product("Serial port") + .serial_number("TEST PORT 1") + ]).unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build(); diff --git a/examples/usb_phy_serial_interrupt.rs b/examples/usb_phy_serial_interrupt.rs index dff0fee7..bd314a82 100644 --- a/examples/usb_phy_serial_interrupt.rs +++ b/examples/usb_phy_serial_interrupt.rs @@ -152,11 +152,13 @@ unsafe fn main() -> ! { USB_BUS_ALLOCATOR.as_ref().unwrap(), UsbVidPid(VID, PID), ) - .manufacturer("Fake company") - .product("Serial port") - .serial_number("TEST") + .strings(&[usb_device::device::StringDescriptors::default() + .manufacturer("Fake company") + .product("Serial port") + .serial_number("TEST PORT 1") + ]).unwrap() .device_class(usbd_serial::USB_CLASS_CDC) - .max_packet_size_0(64) + .max_packet_size_0(64).unwrap() .build(); interrupt_free(|cs| { diff --git a/examples/usb_rtic.rs b/examples/usb_rtic.rs index 19fe6273..8263b805 100644 --- a/examples/usb_rtic.rs +++ b/examples/usb_rtic.rs @@ -91,9 +91,11 @@ mod app { .unwrap(); let serial = usbd_serial::SerialPort::new(usb_bus); let usb_dev = UsbDeviceBuilder::new(usb_bus, UsbVidPid(0x16c0, 0x27dd)) - .manufacturer("Fake company") - .product("Serial port") - .serial_number("TEST") + .strings(&[usb_device::device::StringDescriptors::default() + .manufacturer("Fake company") + .product("Serial port") + .serial_number("TEST PORT 1") + ]).unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build(); let usb = (usb_dev, serial); diff --git a/examples/usb_serial.rs b/examples/usb_serial.rs index 892e15f6..2ddf85c6 100644 --- a/examples/usb_serial.rs +++ b/examples/usb_serial.rs @@ -78,9 +78,11 @@ fn main() -> ! { let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27dd)) - .manufacturer("Fake company") - .product("Serial port") - .serial_number("TEST") + .strings(&[usb_device::device::StringDescriptors::default() + .manufacturer("Fake company") + .product("Serial port") + .serial_number("TEST PORT 1") + ]).unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build(); diff --git a/src/usb_hs.rs b/src/usb_hs.rs index 26354e2f..e0aa7983 100644 --- a/src/usb_hs.rs +++ b/src/usb_hs.rs @@ -18,7 +18,7 @@ use crate::rcc; use crate::stm32; -use crate::gpio::{self, Alternate, Analog, Speed}; +use crate::gpio::{self, Alternate, Speed}; use crate::time::Hertz; @@ -50,8 +50,8 @@ impl USB1 { usb_global: stm32::OTG1_HS_GLOBAL, usb_device: stm32::OTG1_HS_DEVICE, usb_pwrclk: stm32::OTG1_HS_PWRCLK, - _pin_dm: gpio::PA11, - _pin_dp: gpio::PA12, + _pin_dm: gpio::PA11, + _pin_dp: gpio::PA12, prec: rcc::rec::Usb1Otg, clocks: &rcc::CoreClocks, ) -> Self { From 1fb266c75fee147e9d199f3690262b28d9c2e280 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 20 Nov 2023 11:28:29 +0100 Subject: [PATCH 3/4] Fixing format --- examples/usb_passthrough.rs | 4 ++-- examples/usb_phy_serial_interrupt.rs | 13 +++++++------ examples/usb_rtic.rs | 4 ++-- examples/usb_serial.rs | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/usb_passthrough.rs b/examples/usb_passthrough.rs index e1a4982d..cb43443d 100644 --- a/examples/usb_passthrough.rs +++ b/examples/usb_passthrough.rs @@ -76,8 +76,8 @@ fn main() -> ! { .strings(&[usb_device::device::StringDescriptors::default() .manufacturer("Fake company") .product("Serial port") - .serial_number("TEST PORT 1") - ]).unwrap() + .serial_number("TEST PORT 1")]) + .unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build(); diff --git a/examples/usb_phy_serial_interrupt.rs b/examples/usb_phy_serial_interrupt.rs index bd314a82..4ed5d4f4 100644 --- a/examples/usb_phy_serial_interrupt.rs +++ b/examples/usb_phy_serial_interrupt.rs @@ -152,13 +152,14 @@ unsafe fn main() -> ! { USB_BUS_ALLOCATOR.as_ref().unwrap(), UsbVidPid(VID, PID), ) - .strings(&[usb_device::device::StringDescriptors::default() - .manufacturer("Fake company") - .product("Serial port") - .serial_number("TEST PORT 1") - ]).unwrap() + .strings(&[usb_device::device::StringDescriptors::default() + .manufacturer("Fake company") + .product("Serial port") + .serial_number("TEST PORT 1")]) + .unwrap() .device_class(usbd_serial::USB_CLASS_CDC) - .max_packet_size_0(64).unwrap() + .max_packet_size_0(64) + .unwrap() .build(); interrupt_free(|cs| { diff --git a/examples/usb_rtic.rs b/examples/usb_rtic.rs index 8263b805..aa1e99b9 100644 --- a/examples/usb_rtic.rs +++ b/examples/usb_rtic.rs @@ -94,8 +94,8 @@ mod app { .strings(&[usb_device::device::StringDescriptors::default() .manufacturer("Fake company") .product("Serial port") - .serial_number("TEST PORT 1") - ]).unwrap() + .serial_number("TEST PORT 1")]) + .unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build(); let usb = (usb_dev, serial); diff --git a/examples/usb_serial.rs b/examples/usb_serial.rs index 2ddf85c6..951627da 100644 --- a/examples/usb_serial.rs +++ b/examples/usb_serial.rs @@ -81,8 +81,8 @@ fn main() -> ! { .strings(&[usb_device::device::StringDescriptors::default() .manufacturer("Fake company") .product("Serial port") - .serial_number("TEST PORT 1") - ]).unwrap() + .serial_number("TEST PORT 1")]) + .unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build(); From 18b49fe37d3e157a5eeeee2e12e016477a6bcf22 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 20 Nov 2023 12:48:38 +0100 Subject: [PATCH 4/4] Fixing passthrough example --- examples/usb_passthrough.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/usb_passthrough.rs b/examples/usb_passthrough.rs index cb43443d..89440baa 100644 --- a/examples/usb_passthrough.rs +++ b/examples/usb_passthrough.rs @@ -86,9 +86,11 @@ fn main() -> ! { let mut serial2 = usbd_serial::SerialPort::new(&usb2_bus); let mut usb2_dev = UsbDeviceBuilder::new(&usb2_bus, UsbVidPid(0x16c0, 0x27dd)) - .manufacturer("Fake company") - .product("Serial port") - .serial_number("TEST PORT 2") + .strings(&[usb_device::device::StringDescriptors::default() + .manufacturer("Fake company") + .product("Serial port") + .serial_number("TEST PORT 1")]) + .unwrap() .device_class(usbd_serial::USB_CLASS_CDC) .build();