Skip to content

Commit a4d8df6

Browse files
committed
move IntoAf to markers
1 parent d0d7dd7 commit a4d8df6

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

codegen/src/codegen/gpio.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ fn merge_pins_by_port(pins: &[gpio::Pin]) -> Result<Vec<Port>> {
4949

5050
let mut ports = Vec::new();
5151
for (id, mut pins) in pins_by_port {
52+
pins.retain(|p| {
53+
p.name != "PDR_ON" && p.name != "PC14OSC32_IN" && p.name != "PC15OSC32_OUT"
54+
});
5255
pins.sort_by_key(|p| p.number().unwrap_or_default());
5356
pins.dedup_by_key(|p| p.number().unwrap_or_default());
5457
ports.push(Port { id, pins });

src/gpio.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ mod marker {
168168
pub trait Active {}
169169
/// Marker trait for all pin modes except alternate
170170
pub trait NotAlt {}
171+
/// Marker trait for pins with alternate function `A` mapping
172+
pub trait IntoAf<const A: u8>: super::HL {}
171173
}
172174

173175
impl marker::Readable for Input {}
@@ -230,9 +232,6 @@ pub trait HL {
230232
type Afr;
231233
}
232234

233-
/// Marker trait for pins with alternate function `A` mapping
234-
pub trait IntoAf<const A: u8>: HL {}
235-
236235
macro_rules! cr {
237236
($high:literal: [$($i:literal),+]) => {
238237
$(
@@ -609,7 +608,7 @@ macro_rules! gpio {
609608
pub mod $gpiox {
610609
use crate::pac::$GPIOX;
611610
use crate::rcc::{Enable, Reset, AHB};
612-
use super::{Afr, Input, MODER, OTYPER, OSPEEDR, PUPDR, IntoAf};
611+
use super::{Afr, MODER, OTYPER, OSPEEDR, PUPDR};
613612

614613
/// GPIO parts
615614
pub struct Parts {
@@ -660,10 +659,10 @@ macro_rules! gpio {
660659
$(
661660
#[doc=stringify!($PXi)]
662661
#[doc=" pin"]
663-
pub type $PXi<MODE = Input> = super::Pin<$port_id, $i, MODE>;
662+
pub type $PXi<MODE = super::Input> = super::Pin<$port_id, $i, MODE>;
664663

665664
$(
666-
impl<MODE> IntoAf<$A> for $PXi<MODE> { }
665+
impl<MODE> super::marker::IntoAf<$A> for $PXi<MODE> { }
667666
)*
668667
)+
669668

@@ -1197,7 +1196,7 @@ impl<const P: char> Gpio<P> {
11971196
'G' => crate::pac::GPIOG::ptr() as _,
11981197
#[cfg(feature = "gpio-f303e")]
11991198
'H' => crate::pac::GPIOH::ptr() as _,
1200-
_ => crate::pac::GPIOA::ptr(),
1199+
_ => panic!("Unknown GPIO port"),
12011200
}
12021201
}
12031202
}

src/gpio/convert.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl<const P: char, const N: u8, MODE: PinMode> Pin<P, N, MODE> {
99
_afr: &mut <Self as HL>::Afr,
1010
) -> Pin<P, N, Alternate<A, PushPull>>
1111
where
12-
Self: IntoAf<A>,
12+
Self: super::marker::IntoAf<A>,
1313
{
1414
self.into_mode()
1515
}
@@ -22,7 +22,7 @@ impl<const P: char, const N: u8, MODE: PinMode> Pin<P, N, MODE> {
2222
_afr: &mut <Self as HL>::Afr,
2323
) -> Pin<P, N, Alternate<A, OpenDrain>>
2424
where
25-
Self: IntoAf<A>,
25+
Self: super::marker::IntoAf<A>,
2626
{
2727
self.into_mode()
2828
}

0 commit comments

Comments
 (0)