From 3fe91979c9bc08920f3f8398a7c250cf384c385d Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Thu, 30 Jan 2025 21:29:37 +0100 Subject: [PATCH 1/3] Enable *and* reset gpio in split method --- src/gpio.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gpio.rs b/src/gpio.rs index f0ae9845..ecbb149c 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -1,7 +1,7 @@ //! General Purpose Input / Output use core::marker::PhantomData; -use crate::rcc::Rcc; +use crate::rcc::{Enable, Rcc, Reset}; use crate::stm32::EXTI; use crate::syscfg::SysCfg; @@ -14,7 +14,7 @@ pub trait GpioExt { type Parts; /// Splits the GPIO block into independent pins and registers - fn split(self, rcc: &mut Rcc) -> Self::Parts; + fn split(self, rcc: &Rcc) -> Self::Parts; } /// Input mode (type state) @@ -256,8 +256,10 @@ macro_rules! gpio { impl GpioExt for $GPIOX { type Parts = Parts; - fn split(self, rcc: &mut Rcc) -> Parts { - rcc.rb.ahb2enr.modify(|_, w| w.$iopxenr().set_bit()); + fn split(self, rcc: &Rcc) -> Parts { + $GPIOX::enable(&rcc.rb); + $GPIOX::reset(&rcc.rb); + Parts { $( $pxi: $PXi { _mode: PhantomData }, From 72a956bfb957d9a3af0deeb1ef9a36df99a5b689 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Thu, 30 Jan 2025 23:02:29 +0100 Subject: [PATCH 2/3] fmt --- src/gpio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gpio.rs b/src/gpio.rs index ecbb149c..8ff544fc 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -259,7 +259,7 @@ macro_rules! gpio { fn split(self, rcc: &Rcc) -> Parts { $GPIOX::enable(&rcc.rb); $GPIOX::reset(&rcc.rb); - + Parts { $( $pxi: $PXi { _mode: PhantomData }, From b40ad2ff392292f38a325a98ea98e5bdb80cfff8 Mon Sep 17 00:00:00 2001 From: Albin Hedman Date: Thu, 13 Feb 2025 19:57:49 +0100 Subject: [PATCH 3/3] Undo exclusive to shared rcc ref in gpio split --- src/gpio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gpio.rs b/src/gpio.rs index 8ff544fc..c112d0e5 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -14,7 +14,7 @@ pub trait GpioExt { type Parts; /// Splits the GPIO block into independent pins and registers - fn split(self, rcc: &Rcc) -> Self::Parts; + fn split(self, rcc: &mut Rcc) -> Self::Parts; } /// Input mode (type state) @@ -256,7 +256,7 @@ macro_rules! gpio { impl GpioExt for $GPIOX { type Parts = Parts; - fn split(self, rcc: &Rcc) -> Parts { + fn split(self, rcc: &mut Rcc) -> Parts { $GPIOX::enable(&rcc.rb); $GPIOX::reset(&rcc.rb);