diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/stm32/.cargo/config.toml | 3 | ||||
| -rw-r--r-- | tests/stm32/Cargo.toml | 9 | ||||
| -rw-r--r-- | tests/stm32/src/bin/gpio.rs | 7 | ||||
| -rw-r--r-- | tests/stm32/src/bin/timer.rs | 27 |
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` |
| 7 | runner = "probe-run --chip STM32F429ZITx" | 7 | #runner = "teleprobe run --chip STM32G071RBTx --elf" |
| 8 | runner = "./teleprobe.sh nucleo-stm32f429zi" | ||
| 8 | 9 | ||
| 9 | rustflags = [ | 10 | rustflags = [ |
| 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" | |||
| 5 | version = "0.1.0" | 5 | version = "0.1.0" |
| 6 | resolver = "2" | 6 | resolver = "2" |
| 7 | 7 | ||
| 8 | [features] | ||
| 9 | stm32f429zi = ["embassy-stm32/stm32f429zi"] | ||
| 10 | stm32g071rb = ["embassy-stm32/stm32g071rb"] | ||
| 11 | stm32g491re = ["embassy-stm32/stm32g491re"] | ||
| 12 | |||
| 8 | [dependencies] | 13 | [dependencies] |
| 9 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } | 14 | embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt"] } |
| 10 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } | 15 | embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-tim2"] } | 16 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "unstable-pac", "memory-x", "time-driver-tim2"] } |
| 12 | 17 | ||
| 13 | defmt = "0.3.0" | 18 | defmt = "0.3.0" |
| 14 | defmt-rtt = "0.3.0" | 19 | defmt-rtt = "0.3.0" |
| @@ -19,10 +24,8 @@ embedded-hal = "0.2.6" | |||
| 19 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 24 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
| 20 | 25 | ||
| 21 | [profile.dev] | 26 | [profile.dev] |
| 22 | codegen-units = 1 | ||
| 23 | debug = 2 | 27 | debug = 2 |
| 24 | debug-assertions = true | 28 | debug-assertions = true |
| 25 | incremental = false | ||
| 26 | opt-level = 's' | 29 | opt-level = 's' |
| 27 | overflow-checks = true | 30 | overflow-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::*; | |||
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 15 | async 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"] | ||
| 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 | } | ||
