diff options
| author | Joël Schulz-Andres <[email protected]> | 2024-05-24 13:46:55 +0200 |
|---|---|---|
| committer | Joël Schulz-Andres <[email protected]> | 2024-05-24 13:46:55 +0200 |
| commit | bfc5929f50c766a88c3c5120aa3210d3f1f21f5c (patch) | |
| tree | 7299ac8eb0bd553af94a3f7d7126de8bfc4e54a6 | |
| parent | 8226904b34d263f3b0ab56284d18c2153677675b (diff) | |
gpiov1: Do not call set_speed for AFType::Input
Co-authored-by: Toby Fleming <[email protected]>
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/macros.rs | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 214813a42..81cb09b24 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -661,6 +661,11 @@ pub(crate) trait SealedPin { | |||
| 661 | self.set_as_analog(); | 661 | self.set_as_analog(); |
| 662 | } | 662 | } |
| 663 | 663 | ||
| 664 | /// Sets the speed of the output pin. | ||
| 665 | /// | ||
| 666 | /// This should never be called for AFType::Input on the STM32F1 series, since MODE and | ||
| 667 | /// CNF bits are not independent. If the CNF bits are altered afterwards as well, this | ||
| 668 | /// will put the pin into output mode. | ||
| 664 | #[inline] | 669 | #[inline] |
| 665 | fn set_speed(&self, speed: Speed) { | 670 | fn set_speed(&self, speed: Speed) { |
| 666 | let pin = self._pin() as usize; | 671 | let pin = self._pin() as usize; |
diff --git a/embassy-stm32/src/macros.rs b/embassy-stm32/src/macros.rs index 7f8076043..8166dff6a 100644 --- a/embassy-stm32/src/macros.rs +++ b/embassy-stm32/src/macros.rs | |||
| @@ -106,7 +106,11 @@ macro_rules! new_pin { | |||
| 106 | ($name:ident, $aftype:expr, $speed:expr, $pull:expr) => {{ | 106 | ($name:ident, $aftype:expr, $speed:expr, $pull:expr) => {{ |
| 107 | let pin = $name.into_ref(); | 107 | let pin = $name.into_ref(); |
| 108 | pin.set_as_af_pull(pin.af_num(), $aftype, $pull); | 108 | pin.set_as_af_pull(pin.af_num(), $aftype, $pull); |
| 109 | pin.set_speed($speed); | 109 | // Do not call set_speed on AFType::Input, as MODE and CNF bits are not independent |
| 110 | // for gpio_v1 | ||
| 111 | if $aftype != crate::gpio::low_level::AFType::Input { | ||
| 112 | pin.set_speed($speed); | ||
| 113 | } | ||
| 110 | Some(pin.map_into()) | 114 | Some(pin.map_into()) |
| 111 | }}; | 115 | }}; |
| 112 | } | 116 | } |
