Skip to content

Commit 2e7e5c1

Browse files
authored
Enable *and* reset gpio in split method (#182)
Rcc enable *and* reset gpio in split method. Calling `reset` as well ensures that enough time has passed between `enable` and the first register access to the peripheral. Failing to do this might lead to very hard to debug issues, see #180.
1 parent 116e6d6 commit 2e7e5c1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/gpio.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! General Purpose Input / Output
22
use core::marker::PhantomData;
33

4-
use crate::rcc::Rcc;
4+
use crate::rcc::{Enable, Rcc, Reset};
55
use crate::stm32::EXTI;
66
use crate::syscfg::SysCfg;
77

@@ -257,7 +257,9 @@ macro_rules! gpio {
257257
type Parts = Parts;
258258

259259
fn split(self, rcc: &mut Rcc) -> Parts {
260-
rcc.rb.ahb2enr.modify(|_, w| w.$iopxenr().set_bit());
260+
$GPIOX::enable(&rcc.rb);
261+
$GPIOX::reset(&rcc.rb);
262+
261263
Parts {
262264
$(
263265
$pxi: $PXi { _mode: PhantomData },

0 commit comments

Comments
 (0)