examples Remove the fn config() idiom.

It was only useful for doing #[embassy_executor::main(config = "config()")]`. Now that
it's gone, it makes more sense to build the config in main directly.
This commit is contained in:
Dario Nieuwenhuis
2022-08-17 22:25:58 +02:00
parent fc6e1e06b3
commit 2e85eaf7d5
30 changed files with 121 additions and 229 deletions

View File

@ -14,8 +14,10 @@ use embassy_stm32::time::Hertz;
use embassy_stm32::Config;
use {defmt_rtt as _, panic_probe as _};
// Example config for maximum performance on a NUCLEO-F207ZG board
fn config() -> Config {
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
// Example config for maximum performance on a NUCLEO-F207ZG board
let mut config = Config::default();
// By default, HSE on the board comes from a 8 MHz clock signal (not a crystal)
config.rcc.hse = Some(HSEConfig {
@ -40,12 +42,9 @@ fn config() -> Config {
config.rcc.apb1_pre = APBPrescaler::Div4;
// 120 MHz / 2 = 60 MHz APB2 frequency
config.rcc.apb2_pre = APBPrescaler::Div2;
config
}
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let _p = embassy_stm32::init(config());
let _p = embassy_stm32::init(config);
loop {
Timer::after(Duration::from_millis(1000)).await;
info!("1s elapsed");