Merge pull request #3206 from embassy-rs/rp-timer-test

tests/rp: add timer test.
This commit is contained in:
Dario Nieuwenhuis 2024-07-25 10:25:05 +00:00 committed by GitHub
commit 8b4bb625be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

8
ci.sh
View File

@ -2,6 +2,14 @@
set -eo pipefail set -eo pipefail
if ! command -v cargo-batch &> /dev/null; then
echo "cargo-batch could not be found. Install it with the following command:"
echo ""
echo " cargo install --git https://github.com/embassy-rs/cargo-batch cargo --bin cargo-batch --locked"
echo ""
exit 1
fi
# check-cfg is stable on rustc 1.79 but not cargo 1.79. # check-cfg is stable on rustc 1.79 but not cargo 1.79.
# however, our cargo-batch is currently based on cargo 1.80, which does support check-cfg. # however, our cargo-batch is currently based on cargo 1.80, which does support check-cfg.
# so, force build.rs scripts to emit check-cfg commands. # so, force build.rs scripts to emit check-cfg commands.

25
tests/rp/src/bin/timer.rs Normal file
View File

@ -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();
}