2022-04-29 17:13:59 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
use core::convert::TryFrom;
|
2022-06-12 22:15:44 +02:00
|
|
|
|
2022-04-29 17:13:59 +02:00
|
|
|
use defmt::*;
|
2022-08-17 23:40:16 +02:00
|
|
|
use embassy_executor::Spawner;
|
2022-06-12 22:15:44 +02:00
|
|
|
use embassy_stm32::time::Hertz;
|
2022-08-17 18:49:55 +02:00
|
|
|
use embassy_stm32::Config;
|
2023-10-15 01:57:25 +02:00
|
|
|
use embassy_time::Timer;
|
2022-06-12 22:15:44 +02:00
|
|
|
use {defmt_rtt as _, panic_probe as _};
|
2022-04-29 17:13:59 +02:00
|
|
|
|
2022-08-17 22:25:58 +02:00
|
|
|
#[embassy_executor::main]
|
|
|
|
async fn main(_spawner: Spawner) {
|
|
|
|
// Example config for maximum performance on a NUCLEO-F207ZG board
|
|
|
|
|
2022-04-29 17:13:59 +02:00
|
|
|
let mut config = Config::default();
|
2023-11-13 01:56:28 +01:00
|
|
|
|
|
|
|
{
|
|
|
|
use embassy_stm32::rcc::*;
|
|
|
|
|
|
|
|
// By default, HSE on the board comes from a 8 MHz clock signal (not a crystal)
|
|
|
|
config.rcc.hse = Some(Hse {
|
|
|
|
freq: Hertz(8_000_000),
|
|
|
|
mode: HseMode::Bypass,
|
|
|
|
});
|
|
|
|
// PLL uses HSE as the clock source
|
|
|
|
config.rcc.pll_src = PllSource::HSE;
|
|
|
|
config.rcc.pll = Some(Pll {
|
|
|
|
// 8 MHz clock source / 8 = 1 MHz PLL input
|
|
|
|
prediv: unwrap!(PllPreDiv::try_from(8)),
|
|
|
|
// 1 MHz PLL input * 240 = 240 MHz PLL VCO
|
|
|
|
mul: unwrap!(PllMul::try_from(240)),
|
|
|
|
// 240 MHz PLL VCO / 2 = 120 MHz main PLL output
|
|
|
|
divp: Some(PllPDiv::DIV2),
|
|
|
|
// 240 MHz PLL VCO / 5 = 48 MHz PLL48 output
|
|
|
|
divq: Some(PllQDiv::DIV5),
|
|
|
|
divr: None,
|
|
|
|
});
|
|
|
|
// System clock comes from PLL (= the 120 MHz main PLL output)
|
|
|
|
config.rcc.sys = Sysclk::PLL1_P;
|
|
|
|
// 120 MHz / 4 = 30 MHz APB1 frequency
|
|
|
|
config.rcc.apb1_pre = APBPrescaler::DIV4;
|
|
|
|
// 120 MHz / 2 = 60 MHz APB2 frequency
|
|
|
|
config.rcc.apb2_pre = APBPrescaler::DIV2;
|
|
|
|
}
|
2022-04-29 17:13:59 +02:00
|
|
|
|
2022-08-17 22:25:58 +02:00
|
|
|
let _p = embassy_stm32::init(config);
|
|
|
|
|
2022-04-29 17:13:59 +02:00
|
|
|
loop {
|
2023-10-15 01:57:25 +02:00
|
|
|
Timer::after_millis(1000).await;
|
2022-04-29 17:13:59 +02:00
|
|
|
info!("1s elapsed");
|
|
|
|
}
|
|
|
|
}
|