Skip to content

Commit b58d509

Browse files
committed
Allow GPIO block splitting without reset.
Adds method `split_without_reset` to split a GPIO block without resetting it via the RCC register.
1 parent c993283 commit b58d509

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/gpio.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,13 @@ pub trait GpioExt {
119119
/// The to split the GPIO into
120120
type Parts;
121121

122-
/// Splits the GPIO block into independent pins and registers
122+
/// Splits the GPIO block into independent pins and registers.
123+
///
124+
/// This resets the state of the GPIO block.
123125
fn split(self) -> Self::Parts;
126+
127+
/// Splits the GPIO block into independent pins and registers without resetting its state.
128+
fn split_without_reset(self) -> Self::Parts;
124129
}
125130

126131
/// Marker trait for active states.
@@ -391,6 +396,19 @@ macro_rules! gpio {
391396
)+
392397
}
393398
}
399+
400+
fn split_without_reset(self) -> Parts {
401+
let rcc = unsafe { &(*RCC::ptr()) };
402+
$GPIOX::enable(rcc);
403+
404+
Parts {
405+
crl: Cr::<$port_id, false>(()),
406+
crh: Cr::<$port_id, true>(()),
407+
$(
408+
$pxi: $PXi::new(),
409+
)+
410+
}
411+
}
394412
}
395413

396414
impl<MODE> PartiallyErasedPin<$port_id, MODE> {

0 commit comments

Comments
 (0)