aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-01-14 22:02:00 +0100
committerDario Nieuwenhuis <[email protected]>2022-01-19 17:59:55 +0100
commit58fc64722c65bbdc209ae0fd1700f03702bbcd08 (patch)
tree77f9412b47259cd4cf4170b0a257b371398d4f2c /tests
parent52e156b429417bde59d0ea67d11256866f1dcec9 (diff)
stm32/gpio: expose all functionality as inherent methods.
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/src/bin/gpio.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs
index 51ede6cea..305da8d12 100644
--- a/tests/stm32/src/bin/gpio.rs
+++ b/tests/stm32/src/bin/gpio.rs
@@ -8,7 +8,6 @@ use defmt::assert;
8use embassy::executor::Spawner; 8use embassy::executor::Spawner;
9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 9use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
10use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
11use embedded_hal::digital::v2::{InputPin, OutputPin};
12use example_common::*; 11use example_common::*;
13 12
14#[embassy::main(config = "config()")] 13#[embassy::main(config = "config()")]
@@ -35,12 +34,12 @@ async fn main(_spawner: Spawner, p: Peripherals) {
35 { 34 {
36 let _a = Output::new(&mut a, Level::Low, Speed::Low); 35 let _a = Output::new(&mut a, Level::Low, Speed::Low);
37 delay(); 36 delay();
38 assert!(b.is_low().unwrap()); 37 assert!(b.is_low());
39 } 38 }
40 { 39 {
41 let _a = Output::new(&mut a, Level::High, Speed::Low); 40 let _a = Output::new(&mut a, Level::High, Speed::Low);
42 delay(); 41 delay();
43 assert!(b.is_high().unwrap()); 42 assert!(b.is_high());
44 } 43 }
45 } 44 }
46 45
@@ -51,38 +50,38 @@ async fn main(_spawner: Spawner, p: Peripherals) {
51 50
52 let mut a = Output::new(&mut a, Level::Low, Speed::Low); 51 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
53 delay(); 52 delay();
54 assert!(b.is_low().unwrap()); 53 assert!(b.is_low());
55 a.set_high().unwrap(); 54 a.set_high();
56 delay(); 55 delay();
57 assert!(b.is_high().unwrap()); 56 assert!(b.is_high());
58 } 57 }
59 58
60 // Test input pulldown 59 // Test input pulldown
61 { 60 {
62 let b = Input::new(&mut b, Pull::Down); 61 let b = Input::new(&mut b, Pull::Down);
63 delay(); 62 delay();
64 assert!(b.is_low().unwrap()); 63 assert!(b.is_low());
65 64
66 let mut a = Output::new(&mut a, Level::Low, Speed::Low); 65 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
67 delay(); 66 delay();
68 assert!(b.is_low().unwrap()); 67 assert!(b.is_low());
69 a.set_high().unwrap(); 68 a.set_high();
70 delay(); 69 delay();
71 assert!(b.is_high().unwrap()); 70 assert!(b.is_high());
72 } 71 }
73 72
74 // Test input pullup 73 // Test input pullup
75 { 74 {
76 let b = Input::new(&mut b, Pull::Up); 75 let b = Input::new(&mut b, Pull::Up);
77 delay(); 76 delay();
78 assert!(b.is_high().unwrap()); 77 assert!(b.is_high());
79 78
80 let mut a = Output::new(&mut a, Level::Low, Speed::Low); 79 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
81 delay(); 80 delay();
82 assert!(b.is_low().unwrap()); 81 assert!(b.is_low());
83 a.set_high().unwrap(); 82 a.set_high();
84 delay(); 83 delay();
85 assert!(b.is_high().unwrap()); 84 assert!(b.is_high());
86 } 85 }
87 86
88 info!("Test OK"); 87 info!("Test OK");