stm32/tests: higher clocks for H7
This commit is contained in:
parent
5dc5192d79
commit
a14c4f49c4
@ -11,7 +11,7 @@ use embassy_stm32::Peripherals;
|
|||||||
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
use embedded_hal::digital::v2::{InputPin, OutputPin};
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main(config = "config()")]
|
||||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
@ -34,12 +34,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||||||
|
|
||||||
{
|
{
|
||||||
let _a = Output::new(&mut a, Level::Low, Speed::Low);
|
let _a = Output::new(&mut a, Level::Low, Speed::Low);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_low().unwrap());
|
assert!(b.is_low().unwrap());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let _a = Output::new(&mut a, Level::High, Speed::Low);
|
let _a = Output::new(&mut a, Level::High, Speed::Low);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_high().unwrap());
|
assert!(b.is_high().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,41 +50,48 @@ async fn main(_spawner: Spawner, p: Peripherals) {
|
|||||||
// no pull, the status is undefined
|
// no pull, the status is undefined
|
||||||
|
|
||||||
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_low().unwrap());
|
assert!(b.is_low().unwrap());
|
||||||
a.set_high().unwrap();
|
a.set_high().unwrap();
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_high().unwrap());
|
assert!(b.is_high().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test input pulldown
|
// Test input pulldown
|
||||||
{
|
{
|
||||||
let b = Input::new(&mut b, Pull::Down);
|
let b = Input::new(&mut b, Pull::Down);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_low().unwrap());
|
assert!(b.is_low().unwrap());
|
||||||
|
|
||||||
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_low().unwrap());
|
assert!(b.is_low().unwrap());
|
||||||
a.set_high().unwrap();
|
a.set_high().unwrap();
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_high().unwrap());
|
assert!(b.is_high().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test input pullup
|
// Test input pullup
|
||||||
{
|
{
|
||||||
let b = Input::new(&mut b, Pull::Up);
|
let b = Input::new(&mut b, Pull::Up);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_high().unwrap());
|
assert!(b.is_high().unwrap());
|
||||||
|
|
||||||
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
let mut a = Output::new(&mut a, Level::Low, Speed::Low);
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_low().unwrap());
|
assert!(b.is_low().unwrap());
|
||||||
a.set_high().unwrap();
|
a.set_high().unwrap();
|
||||||
cortex_m::asm::delay(1000);
|
delay();
|
||||||
assert!(b.is_high().unwrap());
|
assert!(b.is_high().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Test OK");
|
info!("Test OK");
|
||||||
cortex_m::asm::bkpt();
|
cortex_m::asm::bkpt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn delay() {
|
||||||
|
#[cfg(feature = "stm32h755zi")]
|
||||||
|
cortex_m::asm::delay(10000);
|
||||||
|
#[cfg(not(feature = "stm32h755zi"))]
|
||||||
|
cortex_m::asm::delay(1000);
|
||||||
|
}
|
||||||
|
@ -10,7 +10,7 @@ use embassy::time::{Duration, Instant, Timer};
|
|||||||
use embassy_stm32::Peripherals;
|
use embassy_stm32::Peripherals;
|
||||||
use example_common::*;
|
use example_common::*;
|
||||||
|
|
||||||
#[embassy::main]
|
#[embassy::main(config = "config()")]
|
||||||
async fn main(_spawner: Spawner, _p: Peripherals) {
|
async fn main(_spawner: Spawner, _p: Peripherals) {
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#![macro_use]
|
#![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 _;
|
use panic_probe as _;
|
||||||
|
|
||||||
pub use defmt::*;
|
pub use defmt::*;
|
||||||
@ -15,3 +18,16 @@ defmt::timestamp! {"{=u64}", {
|
|||||||
n as 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
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user