Skip to content

Commit 8435494

Browse files
committed
Update stm32l4xx-hal, use toggle()
1 parent 22aa576 commit 8435494

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

rtic_v1/stm32l4_heartbeat/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ edition = "2021"
1515
[dependencies]
1616
embedded-hal = "0.2.6"
1717
cortex-m-rtic = "1.0.0"
18-
stm32l4xx-hal = { version = "0.6.0", features = ["rt", "stm32l4x2"] }
18+
stm32l4xx-hal = { version = "0.7.1", features = ["rt", "stm32l412"] }
1919
heapless = "0.7.10"
2020
systick-monotonic = "1.0.0"
2121
panic-rtt-target = { version = "0.1.2", features = ["cortex-m"] }

rtic_v1/stm32l4_heartbeat/src/main.rs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use heapless::Vec;
77
use panic_rtt_target as _;
88
use rtic::app;
99
use rtt_target::{rprintln, rtt_init_print};
10-
use stm32l4xx_hal::gpio::{gpiob::PB3, Output, PushPull, State};
10+
use stm32l4xx_hal::gpio::{gpiob::PB3, Output, PushPull};
1111
use stm32l4xx_hal::prelude::*;
1212
use systick_monotonic::{fugit::Duration, Systick};
1313

@@ -38,15 +38,14 @@ mod app {
3838
rtt_init_print!();
3939
rprintln!("init");
4040

41-
let _clocks = rcc.cfgr.sysclk(72.mhz()).freeze(&mut flash.acr, &mut pwr);
41+
let _clocks = rcc.cfgr.sysclk(72.MHz()).freeze(&mut flash.acr, &mut pwr);
4242

4343
// Setup LED
4444
let mut gpiob = cx.device.GPIOB.split(&mut rcc.ahb2);
45-
let led = gpiob.pb3.into_push_pull_output_with_state(
46-
&mut gpiob.moder,
47-
&mut gpiob.otyper,
48-
State::Low,
49-
);
45+
let mut led = gpiob
46+
.pb3
47+
.into_push_pull_output(&mut gpiob.moder, &mut gpiob.otyper);
48+
led.set_low();
5049

5150
// Simple heart beat LED on/off sequence
5251
let mut intervals: Vec<u32, 6> = Vec::new();
@@ -76,16 +75,11 @@ mod app {
7675
let duration = cx.local.intervals[state];
7776
let next_state = (state + 1) % cx.local.intervals.len();
7877

79-
if state % 2 == 0 {
80-
cx.local.led.set_high().unwrap();
81-
} else {
82-
cx.local.led.set_low().unwrap();
83-
}
78+
cx.local.led.toggle();
8479

85-
blink::spawn_after(
80+
let _ = blink::spawn_after(
8681
Duration::<u64, 1, 1000>::from_ticks(duration as u64),
8782
next_state,
88-
)
89-
.unwrap();
83+
);
9084
}
9185
}

0 commit comments

Comments
 (0)