From 3180a43b4352241f3b8c1c0a06cec66ea200bed9 Mon Sep 17 00:00:00 2001 From: Levi Pearson Date: Wed, 9 Mar 2022 04:00:10 -0700 Subject: [PATCH] Update hal to 0.9.0 --- Cargo.toml | 2 +- src/main.rs | 30 ++++++++++++++++-------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 457093a..3c1bfa7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/main.rs b/src/main.rs index 69b72a2..84eb621 100644 --- a/src/main.rs +++ b/src/main.rs @@ -45,8 +45,8 @@ mod app { #[local] struct Local { led1: hal::gpio::gpioc::PC13>, - tmr2: hal::timer::CountDownTimer, - tmr3: hal::timer::CountDownTimer, + tmr2: hal::timer::CounterHz, + tmr3: hal::timer::CounterHz, } // 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); } }