diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-08-17 20:27:42 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-08-17 20:27:42 +0000 |
| commit | 1c5b54a4823d596db730eb476c3ab78110557214 (patch) | |
| tree | 1d22c32eae26435677df89083d71f50fc298a09f /examples/stm32f2/src | |
| parent | d881f3ad9186cf3279aa1ba27093bad94035c186 (diff) | |
| parent | 2e85eaf7d5f4dcf6d84f426542b8ec87aa51c429 (diff) | |
Merge #908
908: Remove HAL initialization from #[embassy_executor::main] macro. r=Dirbaio a=Dirbaio
Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'examples/stm32f2/src')
| -rw-r--r-- | examples/stm32f2/src/bin/blinky.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f2/src/bin/pll.rs | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/examples/stm32f2/src/bin/blinky.rs b/examples/stm32f2/src/bin/blinky.rs index 48ae2e711..2afdeeb35 100644 --- a/examples/stm32f2/src/bin/blinky.rs +++ b/examples/stm32f2/src/bin/blinky.rs | |||
| @@ -6,11 +6,11 @@ use defmt::*; | |||
| 6 | use embassy_executor::executor::Spawner; | 6 | use embassy_executor::executor::Spawner; |
| 7 | use embassy_executor::time::{Duration, Timer}; | 7 | use embassy_executor::time::{Duration, Timer}; |
| 8 | use embassy_stm32::gpio::{Level, Output, Speed}; | 8 | use embassy_stm32::gpio::{Level, Output, Speed}; |
| 9 | use embassy_stm32::Peripherals; | ||
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| 12 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner, p: Peripherals) { | 12 | async fn main(_spawner: Spawner) { |
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | 14 | info!("Hello World!"); |
| 15 | 15 | ||
| 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); | 16 | let mut led = Output::new(p.PB14, Level::High, Speed::Low); |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 01e63b15e..6fce7a716 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -11,11 +11,13 @@ use embassy_stm32::rcc::{ | |||
| 11 | APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, | 11 | APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLL48Div, PLLConfig, PLLMainDiv, PLLMul, PLLPreDiv, PLLSrc, |
| 12 | }; | 12 | }; |
| 13 | use embassy_stm32::time::Hertz; | 13 | use embassy_stm32::time::Hertz; |
| 14 | use embassy_stm32::{Config, Peripherals}; | 14 | use embassy_stm32::Config; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | // Example config for maximum performance on a NUCLEO-F207ZG board | 17 | #[embassy_executor::main] |
| 18 | fn config() -> Config { | 18 | async fn main(_spawner: Spawner) { |
| 19 | // Example config for maximum performance on a NUCLEO-F207ZG board | ||
| 20 | |||
| 19 | let mut config = Config::default(); | 21 | let mut config = Config::default(); |
| 20 | // By default, HSE on the board comes from a 8 MHz clock signal (not a crystal) | 22 | // By default, HSE on the board comes from a 8 MHz clock signal (not a crystal) |
| 21 | config.rcc.hse = Some(HSEConfig { | 23 | config.rcc.hse = Some(HSEConfig { |
| @@ -40,11 +42,9 @@ fn config() -> Config { | |||
| 40 | config.rcc.apb1_pre = APBPrescaler::Div4; | 42 | config.rcc.apb1_pre = APBPrescaler::Div4; |
| 41 | // 120 MHz / 2 = 60 MHz APB2 frequency | 43 | // 120 MHz / 2 = 60 MHz APB2 frequency |
| 42 | config.rcc.apb2_pre = APBPrescaler::Div2; | 44 | config.rcc.apb2_pre = APBPrescaler::Div2; |
| 43 | config | ||
| 44 | } | ||
| 45 | 45 | ||
| 46 | #[embassy_executor::main(config = "config()")] | 46 | let _p = embassy_stm32::init(config); |
| 47 | async fn main(_spawner: Spawner, _p: Peripherals) { | 47 | |
| 48 | loop { | 48 | loop { |
| 49 | Timer::after(Duration::from_millis(1000)).await; | 49 | Timer::after(Duration::from_millis(1000)).await; |
| 50 | info!("1s elapsed"); | 50 | info!("1s elapsed"); |
