diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-12-07 05:00:35 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-12-07 05:00:35 +0100 |
| commit | a14c4f49c4f73b5bd1463b81d2b32666335ebfec (patch) | |
| tree | c6d581a520d123c006aaa96903f0977218dda859 /tests/stm32/src/bin | |
| parent | 5dc5192d79d211569b447dd12b4b09191a9b5a54 (diff) | |
stm32/tests: higher clocks for H7
Diffstat (limited to 'tests/stm32/src/bin')
| -rw-r--r-- | tests/stm32/src/bin/gpio.rs | 29 | ||||
| -rw-r--r-- | tests/stm32/src/bin/timer.rs | 2 |
2 files changed, 19 insertions, 12 deletions
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index f276ce7f4..51ede6cea 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs | |||
| @@ -11,7 +11,7 @@ use embassy_stm32::Peripherals; | |||
| 11 | use embedded_hal::digital::v2::{InputPin, OutputPin}; | 11 | use embedded_hal::digital::v2::{InputPin, OutputPin}; |
| 12 | use example_common::*; | 12 | use example_common::*; |
| 13 | 13 | ||
| 14 | #[embassy::main] | 14 | #[embassy::main(config = "config()")] |
| 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 | ||
| @@ -34,12 +34,12 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 34 | 34 | ||
| 35 | { | 35 | { |
| 36 | let _a = Output::new(&mut a, Level::Low, Speed::Low); | 36 | let _a = Output::new(&mut a, Level::Low, Speed::Low); |
| 37 | cortex_m::asm::delay(1000); | 37 | delay(); |
| 38 | assert!(b.is_low().unwrap()); | 38 | assert!(b.is_low().unwrap()); |
| 39 | } | 39 | } |
| 40 | { | 40 | { |
| 41 | let _a = Output::new(&mut a, Level::High, Speed::Low); | 41 | let _a = Output::new(&mut a, Level::High, Speed::Low); |
| 42 | cortex_m::asm::delay(1000); | 42 | delay(); |
| 43 | assert!(b.is_high().unwrap()); | 43 | assert!(b.is_high().unwrap()); |
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| @@ -50,41 +50,48 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 50 | // no pull, the status is undefined | 50 | // no pull, the status is undefined |
| 51 | 51 | ||
| 52 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 52 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); |
| 53 | cortex_m::asm::delay(1000); | 53 | delay(); |
| 54 | assert!(b.is_low().unwrap()); | 54 | assert!(b.is_low().unwrap()); |
| 55 | a.set_high().unwrap(); | 55 | a.set_high().unwrap(); |
| 56 | cortex_m::asm::delay(1000); | 56 | delay(); |
| 57 | assert!(b.is_high().unwrap()); | 57 | assert!(b.is_high().unwrap()); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | // Test input pulldown | 60 | // Test input pulldown |
| 61 | { | 61 | { |
| 62 | let b = Input::new(&mut b, Pull::Down); | 62 | let b = Input::new(&mut b, Pull::Down); |
| 63 | cortex_m::asm::delay(1000); | 63 | delay(); |
| 64 | assert!(b.is_low().unwrap()); | 64 | assert!(b.is_low().unwrap()); |
| 65 | 65 | ||
| 66 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 66 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); |
| 67 | cortex_m::asm::delay(1000); | 67 | delay(); |
| 68 | assert!(b.is_low().unwrap()); | 68 | assert!(b.is_low().unwrap()); |
| 69 | a.set_high().unwrap(); | 69 | a.set_high().unwrap(); |
| 70 | cortex_m::asm::delay(1000); | 70 | delay(); |
| 71 | assert!(b.is_high().unwrap()); | 71 | assert!(b.is_high().unwrap()); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | // Test input pullup | 74 | // Test input pullup |
| 75 | { | 75 | { |
| 76 | let b = Input::new(&mut b, Pull::Up); | 76 | let b = Input::new(&mut b, Pull::Up); |
| 77 | cortex_m::asm::delay(1000); | 77 | delay(); |
| 78 | assert!(b.is_high().unwrap()); | 78 | assert!(b.is_high().unwrap()); |
| 79 | 79 | ||
| 80 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); | 80 | let mut a = Output::new(&mut a, Level::Low, Speed::Low); |
| 81 | cortex_m::asm::delay(1000); | 81 | delay(); |
| 82 | assert!(b.is_low().unwrap()); | 82 | assert!(b.is_low().unwrap()); |
| 83 | a.set_high().unwrap(); | 83 | a.set_high().unwrap(); |
| 84 | cortex_m::asm::delay(1000); | 84 | delay(); |
| 85 | assert!(b.is_high().unwrap()); | 85 | assert!(b.is_high().unwrap()); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | info!("Test OK"); | 88 | info!("Test OK"); |
| 89 | cortex_m::asm::bkpt(); | 89 | cortex_m::asm::bkpt(); |
| 90 | } | 90 | } |
| 91 | |||
| 92 | fn delay() { | ||
| 93 | #[cfg(feature = "stm32h755zi")] | ||
| 94 | cortex_m::asm::delay(10000); | ||
| 95 | #[cfg(not(feature = "stm32h755zi"))] | ||
| 96 | cortex_m::asm::delay(1000); | ||
| 97 | } | ||
diff --git a/tests/stm32/src/bin/timer.rs b/tests/stm32/src/bin/timer.rs index de19a22e3..002a8a4d3 100644 --- a/tests/stm32/src/bin/timer.rs +++ b/tests/stm32/src/bin/timer.rs | |||
| @@ -10,7 +10,7 @@ use embassy::time::{Duration, Instant, Timer}; | |||
| 10 | use embassy_stm32::Peripherals; | 10 | use embassy_stm32::Peripherals; |
| 11 | use example_common::*; | 11 | use example_common::*; |
| 12 | 12 | ||
| 13 | #[embassy::main] | 13 | #[embassy::main(config = "config()")] |
| 14 | async fn main(_spawner: Spawner, _p: Peripherals) { | 14 | async fn main(_spawner: Spawner, _p: Peripherals) { |
| 15 | info!("Hello World!"); | 15 | info!("Hello World!"); |
| 16 | 16 | ||
