Update hal to 0.9.0

master
Levi Pearson 2022-03-09 04:00:10 -07:00
parent 9fdd9a4482
commit 3180a43b43
2 changed files with 17 additions and 15 deletions

View File

@ -10,7 +10,7 @@ edition = "2021"
cortex-m-rtic = "1.0.0"
panic-rtt-target = { version = "0.1.2", features = ["cortex-m"] }
rtt-target = { version = "0.3.1", features = ["cortex-m"] }
stm32f1xx-hal = { version = "0.8.0", features = ["rt", "stm32f103", "medium"] }
stm32f1xx-hal = { version = "0.9.0", features = ["rt", "stm32f103", "medium"] }
[[bin]]
name = "blue_pill_rtic"

View File

@ -45,8 +45,8 @@ mod app {
#[local]
struct Local {
led1: hal::gpio::gpioc::PC13<hal::gpio::Output<hal::gpio::PushPull>>,
tmr2: hal::timer::CountDownTimer<stm32::TIM2>,
tmr3: hal::timer::CountDownTimer<stm32::TIM3>,
tmr2: hal::timer::CounterHz<stm32::TIM2>,
tmr3: hal::timer::CounterHz<stm32::TIM3>,
}
// This task does startup config; the peripherals are passed in thanks to
@ -62,12 +62,12 @@ mod app {
let rcc = cx.device.RCC.constrain();
let clocks = rcc
.cfgr
.use_hse(8.mhz())
.sysclk(8.mhz())
.hclk(8.mhz())
.pclk1(8.mhz())
.pclk2(8.mhz())
.adcclk(8.mhz())
.use_hse(8.MHz())
.sysclk(8.MHz())
.hclk(8.MHz())
.pclk1(8.MHz())
.pclk2(8.MHz())
.adcclk(8.MHz())
.freeze(&mut flash.acr);
// LED is on pin C13, configure it for output
@ -75,11 +75,13 @@ mod app {
let led1 = gpioc.pc13.into_push_pull_output(&mut gpioc.crh);
// Use TIM2 for the beat counter task
let mut tmr2 = Timer::tim2(cx.device.TIM2, &clocks).start_count_down(1.hz());
let mut tmr2 = Timer::new(cx.device.TIM2, &clocks).counter_hz();
tmr2.start(1.Hz()).unwrap();
tmr2.listen(Event::Update);
// Use TIM3 for the LED blinker task
let mut tmr3 = Timer::tim3(cx.device.TIM3, &clocks).start_count_down(2.hz());
let mut tmr3 = Timer::new(cx.device.TIM3, &clocks).counter_hz();
tmr3.start(2.Hz()).unwrap();
tmr3.listen(Event::Update);
rprintln!("init end");
@ -114,15 +116,15 @@ mod app {
beat_update::spawn().unwrap();
// Restart the timer and clear the interrupt flag
cx.local.tmr2.start(1.hz());
cx.local.tmr2.clear_update_interrupt_flag();
cx.local.tmr2.start(1.Hz()).unwrap();
cx.local.tmr2.clear_interrupt(Event::Update);
}
// Interrupt task for TIM3, the LED blink timer
#[task(binds = TIM3, priority = 1, local = [led1, tmr3])]
fn tim3(cx: tim3::Context) {
cx.local.led1.toggle();
cx.local.tmr3.start(2.hz());
cx.local.tmr3.clear_update_interrupt_flag();
cx.local.tmr3.start(2.Hz()).unwrap();
cx.local.tmr3.clear_interrupt(Event::Update);
}
}