From 1598dd55e4f75c616d5461bde4289b962ff77615 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 24 Jul 2024 17:31:01 +0200 Subject: [PATCH] tests/rp: add timer test. --- tests/rp/src/bin/timer.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/rp/src/bin/timer.rs diff --git a/tests/rp/src/bin/timer.rs b/tests/rp/src/bin/timer.rs new file mode 100644 index 000000000..be9242144 --- /dev/null +++ b/tests/rp/src/bin/timer.rs @@ -0,0 +1,25 @@ +#![no_std] +#![no_main] +teleprobe_meta::target!(b"rpi-pico"); + +use defmt::{assert, *}; +use embassy_executor::Spawner; +use embassy_time::{Instant, Timer}; +use {defmt_rtt as _, panic_probe as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + let _p = embassy_rp::init(Default::default()); + info!("Hello World!"); + + let start = Instant::now(); + Timer::after_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(); +}