stm32: move MCO pin impls to build.rs

This commit is contained in:
Dario Nieuwenhuis 2022-02-23 19:54:26 +01:00
parent 1e69a8c484
commit 30ce71127a
2 changed files with 13 additions and 10 deletions

View File

@ -251,6 +251,8 @@ fn main() {
(("spi", "MISO"), (quote!(crate::spi::MisoPin), quote!())),
(("i2c", "SDA"), (quote!(crate::i2c::SdaPin), quote!())),
(("i2c", "SCL"), (quote!(crate::i2c::SclPin), quote!())),
(("rcc", "MCO_1"), (quote!(crate::rcc::McoPin), quote!())),
(("rcc", "MCO_2"), (quote!(crate::rcc::McoPin), quote!())),
(("dcmi", "D0"), (quote!(crate::dcmi::D0Pin), quote!())),
(("dcmi", "D1"), (quote!(crate::dcmi::D1Pin), quote!())),
(("dcmi", "D2"), (quote!(crate::dcmi::D2Pin), quote!())),
@ -427,10 +429,20 @@ fn main() {
for pin in p.pins {
let key = (regs.kind, pin.signal);
if let Some((tr, cfgs)) = signals.get(&key) {
let peri = format_ident!("{}", p.name);
let mut peri = format_ident!("{}", p.name);
let pin_name = format_ident!("{}", pin.pin);
let af = pin.af.unwrap_or(0);
// MCO is special
if pin.signal.starts_with("MCO_") {
// Supported in H7 only for now
if regs.version == "h7" {
peri = format_ident!("{}", pin.signal.replace("_", ""));
} else {
continue;
}
}
g.extend(quote! {
#cfgs
pin_trait_impl!(#tr, #peri, #pin_name, #af);

View File

@ -348,15 +348,6 @@ macro_rules! impl_peri {
impl_peri!(MCO1, Mco1, set_mco1, set_mco1pre);
impl_peri!(MCO2, Mco2, set_mco2, set_mco2pre);
crate::pac::peripheral_pins!(
($inst:ident, rcc, RCC, $pin:ident, MCO_1, $af:expr) => {
pin_trait_impl!(crate::rcc::McoPin, MCO1, $pin, $af);
};
($inst:ident, rcc, RCC, $pin:ident, MCO_2, $af:expr) => {
pin_trait_impl!(crate::rcc::McoPin, MCO2, $pin, $af);
};
);
pub struct Mco<'d, T: McoInstance> {
phantom: PhantomData<&'d mut T>,
}