diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-05-24 13:12:37 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-24 13:12:37 +0000 |
| commit | 891ec5fa5da384cc7c8ffe48ef2df0bbfca769a3 (patch) | |
| tree | 5e1a607ec7725cfabbe72533d4d6b883e3b72221 /embassy-stm32 | |
| parent | b48cf5357c16063a7ac19998977b2d45d7bee54f (diff) | |
| parent | e1d2ba07a79561cf18b30e905a28d0ff0744cb58 (diff) | |
Merge pull request #2996 from joelsa/fix-gpiov1
gpiov1: Do not call set_speed for AFType::Input
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 5 | ||||
| -rw-r--r-- | embassy-stm32/src/macros.rs | 9 |
2 files changed, 13 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..dcd25cbe9 100644 --- a/embassy-stm32/src/macros.rs +++ b/embassy-stm32/src/macros.rs | |||
| @@ -106,7 +106,14 @@ 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 | match $aftype { | ||
| 112 | crate::gpio::AFType::Input => {} | ||
| 113 | _ => { | ||
| 114 | pin.set_speed($speed); | ||
| 115 | } | ||
| 116 | }; | ||
| 110 | Some(pin.map_into()) | 117 | Some(pin.map_into()) |
| 111 | }}; | 118 | }}; |
| 112 | } | 119 | } |
