diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-07-25 10:25:05 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-25 10:25:05 +0000 |
| commit | 8b4bb625be86e7c199a14ceffbed7ad87b99a8db (patch) | |
| tree | 43e1ddb006922ef2100b30311314174f9456d16d | |
| parent | 2537fc6f4fcbdaa0fcea45a37382d61f59cc5767 (diff) | |
| parent | 1598dd55e4f75c616d5461bde4289b962ff77615 (diff) | |
Merge pull request #3206 from embassy-rs/rp-timer-test
tests/rp: add timer test.
| -rwxr-xr-x | ci.sh | 8 | ||||
| -rw-r--r-- | tests/rp/src/bin/timer.rs | 25 |
2 files changed, 33 insertions, 0 deletions
| @@ -2,6 +2,14 @@ | |||
| 2 | 2 | ||
| 3 | set -eo pipefail | 3 | set -eo pipefail |
| 4 | 4 | ||
| 5 | if ! 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 | ||
| 11 | fi | ||
| 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] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | ||
| 4 | |||
| 5 | use defmt::{assert, *}; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_time::{Instant, Timer}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async 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 | } | ||
