From c44bed300b17ef0cb0004758fd085b150533252f Mon Sep 17 00:00:00 2001 From: Tobias Pisani Date: Sat, 9 Oct 2021 22:03:22 +0200 Subject: [PATCH] Correctly set alternate function for stm32f1 gpios --- embassy-stm32/src/gpio.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 5c48b5be..7c331fbb 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -407,11 +407,17 @@ pub(crate) mod sealed { match af_type { // TODO: Do we need to configure input AF pins differently? AFType::OutputPushPull => { - r.cr(crlh).modify(|w| w.set_cnf(n % 8, vals::Cnf::PUSHPULL)); + r.cr(crlh).modify(|w| { + w.set_mode(n % 8, vals::Mode::OUTPUT50); + w.set_cnf(n % 8, vals::Cnf::ALTPUSHPULL); + }); + } + AFType::OutputOpenDrain => { + r.cr(crlh).modify(|w| { + w.set_mode(n % 8, vals::Mode::OUTPUT50); + w.set_cnf(n % 8, vals::Cnf::ALTOPENDRAIN); + }); } - AFType::OutputOpenDrain => r - .cr(crlh) - .modify(|w| w.set_cnf(n % 8, vals::Cnf::OPENDRAIN)), } } #[cfg(gpio_v2)]