Skip to content

Commit

Permalink
example: update to stm32f4xx-hal to 0.22.0
Browse files Browse the repository at this point in the history
this is a breaking change and thus needs some manual changes.
see stm32-rs/stm32f4xx-hal#791 for details.
  • Loading branch information
rursprung committed Oct 12, 2024
1 parent d399e20 commit 7a3ac36
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
46 changes: 30 additions & 16 deletions examples/stm32f4-single-motor-example/Cargo.lock

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

2 changes: 1 addition & 1 deletion examples/stm32f4-single-motor-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 3 additions & 6 deletions examples/stm32f4-single-motor-example/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 7a3ac36

Please sign in to comment.