File tree Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ name = "serial"
25
25
harness = false
26
26
27
27
[dev-dependencies ]
28
+ cortex-m = " 0.7.0"
28
29
defmt = " 0.1.3"
29
30
defmt-rtt = " 0.1.0"
30
31
defmt-test = " 0.1.1"
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ struct State {
19
19
20
20
#[ defmt_test:: tests]
21
21
mod tests {
22
+ use cortex_m:: asm;
22
23
use defmt:: { assert, unwrap} ;
23
24
use nrf52840_hal:: { gpio:: p0, pac, prelude:: * } ;
24
25
@@ -53,6 +54,8 @@ mod tests {
53
54
let pull_pin = unwrap ! ( state. pull_pin. take( ) ) ;
54
55
55
56
let pullup_pin = pull_pin. into_pullup_input ( ) ;
57
+ // GPIO re-configuration is not instantaneous so a delay is needed
58
+ asm:: delay ( 100 ) ;
56
59
assert ! ( state. input_pin. is_high( ) . unwrap( ) ) ;
57
60
58
61
state. pull_pin = Some ( pullup_pin. into_floating_input ( ) ) ;
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ struct State {
19
19
20
20
#[ defmt_test:: tests]
21
21
mod tests {
22
+ use cortex_m:: asm;
22
23
use defmt:: { assert, unwrap} ;
23
24
use nrf52840_hal:: {
24
25
gpio:: { p0, Level } ,
@@ -45,12 +46,16 @@ mod tests {
45
46
#[ test]
46
47
fn set_low_is_low ( state : & mut State ) {
47
48
state. output_pin . set_low ( ) . unwrap ( ) ;
49
+ // GPIO operations are not instantaneous so a delay is needed
50
+ asm:: delay ( 100 ) ;
48
51
assert ! ( state. input_pin. is_low( ) . unwrap( ) ) ;
49
52
}
50
53
51
54
#[ test]
52
55
fn set_high_is_high ( state : & mut State ) {
53
56
state. output_pin . set_high ( ) . unwrap ( ) ;
57
+ // GPIO operations are not instantaneous so a delay is needed
58
+ asm:: delay ( 100 ) ;
54
59
assert ! ( state. input_pin. is_high( ) . unwrap( ) ) ;
55
60
}
56
61
}
You can’t perform that action at this time.
0 commit comments