@@ -16,21 +16,36 @@ pub const CYCLES_PER_US: u32 = F_SYS.raw() / 1_000_000;
1616use crate :: common:: is_pax_low;
1717use embedded_hal:: delay:: DelayNs ;
1818use 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 } ;
2220
2321#[ embedded_test:: tests]
2422mod 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+ }
2541 #[ test]
2642 fn gpio_push_pull ( ) {
2743 use super :: * ;
2844
2945 let ( gpioa, mut delay) = init ( ) ;
3046
31- let _pa1_important_dont_use_as_output = gpioa. pa1 . into_floating_input ( ) ;
3247 let mut pin = gpioa. pa8 . into_push_pull_output ( ) ;
33- let pin_num = 8 ; // PA8
48+ let pin_num = pin . pin_id ( ) ;
3449
3550 pin. set_high ( ) ;
3651 delay. delay_ms ( 1 ) ; // Give the pin plenty of time to go high
@@ -46,9 +61,9 @@ mod tests {
4661 use super :: * ;
4762
4863 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 ( ) ;
5267
5368 pin. set_high ( ) ;
5469 delay. delay_ms ( 1 ) ; // Give the pin plenty of time to go high
0 commit comments