aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author[email protected] <[email protected]>2022-07-08 21:59:09 +0200
committer[email protected] <[email protected]>2022-07-08 21:59:09 +0200
commitf911ad25c3cb1155dc47cf9bd7de31628562c6a9 (patch)
tree7f90b7a75651120bbbab391c5967d996b3471c74 /tests
parent39702d76242797106f77b3af56f3aed946e237b0 (diff)
Flex/ Test initial output test done
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/src/bin/gpio.rs92
1 files changed, 91 insertions, 1 deletions
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs
index c7991953f..2692f25fc 100644
--- a/tests/stm32/src/bin/gpio.rs
+++ b/tests/stm32/src/bin/gpio.rs
@@ -6,7 +6,7 @@
6mod example_common; 6mod example_common;
7use defmt::assert; 7use 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, OutputOpenDrain, Flex, Pull, Speed};
10use embassy_stm32::Peripherals; 10use embassy_stm32::Peripherals;
11use example_common::*; 11use example_common::*;
12 12
@@ -88,6 +88,96 @@ async fn main(_spawner: Spawner, p: Peripherals) {
88 assert!(b.is_high()); 88 assert!(b.is_high());
89 } 89 }
90 90
91 // Test output open drain
92 {
93 let b = Input::new(&mut b, Pull::Down);
94 // no pull, the status is undefined
95
96 let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None);
97 delay();
98 assert!(b.is_low());
99 a.set_high(); // High-Z output
100 delay();
101 assert!(b.is_low());
102 }
103
104 // FLEX
105 // Test initial output
106 {
107 let mut b = Flex::new(&mut b);
108 b.set_as_input(Pull::None);
109
110 {
111 let mut a = Flex::new(&mut a);
112 a.set_low();
113 a.set_as_output(Speed::Low);
114 delay();
115 assert!(b.is_low());
116 }
117 {
118 let mut a = Flex::new(&mut a);
119 a.set_as_output(Speed::Low);
120 a.set_high();
121 delay();
122 assert!(b.is_high());
123 }
124 }
125 /*
126 // Test input no pull
127 {
128 let b = Input::new(&mut b, Pull::None);
129 // no pull, the status is undefined
130
131 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
132 delay();
133 assert!(b.is_low());
134 a.set_high();
135 delay();
136 assert!(b.is_high());
137 }
138
139 // Test input pulldown
140 {
141 let b = Input::new(&mut b, Pull::Down);
142 delay();
143 assert!(b.is_low());
144
145 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
146 delay();
147 assert!(b.is_low());
148 a.set_high();
149 delay();
150 assert!(b.is_high());
151 }
152
153 // Test input pullup
154 {
155 let b = Input::new(&mut b, Pull::Up);
156 delay();
157 assert!(b.is_high());
158
159 let mut a = Output::new(&mut a, Level::Low, Speed::Low);
160 delay();
161 assert!(b.is_low());
162 a.set_high();
163 delay();
164 assert!(b.is_high());
165 }
166
167 // Test output open drain
168 {
169 let b = Input::new(&mut b, Pull::Down);
170 // no pull, the status is undefined
171
172 let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None);
173 delay();
174 assert!(b.is_low());
175 a.set_high(); // High-Z output
176 delay();
177 assert!(b.is_low());
178 }
179*/
180
91 info!("Test OK"); 181 info!("Test OK");
92 cortex_m::asm::bkpt(); 182 cortex_m::asm::bkpt();
93} 183}