Merge pull request #2996 from joelsa/fix-gpiov1
gpiov1: Do not call set_speed for AFType::Input
This commit is contained in:
		
						commit
						891ec5fa5d
					
				@ -661,6 +661,11 @@ pub(crate) trait SealedPin {
 | 
				
			|||||||
        self.set_as_analog();
 | 
					        self.set_as_analog();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /// Sets the speed of the output pin.
 | 
				
			||||||
 | 
					    ///
 | 
				
			||||||
 | 
					    /// This should never be called for AFType::Input on the STM32F1 series, since MODE and
 | 
				
			||||||
 | 
					    /// CNF bits are not independent. If the CNF bits are altered afterwards as well, this
 | 
				
			||||||
 | 
					    /// will put the pin into output mode.
 | 
				
			||||||
    #[inline]
 | 
					    #[inline]
 | 
				
			||||||
    fn set_speed(&self, speed: Speed) {
 | 
					    fn set_speed(&self, speed: Speed) {
 | 
				
			||||||
        let pin = self._pin() as usize;
 | 
					        let pin = self._pin() as usize;
 | 
				
			||||||
 | 
				
			|||||||
@ -106,7 +106,14 @@ macro_rules! new_pin {
 | 
				
			|||||||
    ($name:ident, $aftype:expr, $speed:expr, $pull:expr) => {{
 | 
					    ($name:ident, $aftype:expr, $speed:expr, $pull:expr) => {{
 | 
				
			||||||
        let pin = $name.into_ref();
 | 
					        let pin = $name.into_ref();
 | 
				
			||||||
        pin.set_as_af_pull(pin.af_num(), $aftype, $pull);
 | 
					        pin.set_as_af_pull(pin.af_num(), $aftype, $pull);
 | 
				
			||||||
 | 
					        // Do not call set_speed on AFType::Input, as MODE and CNF bits are not independent
 | 
				
			||||||
 | 
					        // for gpio_v1
 | 
				
			||||||
 | 
					        match $aftype {
 | 
				
			||||||
 | 
					            crate::gpio::AFType::Input => {}
 | 
				
			||||||
 | 
					            _ => {
 | 
				
			||||||
                pin.set_speed($speed);
 | 
					                pin.set_speed($speed);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
        Some(pin.map_into())
 | 
					        Some(pin.map_into())
 | 
				
			||||||
    }};
 | 
					    }};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user