@@ -16,21 +16,36 @@ pub const CYCLES_PER_US: u32 = F_SYS.raw() / 1_000_000;
16
16
use crate :: common:: is_pax_low;
17
17
use embedded_hal:: delay:: DelayNs ;
18
18
use fugit:: RateExtU32 ;
19
- use stm32h5xx_hal:: {
20
- delay:: Delay , gpio:: GpioExt , pwr:: PwrExt , rcc:: RccExt , stm32:: GPIOA ,
21
- } ;
19
+ use stm32h5xx_hal:: { delay:: Delay , gpio:: GpioExt , pwr:: PwrExt , rcc:: RccExt } ;
22
20
23
21
#[ embedded_test:: tests]
24
22
mod tests {
23
+ use stm32h5xx_hal:: gpio:: { PinExt , Pull } ;
24
+
25
+ #[ test]
26
+ fn gpio_resistors ( ) {
27
+ use super :: * ;
28
+
29
+ let ( gpioa, mut delay) = init ( ) ;
30
+
31
+ let mut pin = gpioa. pa8 . into_pull_down_input ( ) ;
32
+ let pin_num = pin. pin_id ( ) ;
33
+
34
+ delay. delay_ms ( 1 ) ; // Give the pin plenty of time to go low
35
+ assert ! ( is_pax_low( pin_num) ) ;
36
+
37
+ pin. set_internal_resistor ( Pull :: Up ) ;
38
+ delay. delay_ms ( 1 ) ; // Give the pin plenty of time to go high
39
+ assert ! ( !is_pax_low( pin_num) ) ;
40
+ }
25
41
#[ test]
26
42
fn gpio_push_pull ( ) {
27
43
use super :: * ;
28
44
29
45
let ( gpioa, mut delay) = init ( ) ;
30
46
31
- let _pa1_important_dont_use_as_output = gpioa. pa1 . into_floating_input ( ) ;
32
47
let mut pin = gpioa. pa8 . into_push_pull_output ( ) ;
33
- let pin_num = 8 ; // PA8
48
+ let pin_num = pin . pin_id ( ) ;
34
49
35
50
pin. set_high ( ) ;
36
51
delay. delay_ms ( 1 ) ; // Give the pin plenty of time to go high
@@ -46,9 +61,9 @@ mod tests {
46
61
use super :: * ;
47
62
48
63
let ( gpioa, mut delay) = init ( ) ;
49
- let _pa1_important_dont_use_as_output = gpioa . pa1 . into_floating_input ( ) ;
50
- let mut pin = gpioa. pa8 . into_open_drain_output ( ) . internal_pull_up ( on ) ;
51
- let pin_num = 8 ; // PA8
64
+
65
+ let mut pin = gpioa. pa8 . into_open_drain_output ( ) . internal_pull_up ( true ) ;
66
+ let pin_num = pin . pin_id ( ) ;
52
67
53
68
pin. set_high ( ) ;
54
69
delay. delay_ms ( 1 ) ; // Give the pin plenty of time to go high
0 commit comments