embassy/tests/stm32/src/bin/timer.rs

27 lines
566 B
Rust
Raw Normal View History

2021-12-07 00:28:32 +01:00
#![no_std]
#![no_main]
2023-05-30 00:10:36 +02:00
#[path = "../common.rs"]
mod common;
2021-12-07 00:28:32 +01:00
2023-05-30 00:10:36 +02:00
use common::*;
2021-12-07 00:28:32 +01:00
use defmt::assert;
use embassy_executor::Spawner;
use embassy_time::{Instant, Timer};
2021-12-07 00:28:32 +01:00
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let _p = embassy_stm32::init(config());
2021-12-07 00:28:32 +01:00
info!("Hello World!");
let start = Instant::now();
Timer::after_millis(100).await;
2021-12-07 00:28:32 +01:00
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();
}