aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-12-07 05:00:35 +0100
committerDario Nieuwenhuis <[email protected]>2021-12-07 05:00:35 +0100
commita14c4f49c4f73b5bd1463b81d2b32666335ebfec (patch)
treec6d581a520d123c006aaa96903f0977218dda859 /tests
parent5dc5192d79d211569b447dd12b4b09191a9b5a54 (diff)
stm32/tests: higher clocks for H7
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/src/bin/gpio.rs29
-rw-r--r--tests/stm32/src/bin/timer.rs2
-rw-r--r--tests/stm32/src/example_common.rs18
3 files changed, 36 insertions, 13 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;
11use embedded_hal::digital::v2::{InputPin, OutputPin}; 11use embedded_hal::digital::v2::{InputPin, OutputPin};
12use example_common::*; 12use example_common::*;
13 13
14#[embassy::main] 14#[embassy::main(config = "config()")]
15async fn main(_spawner: Spawner, p: Peripherals) { 15async 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
92fn 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};
10use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
11use example_common::*; 11use example_common::*;
12 12
13#[embassy::main] 13#[embassy::main(config = "config()")]
14async fn main(_spawner: Spawner, _p: Peripherals) { 14async fn main(_spawner: Spawner, _p: Peripherals) {
15 info!("Hello World!"); 15 info!("Hello World!");
16 16
diff --git a/tests/stm32/src/example_common.rs b/tests/stm32/src/example_common.rs
index 54d633837..11b11d685 100644
--- a/tests/stm32/src/example_common.rs
+++ b/tests/stm32/src/example_common.rs
@@ -1,6 +1,9 @@
1#![macro_use] 1#![macro_use]
2 2
3use defmt_rtt as _; // global logger 3use defmt_rtt as _;
4#[allow(unused)]
5use embassy_stm32::time::Hertz;
6use embassy_stm32::Config;
4use panic_probe as _; 7use panic_probe as _;
5 8
6pub use defmt::*; 9pub use defmt::*;
@@ -15,3 +18,16 @@ defmt::timestamp! {"{=u64}", {
15 n as u64 18 n as u64
16 } 19 }
17} 20}
21
22pub fn config() -> Config {
23 #[allow(unused_mut)]
24 let mut config = Config::default();
25
26 #[cfg(feature = "stm32h755zi")]
27 {
28 config.rcc.sys_ck = Some(Hertz(400_000_000));
29 config.rcc.pll1.q_ck = Some(Hertz(100_000_000));
30 }
31
32 config
33}