embassy/examples/stm32h7/src/example_common.rs

29 lines
711 B
Rust
Raw Normal View History

2021-06-08 20:47:32 +02:00
#![macro_use]
use defmt_rtt as _; // global logger
use panic_probe as _;
pub use defmt::*;
use core::sync::atomic::{AtomicUsize, Ordering};
use embassy_stm32::time::U32Ext;
2021-08-04 19:42:06 +02:00
use embassy_stm32::Config;
2021-06-08 20:47:32 +02:00
defmt::timestamp! {"{=u64}", {
static COUNT: AtomicUsize = AtomicUsize::new(0);
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
let n = COUNT.load(Ordering::Relaxed);
COUNT.store(n + 1, Ordering::Relaxed);
n as u64
}
}
#[allow(unused)]
pub fn config() -> Config {
let mut config = Config::default();
config.rcc.sys_ck = Some(400.mhz().into());
config.rcc.pll1.q_ck = Some(100.mhz().into());
config.rcc.enable_dma1 = true;
config
}