File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ no_std]
2
+ #![ no_main]
3
+
4
+ use defmt_rtt as _;
5
+ use panic_probe as _;
6
+
7
+ use stm32f3xx_hal as hal;
8
+
9
+ use hal:: gpio:: { Input , PXx } ;
10
+
11
+ struct State {
12
+ input_ground : PXx < Input > ,
13
+ input_vdd : PXx < Input > ,
14
+ }
15
+
16
+ #[ defmt_test:: tests]
17
+ mod tests {
18
+ use defmt:: { assert, unwrap} ;
19
+ use stm32f3xx_hal:: { pac, prelude:: * } ;
20
+
21
+ // Test the defaults with no configuration
22
+ #[ init]
23
+ fn init ( ) -> super :: State {
24
+ let dp = unwrap ! ( pac:: Peripherals :: take( ) ) ;
25
+
26
+ let mut rcc = dp. RCC . constrain ( ) ;
27
+ let mut gpioc = dp. GPIOC . split ( & mut rcc. ahb ) ;
28
+ let input_ground = gpioc
29
+ . pc3
30
+ . into_floating_input ( & mut gpioc. moder , & mut gpioc. pupdr )
31
+ . downgrade ( )
32
+ . downgrade ( ) ;
33
+ let input_vdd = gpioc
34
+ . pc2
35
+ . into_floating_input ( & mut gpioc. moder , & mut gpioc. pupdr )
36
+ . downgrade ( )
37
+ . downgrade ( ) ;
38
+
39
+ super :: State {
40
+ input_ground,
41
+ input_vdd,
42
+ }
43
+ }
44
+
45
+ #[ test]
46
+ fn ground_is_low ( state : & mut super :: State ) {
47
+ assert ! ( unwrap!( state. input_ground. is_low( ) ) ) ;
48
+ }
49
+
50
+ #[ test]
51
+ fn vdd_is_high ( state : & mut super :: State ) {
52
+ assert ! ( unwrap!( state. input_vdd. is_high( ) ) ) ;
53
+ }
54
+ }
You can’t perform that action at this time.
0 commit comments