diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-12-07 00:28:32 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-12-07 00:29:41 +0100 |
| commit | dde6607aec758df431eafb5844a78888bc7231e7 (patch) | |
| tree | 3d43450b7ba67112dad3968fa836f09d4d75026a /tests/stm32/src/bin/timer.rs | |
| parent | 693690cb5abf5855d190e58142e2b5f7dd63f2bb (diff) | |
Add timer test, add g0, g4 tests.
Diffstat (limited to 'tests/stm32/src/bin/timer.rs')
| -rw-r--r-- | tests/stm32/src/bin/timer.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs new file mode 100644 index 000000000..de19a22e3 --- /dev/null +++ b/tests/stm32/src/bin/timer.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | #[path = "../example_common.rs"] | ||
| 6 | mod example_common; | ||
| 7 | use defmt::assert; | ||
| 8 | use embassy::executor::Spawner; | ||
| 9 | use embassy::time::{Duration, Instant, Timer}; | ||
| 10 | use embassy_stm32::Peripherals; | ||
| 11 | use example_common::*; | ||
| 12 | |||
| 13 | #[embassy::main] | ||
| 14 | async fn main(_spawner: Spawner, _p: Peripherals) { | ||
| 15 | info!("Hello World!"); | ||
| 16 | |||
| 17 | let start = Instant::now(); | ||
| 18 | Timer::after(Duration::from_millis(100)).await; | ||
| 19 | let end = Instant::now(); | ||
| 20 | let ms = (end - start).as_millis(); | ||
| 21 | info!("slept for {} ms", ms); | ||
| 22 | assert!(ms >= 99); | ||
| 23 | assert!(ms < 110); | ||
| 24 | |||
| 25 | info!("Test OK"); | ||
| 26 | cortex_m::asm::bkpt(); | ||
| 27 | } | ||
