Move NoPin impls from v1 to mod

This commit is contained in:
Grant Miller 2021-12-06 14:02:21 -06:00
parent 8b4a247af2
commit d426caefbf
2 changed files with 22 additions and 22 deletions

View File

@ -8,7 +8,7 @@ mod _version;
use crate::{dma, peripherals, rcc::RccPeripheral}; use crate::{dma, peripherals, rcc::RccPeripheral};
pub use _version::*; pub use _version::*;
use crate::gpio::OptionalPin; use crate::gpio::{NoPin, OptionalPin};
#[derive(Debug)] #[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))] #[cfg_attr(feature = "defmt", derive(defmt::Format))]
@ -135,6 +135,26 @@ crate::pac::peripheral_pins!(
}; };
); );
macro_rules! impl_nopin {
($inst:ident, $signal:ident) => {
impl $signal<peripherals::$inst> for NoPin {}
impl sealed::$signal<peripherals::$inst> for NoPin {
fn af_num(&self) -> u8 {
0
}
}
};
}
crate::pac::peripherals!(
(spi, $inst:ident) => {
impl_nopin!($inst, SckPin);
impl_nopin!($inst, MosiPin);
impl_nopin!($inst, MisoPin);
};
);
macro_rules! impl_dma { macro_rules! impl_dma {
($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => { ($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => {
impl<T> sealed::$signal<peripherals::$inst> for T impl<T> sealed::$signal<peripherals::$inst> for T

View File

@ -3,9 +3,8 @@
use crate::dma::NoDma; use crate::dma::NoDma;
use crate::gpio::sealed::AFType; use crate::gpio::sealed::AFType;
use crate::gpio::sealed::Pin; use crate::gpio::sealed::Pin;
use crate::gpio::{AnyPin, NoPin}; use crate::gpio::AnyPin;
use crate::pac::spi; use crate::pac::spi;
use crate::peripherals;
use crate::spi::{ use crate::spi::{
ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel, ByteOrder, Config, Error, Instance, MisoPin, MosiPin, RxDmaChannel, SckPin, TxDmaChannel,
WordSize, WordSize,
@ -30,25 +29,6 @@ impl WordSize {
} }
} }
macro_rules! impl_nopin {
($inst:ident, $signal:ident) => {
impl $signal<peripherals::$inst> for NoPin {}
impl super::sealed::$signal<peripherals::$inst> for NoPin {
fn af_num(&self) -> u8 {
0
}
}
};
}
crate::pac::peripherals!(
(spi, $inst:ident) => {
impl_nopin!($inst, SckPin);
impl_nopin!($inst, MosiPin);
impl_nopin!($inst, MisoPin);
};
);
pub struct Spi<'d, T: Instance, Tx, Rx> { pub struct Spi<'d, T: Instance, Tx, Rx> {
sck: Option<AnyPin>, sck: Option<AnyPin>,
mosi: Option<AnyPin>, mosi: Option<AnyPin>,