stm32/tests: higher clocks for H7

This commit is contained in:
Dario Nieuwenhuis 2021-12-07 05:00:35 +01:00
parent 5dc5192d79
commit a14c4f49c4
3 changed files with 36 additions and 13 deletions

View file

@ -11,7 +11,7 @@ use embassy_stm32::Peripherals;
use embedded_hal::digital::v2::{InputPin, OutputPin};
use example_common::*;
#[embassy::main]
#[embassy::main(config = "config()")]
async fn main(_spawner: Spawner, p: Peripherals) {
info!("Hello World!");
@ -34,12 +34,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
{
let _a = Output::new(&mut a, Level::Low, Speed::Low);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_low().unwrap());
}
{
let _a = Output::new(&mut a, Level::High, Speed::Low);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_high().unwrap());
}
}
@ -50,41 +50,48 @@ async fn main(_spawner: Spawner, p: Peripherals) {
// no pull, the status is undefined
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_low().unwrap());
a.set_high().unwrap();
cortex_m::asm::delay(1000);
delay();
assert!(b.is_high().unwrap());
}
// Test input pulldown
{
let b = Input::new(&mut b, Pull::Down);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_low().unwrap());
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_low().unwrap());
a.set_high().unwrap();
cortex_m::asm::delay(1000);
delay();
assert!(b.is_high().unwrap());
}
// Test input pullup
{
let b = Input::new(&mut b, Pull::Up);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_high().unwrap());
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
cortex_m::asm::delay(1000);
delay();
assert!(b.is_low().unwrap());
a.set_high().unwrap();
cortex_m::asm::delay(1000);
delay();
assert!(b.is_high().unwrap());
}
info!("Test OK");
cortex_m::asm::bkpt();
}
fn delay() {
#[cfg(feature = "stm32h755zi")]
cortex_m::asm::delay(10000);
#[cfg(not(feature = "stm32h755zi"))]
cortex_m::asm::delay(1000);
}

View file

@ -10,7 +10,7 @@ use embassy::time::{Duration, Instant, Timer};
use embassy_stm32::Peripherals;
use example_common::*;
#[embassy::main]
#[embassy::main(config = "config()")]
async fn main(_spawner: Spawner, _p: Peripherals) {
info!("Hello World!");

View file

@ -1,6 +1,9 @@
#![macro_use]
use defmt_rtt as _; // global logger
use defmt_rtt as _;
#[allow(unused)]
use embassy_stm32::time::Hertz;
use embassy_stm32::Config;
use panic_probe as _;
pub use defmt::*;
@ -15,3 +18,16 @@ defmt::timestamp! {"{=u64}", {
n as u64
}
}
pub fn config() -> Config {
#[allow(unused_mut)]
let mut config = Config::default();
#[cfg(feature = "stm32h755zi")]
{
config.rcc.sys_ck = Some(Hertz(400_000_000));
config.rcc.pll1.q_ck = Some(Hertz(100_000_000));
}
config
}