aboutsummaryrefslogtreecommitdiff
path: root/tests/stm32/src/bin
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-12-07 00:28:32 +0100
committerDario Nieuwenhuis <[email protected]>2021-12-07 00:29:41 +0100
commitdde6607aec758df431eafb5844a78888bc7231e7 (patch)
tree3d43450b7ba67112dad3968fa836f09d4d75026a /tests/stm32/src/bin
parent693690cb5abf5855d190e58142e2b5f7dd63f2bb (diff)
Add timer test, add g0, g4 tests.
Diffstat (limited to 'tests/stm32/src/bin')
-rw-r--r--tests/stm32/src/bin/gpio.rs7
-rw-r--r--tests/stm32/src/bin/timer.rs27
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs
index 7f7fccbfd..7a9d38f2d 100644
--- a/tests/stm32/src/bin/gpio.rs
+++ b/tests/stm32/src/bin/gpio.rs
@@ -15,6 +15,13 @@ use example_common::*;
15async fn main(_spawner: Spawner, p: Peripherals) { 15async fn main(_spawner: Spawner, p: Peripherals) {
16 info!("Hello World!"); 16 info!("Hello World!");
17 17
18 // Arduino pins D0 and D1
19 // They're connected together with a 1K resistor.
20 #[cfg(feature = "stm32g491re")]
21 let (mut a, mut b) = (p.PC4, p.PC5);
22 #[cfg(feature = "stm32g071rb")]
23 let (mut a, mut b) = (p.PC4, p.PC5);
24 #[cfg(feature = "stm32f429zi")]
18 let (mut a, mut b) = (p.PG14, p.PG9); 25 let (mut a, mut b) = (p.PG14, p.PG9);
19 26
20 // Test initial output 27 // Test initial output
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"]
6mod example_common;
7use defmt::assert;
8use embassy::executor::Spawner;
9use embassy::time::{Duration, Instant, Timer};
10use embassy_stm32::Peripherals;
11use example_common::*;
12
13#[embassy::main]
14async 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}