aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-12-06 23:39:34 +0000
committerGitHub <[email protected]>2021-12-06 23:39:34 +0000
commitc1b47599357fbc0c616afe56c5b77539149f6887 (patch)
tree3d43450b7ba67112dad3968fa836f09d4d75026a /tests
parent7058f29cf049d2ba14c0f8d99ad964dc1ded918c (diff)
parentdde6607aec758df431eafb5844a78888bc7231e7 (diff)
Merge #519
519: stm32: Add timer test, add g0, g4 tests. r=Dirbaio a=Dirbaio Co-authored-by: Dario Nieuwenhuis <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/.cargo/config.toml3
-rw-r--r--tests/stm32/Cargo.toml9
-rw-r--r--tests/stm32/src/bin/gpio.rs7
-rw-r--r--tests/stm32/src/bin/timer.rs27
4 files changed, 42 insertions, 4 deletions
diff --git a/tests/stm32/.cargo/config.toml b/tests/stm32/.cargo/config.toml
index 40a13ddd3..586a63875 100644
--- a/tests/stm32/.cargo/config.toml
+++ b/tests/stm32/.cargo/config.toml
@@ -4,7 +4,8 @@ build-std-features = ["panic_immediate_abort"]
4 4
5[target.'cfg(all(target_arch = "arm", target_os = "none"))'] 5[target.'cfg(all(target_arch = "arm", target_os = "none"))']
6# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips` 6# replace STM32F429ZITx with your chip as listed in `probe-run --list-chips`
7runner = "probe-run --chip STM32F429ZITx" 7#runner = "teleprobe run --chip STM32G071RBTx --elf"
8runner = "./teleprobe.sh nucleo-stm32f429zi"
8 9
9rustflags = [ 10rustflags = [
10 # Code-size optimizations. 11 # Code-size optimizations.
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index f64043a86..e092caf8b 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -5,10 +5,15 @@ name = "embassy-stm32-tests"
5version = "0.1.0" 5version = "0.1.0"
6resolver = "2" 6resolver = "2"
7 7
8[features]
9stm32f429zi = ["embassy-stm32/stm32f429zi"]
10stm32g071rb = ["embassy-stm32/stm32g071rb"]
11stm32g491re = ["embassy-stm32/stm32g491re"]
12
8[dependencies] 13[dependencies]
9embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } 14embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] }
10embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } 15embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
11embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim2"] } 16embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "memory-x", "time-driver-tim2"] }
12 17
13defmt = "0.3.0" 18defmt = "0.3.0"
14defmt-rtt = "0.3.0" 19defmt-rtt = "0.3.0"
@@ -19,10 +24,8 @@ embedded-hal = "0.2.6"
19panic-probe = { version = "0.3.0", features = ["print-defmt"] } 24panic-probe = { version = "0.3.0", features = ["print-defmt"] }
20 25
21[profile.dev] 26[profile.dev]
22codegen-units = 1
23debug = 2 27debug = 2
24debug-assertions = true 28debug-assertions = true
25incremental = false
26opt-level = 's' 29opt-level = 's'
27overflow-checks = true 30overflow-checks = true
28 31
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}