From b230ac9c1a2e33da7e2996284ae5dfdc1b832a30 Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Sun, 8 May 2022 14:41:59 -0500 Subject: [PATCH 1/2] stm32/gpio: Add support for `set_speed` for gpio v1 --- embassy-stm32/src/gpio.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 30f90031..d5941c2f 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -511,10 +511,20 @@ pub(crate) mod sealed { self.set_as_analog(); } - #[cfg(gpio_v2)] + #[cfg(any(gpio_v1, gpio_v2))] #[inline] unsafe fn set_speed(&self, speed: Speed) { let pin = self._pin() as usize; + + #[cfg(gpio_v1)] + { + let crlh = if pin < 8 { 0 } else { 1 }; + self.block().cr(crlh).modify(|w| { + w.set_mode(pin % 8, speed.into()); + }); + } + + #[cfg(gpio_v2)] self.block() .ospeedr() .modify(|w| w.set_ospeedr(pin, speed.into())); From acc176163730ef197ec7b030018bc63b6dd14720 Mon Sep 17 00:00:00 2001 From: Grant Miller Date: Sun, 8 May 2022 14:50:15 -0500 Subject: [PATCH 2/2] Remove unnecessary cfg --- embassy-stm32/src/gpio.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index d5941c2f..b6982e91 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -511,7 +511,6 @@ pub(crate) mod sealed { self.set_as_analog(); } - #[cfg(any(gpio_v1, gpio_v2))] #[inline] unsafe fn set_speed(&self, speed: Speed) { let pin = self._pin() as usize;