aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-07-25 10:25:05 +0000
committerGitHub <[email protected]>2024-07-25 10:25:05 +0000
commit8b4bb625be86e7c199a14ceffbed7ad87b99a8db (patch)
tree43e1ddb006922ef2100b30311314174f9456d16d
parent2537fc6f4fcbdaa0fcea45a37382d61f59cc5767 (diff)
parent1598dd55e4f75c616d5461bde4289b962ff77615 (diff)
Merge pull request #3206 from embassy-rs/rp-timer-test
tests/rp: add timer test.
-rwxr-xr-xci.sh8
-rw-r--r--tests/rp/src/bin/timer.rs25
2 files changed, 33 insertions, 0 deletions
diff --git a/ci.sh b/ci.sh
index 15bb6eec0..341fe6a09 100755
--- a/ci.sh
+++ b/ci.sh
@@ -2,6 +2,14 @@
2 2
3set -eo pipefail 3set -eo pipefail
4 4
5if ! command -v cargo-batch &> /dev/null; then
6 echo "cargo-batch could not be found. Install it with the following command:"
7 echo ""
8 echo " cargo install --git https://github.com/embassy-rs/cargo-batch cargo --bin cargo-batch --locked"
9 echo ""
10 exit 1
11fi
12
5# check-cfg is stable on rustc 1.79 but not cargo 1.79. 13# check-cfg is stable on rustc 1.79 but not cargo 1.79.
6# however, our cargo-batch is currently based on cargo 1.80, which does support check-cfg. 14# however, our cargo-batch is currently based on cargo 1.80, which does support check-cfg.
7# so, force build.rs scripts to emit check-cfg commands. 15# so, force build.rs scripts to emit check-cfg commands.
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 @@
1#![no_std]
2#![no_main]
3teleprobe_meta::target!(b"rpi-pico");
4
5use defmt::{assert, *};
6use embassy_executor::Spawner;
7use embassy_time::{Instant, Timer};
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let _p = embassy_rp::init(Default::default());
13 info!("Hello World!");
14
15 let start = Instant::now();
16 Timer::after_millis(100).await;
17 let end = Instant::now();
18 let ms = (end - start).as_millis();
19 info!("slept for {} ms", ms);
20 assert!(ms >= 99);
21 assert!(ms < 110);
22
23 info!("Test OK");
24 cortex_m::asm::bkpt();
25}