Add timer test, add g0, g4 tests.
This commit is contained in:
@ -15,6 +15,13 @@ use example_common::*;
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
// Arduino pins D0 and D1
|
||||
// They're connected together with a 1K resistor.
|
||||
#[cfg(feature = "stm32g491re")]
|
||||
let (mut a, mut b) = (p.PC4, p.PC5);
|
||||
#[cfg(feature = "stm32g071rb")]
|
||||
let (mut a, mut b) = (p.PC4, p.PC5);
|
||||
#[cfg(feature = "stm32f429zi")]
|
||||
let (mut a, mut b) = (p.PG14, p.PG9);
|
||||
|
||||
// Test initial output
|
||||
|
27
tests/stm32/src/bin/timer.rs
Normal file
27
tests/stm32/src/bin/timer.rs
Normal file
@ -0,0 +1,27 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use defmt::assert;
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Instant, Timer};
|
||||
use embassy_stm32::Peripherals;
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, _p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
let start = Instant::now();
|
||||
Timer::after(Duration::from_millis(100)).await;
|
||||
let end = Instant::now();
|
||||
let ms = (end - start).as_millis();
|
||||
info!("slept for {} ms", ms);
|
||||
assert!(ms >= 99);
|
||||
assert!(ms < 110);
|
||||
|
||||
info!("Test OK");
|
||||
cortex_m::asm::bkpt();
|
||||
}
|
Reference in New Issue
Block a user