From 7a3ac36c0b4d64274d7fb2221cba37315cbdb8da Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Tue, 8 Oct 2024 11:19:53 +0200 Subject: [PATCH] example: update to `stm32f4xx-hal` to 0.22.0 this is a breaking change and thus needs some manual changes. see stm32-rs/stm32f4xx-hal#791 for details. --- .../stm32f4-single-motor-example/Cargo.lock | 46 ++++++++++++------- .../stm32f4-single-motor-example/Cargo.toml | 2 +- .../stm32f4-single-motor-example/src/main.rs | 9 ++-- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/examples/stm32f4-single-motor-example/Cargo.lock b/examples/stm32f4-single-motor-example/Cargo.lock index b839c9e..f5eff6e 100644 --- a/examples/stm32f4-single-motor-example/Cargo.lock +++ b/examples/stm32f4-single-motor-example/Cargo.lock @@ -212,6 +212,12 @@ dependencies = [ "nb 1.1.0", ] +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "embedded-storage" version = "0.3.1" @@ -348,6 +354,12 @@ dependencies = [ "defmt", ] +[[package]] +name = "portable-atomic" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" + [[package]] name = "powerfmt" version = "0.2.0" @@ -486,18 +498,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "stm32f4" -version = "0.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb94729242cd1aebe6dab42a2ca0131985ae93bc3ab2751b680df724bb35528d" -dependencies = [ - "bare-metal 1.0.0", - "cortex-m", - "cortex-m-rt", - "vcell", -] - [[package]] name = "stm32f4-single-motor-example" version = "0.1.0" @@ -511,11 +511,25 @@ dependencies = [ "tb6612fng", ] +[[package]] +name = "stm32f4-staging" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a6d5e873d8f15406aadd4349b491e28617173a90f152c0635863b1919070af" +dependencies = [ + "cortex-m", + "cortex-m-rt", + "critical-section", + "defmt", + "portable-atomic", + "vcell", +] + [[package]] name = "stm32f4xx-hal" -version = "0.21.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceed60591531f4da636d828701c74861a3d100e5c4e36677cadbd2eb6f46eb67" +checksum = "243ab58411b5b063098402d18a5d44916336ec86a288b613796e376bd83eaf80" dependencies = [ "bare-metal 1.0.0", "cortex-m", @@ -526,6 +540,7 @@ dependencies = [ "embedded-hal 0.2.7", "embedded-hal 1.0.0", "embedded-hal-nb", + "embedded-io", "embedded-storage", "enumflags2", "fugit", @@ -533,10 +548,9 @@ dependencies = [ "nb 1.1.0", "rand_core", "rtic-monotonic", - "stm32f4", + "stm32f4-staging", "systick-monotonic", "time", - "vcell", "void", ] diff --git a/examples/stm32f4-single-motor-example/Cargo.toml b/examples/stm32f4-single-motor-example/Cargo.toml index a5ab71c..39a4860 100644 --- a/examples/stm32f4-single-motor-example/Cargo.toml +++ b/examples/stm32f4-single-motor-example/Cargo.toml @@ -9,7 +9,7 @@ cortex-m = { version = "0.7", features = ["critical-section-single-core"]} cortex-m-rtic = "1.1.4" panic-probe = { version = "0.3", features = ["print-defmt"] } -stm32f4xx-hal = { version = "0.21.0", features = ["stm32f401", "rtic1"] } +stm32f4xx-hal = { version = "0.22", features = ["stm32f401", "rtic1"] } defmt = "0.3.6" defmt-rtt = "0.4" diff --git a/examples/stm32f4-single-motor-example/src/main.rs b/examples/stm32f4-single-motor-example/src/main.rs index cf65476..5997b8b 100644 --- a/examples/stm32f4-single-motor-example/src/main.rs +++ b/examples/stm32f4-single-motor-example/src/main.rs @@ -13,7 +13,7 @@ use defmt_rtt as _; #[rtic::app(device = stm32f4xx_hal::pac, dispatchers = [EXTI1])] mod app { use stm32f4xx_hal::gpio::{Edge, Input, Output, PB4, PB5, PC13}; - use stm32f4xx_hal::timer::{Channel3, MonoTimerUs, PwmChannel}; + use stm32f4xx_hal::timer::{MonoTimerUs, PwmChannel}; use stm32f4xx_hal::{pac, pac::TIM2, prelude::*, watchdog::IndependentWatchdog}; use tb6612fng::{DriveCommand, Motor}; @@ -46,11 +46,8 @@ mod app { // set up the motor let motor_in1 = gpiob.pb5.into_push_pull_output(); let motor_in2 = gpiob.pb4.into_push_pull_output(); - let mut motor_pwm = ctx - .device - .TIM2 - .pwm_hz(Channel3::new(gpiob.pb10), 100.kHz(), &clocks) - .split(); + let (_, (_, _, motor_pwm, ..)) = ctx.device.TIM2.pwm_hz(100.kHz(), &clocks); + let mut motor_pwm = motor_pwm.with(gpiob.pb10); motor_pwm.enable(); let mut motor = Motor::new(motor_in1, motor_in2, motor_pwm).unwrap(); motor.drive(DriveCommand::Backward(0)).unwrap();