From 35f4ae378cbc9a1263e46baaeac536cae2337896 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 5 Sep 2025 23:44:25 +0200 Subject: stm32/afio: make the A generic param only appear in chips with AFIO. --- embassy-stm32/src/can/bxcan/mod.rs | 6 +- embassy-stm32/src/eth/v1/mod.rs | 50 ++++++------- embassy-stm32/src/eth/v2/mod.rs | 50 ++++++------- embassy-stm32/src/gpio.rs | 1 + embassy-stm32/src/i2c/mod.rs | 12 ++-- embassy-stm32/src/i2s.rs | 46 ++++++------ embassy-stm32/src/macros.rs | 54 +++++++++++++- embassy-stm32/src/spi/mod.rs | 48 ++++++------- embassy-stm32/src/timer/complementary_pwm.rs | 26 +++---- embassy-stm32/src/timer/input_capture.rs | 18 ++--- embassy-stm32/src/timer/one_pulse.rs | 4 +- embassy-stm32/src/timer/pwm_input.rs | 14 +++- embassy-stm32/src/timer/qei.rs | 14 ++-- embassy-stm32/src/timer/simple_pwm.rs | 22 +++--- embassy-stm32/src/usart/buffered.rs | 48 ++++++------- embassy-stm32/src/usart/mod.rs | 104 +++++++++++++-------------- 16 files changed, 291 insertions(+), 226 deletions(-) diff --git a/embassy-stm32/src/can/bxcan/mod.rs b/embassy-stm32/src/can/bxcan/mod.rs index 9ebfeb42f..663b34501 100644 --- a/embassy-stm32/src/can/bxcan/mod.rs +++ b/embassy-stm32/src/can/bxcan/mod.rs @@ -181,10 +181,10 @@ pub enum TryWriteError { impl<'d> Can<'d> { /// Creates a new Bxcan instance, keeping the peripheral in sleep mode. /// You must call [Can::enable_non_blocking] to use the peripheral. - pub fn new( + pub fn new( _peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, _irqs: impl interrupt::typelevel::Binding> + interrupt::typelevel::Binding> + interrupt::typelevel::Binding> diff --git a/embassy-stm32/src/eth/v1/mod.rs b/embassy-stm32/src/eth/v1/mod.rs index 45be65c5f..2ae451902 100644 --- a/embassy-stm32/src/eth/v1/mod.rs +++ b/embassy-stm32/src/eth/v1/mod.rs @@ -99,19 +99,19 @@ macro_rules! config_pins { impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { /// safety: the returned instance is not leak-safe - pub fn new( + pub fn new( queue: &'d mut PacketQueue, peri: Peri<'d, T>, irq: impl interrupt::typelevel::Binding + 'd, - ref_clk: Peri<'d, impl RefClkPin>, - mdio: Peri<'d, impl MDIOPin>, - mdc: Peri<'d, impl MDCPin>, - crs: Peri<'d, impl CRSPin>, - rx_d0: Peri<'d, impl RXD0Pin>, - rx_d1: Peri<'d, impl RXD1Pin>, - tx_d0: Peri<'d, impl TXD0Pin>, - tx_d1: Peri<'d, impl TXD1Pin>, - tx_en: Peri<'d, impl TXEnPin>, + ref_clk: Peri<'d, if_afio!(impl RefClkPin)>, + mdio: Peri<'d, if_afio!(impl MDIOPin)>, + mdc: Peri<'d, if_afio!(impl MDCPin)>, + crs: Peri<'d, if_afio!(impl CRSPin)>, + rx_d0: Peri<'d, if_afio!(impl RXD0Pin)>, + rx_d1: Peri<'d, if_afio!(impl RXD1Pin)>, + tx_d0: Peri<'d, if_afio!(impl TXD0Pin)>, + tx_d1: Peri<'d, if_afio!(impl TXD1Pin)>, + tx_en: Peri<'d, if_afio!(impl TXEnPin)>, phy: P, mac_addr: [u8; 6], ) -> Self { @@ -291,24 +291,24 @@ impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { } /// Create a new MII ethernet driver using 14 pins. - pub fn new_mii( + pub fn new_mii( queue: &'d mut PacketQueue, peri: Peri<'d, T>, irq: impl interrupt::typelevel::Binding + 'd, - rx_clk: Peri<'d, impl RXClkPin>, - tx_clk: Peri<'d, impl TXClkPin>, - mdio: Peri<'d, impl MDIOPin>, - mdc: Peri<'d, impl MDCPin>, - rxdv: Peri<'d, impl RXDVPin>, - rx_d0: Peri<'d, impl RXD0Pin>, - rx_d1: Peri<'d, impl RXD1Pin>, - rx_d2: Peri<'d, impl RXD2Pin>, - rx_d3: Peri<'d, impl RXD3Pin>, - tx_d0: Peri<'d, impl TXD0Pin>, - tx_d1: Peri<'d, impl TXD1Pin>, - tx_d2: Peri<'d, impl TXD2Pin>, - tx_d3: Peri<'d, impl TXD3Pin>, - tx_en: Peri<'d, impl TXEnPin>, + rx_clk: Peri<'d, if_afio!(impl RXClkPin)>, + tx_clk: Peri<'d, if_afio!(impl TXClkPin)>, + mdio: Peri<'d, if_afio!(impl MDIOPin)>, + mdc: Peri<'d, if_afio!(impl MDCPin)>, + rxdv: Peri<'d, if_afio!(impl RXDVPin)>, + rx_d0: Peri<'d, if_afio!(impl RXD0Pin)>, + rx_d1: Peri<'d, if_afio!(impl RXD1Pin)>, + rx_d2: Peri<'d, if_afio!(impl RXD2Pin)>, + rx_d3: Peri<'d, if_afio!(impl RXD3Pin)>, + tx_d0: Peri<'d, if_afio!(impl TXD0Pin)>, + tx_d1: Peri<'d, if_afio!(impl TXD1Pin)>, + tx_d2: Peri<'d, if_afio!(impl TXD2Pin)>, + tx_d3: Peri<'d, if_afio!(impl TXD3Pin)>, + tx_en: Peri<'d, if_afio!(impl TXEnPin)>, phy: P, mac_addr: [u8; 6], ) -> Self { diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index 96ad42c7f..034c5dd88 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs @@ -65,19 +65,19 @@ macro_rules! config_pins { impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { /// Create a new RMII ethernet driver using 9 pins. - pub fn new( + pub fn new( queue: &'d mut PacketQueue, peri: Peri<'d, T>, irq: impl interrupt::typelevel::Binding + 'd, - ref_clk: Peri<'d, impl RefClkPin>, - mdio: Peri<'d, impl MDIOPin>, - mdc: Peri<'d, impl MDCPin>, - crs: Peri<'d, impl CRSPin>, - rx_d0: Peri<'d, impl RXD0Pin>, - rx_d1: Peri<'d, impl RXD1Pin>, - tx_d0: Peri<'d, impl TXD0Pin>, - tx_d1: Peri<'d, impl TXD1Pin>, - tx_en: Peri<'d, impl TXEnPin>, + ref_clk: Peri<'d, impl RefClkPin>, + mdio: Peri<'d, impl MDIOPin>, + mdc: Peri<'d, impl MDCPin>, + crs: Peri<'d, impl CRSPin>, + rx_d0: Peri<'d, impl RXD0Pin>, + rx_d1: Peri<'d, impl RXD1Pin>, + tx_d0: Peri<'d, impl TXD0Pin>, + tx_d1: Peri<'d, impl TXD1Pin>, + tx_en: Peri<'d, impl TXEnPin>, phy: P, mac_addr: [u8; 6], ) -> Self { @@ -110,24 +110,24 @@ impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { } /// Create a new MII ethernet driver using 14 pins. - pub fn new_mii( + pub fn new_mii( queue: &'d mut PacketQueue, peri: Peri<'d, T>, irq: impl interrupt::typelevel::Binding + 'd, - rx_clk: Peri<'d, impl RXClkPin>, - tx_clk: Peri<'d, impl TXClkPin>, - mdio: Peri<'d, impl MDIOPin>, - mdc: Peri<'d, impl MDCPin>, - rxdv: Peri<'d, impl RXDVPin>, - rx_d0: Peri<'d, impl RXD0Pin>, - rx_d1: Peri<'d, impl RXD1Pin>, - rx_d2: Peri<'d, impl RXD2Pin>, - rx_d3: Peri<'d, impl RXD3Pin>, - tx_d0: Peri<'d, impl TXD0Pin>, - tx_d1: Peri<'d, impl TXD1Pin>, - tx_d2: Peri<'d, impl TXD2Pin>, - tx_d3: Peri<'d, impl TXD3Pin>, - tx_en: Peri<'d, impl TXEnPin>, + rx_clk: Peri<'d, impl RXClkPin>, + tx_clk: Peri<'d, impl TXClkPin>, + mdio: Peri<'d, impl MDIOPin>, + mdc: Peri<'d, impl MDCPin>, + rxdv: Peri<'d, impl RXDVPin>, + rx_d0: Peri<'d, impl RXD0Pin>, + rx_d1: Peri<'d, impl RXD1Pin>, + rx_d2: Peri<'d, impl RXD2Pin>, + rx_d3: Peri<'d, impl RXD3Pin>, + tx_d0: Peri<'d, impl TXD0Pin>, + tx_d1: Peri<'d, impl TXD1Pin>, + tx_d2: Peri<'d, impl TXD2Pin>, + tx_d3: Peri<'d, impl TXD3Pin>, + tx_en: Peri<'d, impl TXEnPin>, phy: P, mac_addr: [u8; 6], ) -> Self { diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index ef631bbdc..83fd08e23 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -718,6 +718,7 @@ pub struct AfioRemap; /// Holds the AFIO remap value for a peripheral's pin pub struct AfioRemapBool; +#[cfg(afio)] /// Placeholder for a peripheral's pin which cannot be remapped via AFIO. pub struct AfioRemapNotApplicable; diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs index be0ae2f5f..249bac41c 100644 --- a/embassy-stm32/src/i2c/mod.rs +++ b/embassy-stm32/src/i2c/mod.rs @@ -149,10 +149,10 @@ pub struct I2c<'d, M: Mode, IM: MasterMode> { impl<'d> I2c<'d, Async, Master> { /// Create a new I2C driver. - pub fn new( + pub fn new( peri: Peri<'d, T>, - scl: Peri<'d, impl SclPin>, - sda: Peri<'d, impl SdaPin>, + scl: Peri<'d, if_afio!(impl SclPin)>, + sda: Peri<'d, if_afio!(impl SdaPin)>, _irq: impl interrupt::typelevel::Binding> + interrupt::typelevel::Binding> + 'd, @@ -173,10 +173,10 @@ impl<'d> I2c<'d, Async, Master> { impl<'d> I2c<'d, Blocking, Master> { /// Create a new blocking I2C driver. - pub fn new_blocking( + pub fn new_blocking( peri: Peri<'d, T>, - scl: Peri<'d, impl SclPin>, - sda: Peri<'d, impl SdaPin>, + scl: Peri<'d, if_afio!(impl SclPin)>, + sda: Peri<'d, if_afio!(impl SdaPin)>, config: Config, ) -> Self { Self::new_inner( diff --git a/embassy-stm32/src/i2s.rs b/embassy-stm32/src/i2s.rs index 4c634aa17..1b885ec54 100644 --- a/embassy-stm32/src/i2s.rs +++ b/embassy-stm32/src/i2s.rs @@ -237,12 +237,12 @@ pub struct I2S<'d, W: Word> { impl<'d, W: Word> I2S<'d, W> { /// Create a transmitter driver. - pub fn new_txonly( + pub fn new_txonly( peri: Peri<'d, T>, - sd: Peri<'d, impl MosiPin>, - ws: Peri<'d, impl WsPin>, - ck: Peri<'d, impl CkPin>, - mck: Peri<'d, impl MckPin>, + sd: Peri<'d, if_afio!(impl MosiPin)>, + ws: Peri<'d, if_afio!(impl WsPin)>, + ck: Peri<'d, if_afio!(impl CkPin)>, + mck: Peri<'d, if_afio!(impl MckPin)>, txdma: Peri<'d, impl TxDma>, txdma_buf: &'d mut [W], config: Config, @@ -262,11 +262,11 @@ impl<'d, W: Word> I2S<'d, W> { } /// Create a transmitter driver without a master clock pin. - pub fn new_txonly_nomck( + pub fn new_txonly_nomck( peri: Peri<'d, T>, - sd: Peri<'d, impl MosiPin>, - ws: Peri<'d, impl WsPin>, - ck: Peri<'d, impl CkPin>, + sd: Peri<'d, if_afio!(impl MosiPin)>, + ws: Peri<'d, if_afio!(impl WsPin)>, + ck: Peri<'d, if_afio!(impl CkPin)>, txdma: Peri<'d, impl TxDma>, txdma_buf: &'d mut [W], config: Config, @@ -286,12 +286,12 @@ impl<'d, W: Word> I2S<'d, W> { } /// Create a receiver driver. - pub fn new_rxonly( + pub fn new_rxonly( peri: Peri<'d, T>, - sd: Peri<'d, impl MisoPin>, - ws: Peri<'d, impl WsPin>, - ck: Peri<'d, impl CkPin>, - mck: Peri<'d, impl MckPin>, + sd: Peri<'d, if_afio!(impl MisoPin)>, + ws: Peri<'d, if_afio!(impl WsPin)>, + ck: Peri<'d, if_afio!(impl CkPin)>, + mck: Peri<'d, if_afio!(impl MckPin)>, rxdma: Peri<'d, impl RxDma>, rxdma_buf: &'d mut [W], config: Config, @@ -313,13 +313,13 @@ impl<'d, W: Word> I2S<'d, W> { #[cfg(any(spi_v4, spi_v5))] /// Create a full duplex driver. - pub fn new_full_duplex( + pub fn new_full_duplex( peri: Peri<'d, T>, - txsd: Peri<'d, impl MosiPin>, - rxsd: Peri<'d, impl MisoPin>, - ws: Peri<'d, impl WsPin>, - ck: Peri<'d, impl CkPin>, - mck: Peri<'d, impl MckPin>, + txsd: Peri<'d, if_afio!(impl MosiPin)>, + rxsd: Peri<'d, if_afio!(impl MisoPin)>, + ws: Peri<'d, if_afio!(impl WsPin)>, + ck: Peri<'d, if_afio!(impl CkPin)>, + mck: Peri<'d, if_afio!(impl MckPin)>, txdma: Peri<'d, impl TxDma>, txdma_buf: &'d mut [W], rxdma: Peri<'d, impl RxDma>, @@ -459,12 +459,12 @@ impl<'d, W: Word> I2S<'d, W> { } } - fn new_inner( + fn new_inner( peri: Peri<'d, T>, txsd: Option>, rxsd: Option>, - ws: Peri<'d, impl WsPin>, - ck: Peri<'d, impl CkPin>, + ws: Peri<'d, if_afio!(impl WsPin)>, + ck: Peri<'d, if_afio!(impl CkPin)>, mck: Option>, txdma: Option<(ChannelAndRequest<'d>, &'d mut [W])>, rxdma: Option<(ChannelAndRequest<'d>, &'d mut [W])>, diff --git a/embassy-stm32/src/macros.rs b/embassy-stm32/src/macros.rs index 8a3abe1ee..def8dcf49 100644 --- a/embassy-stm32/src/macros.rs +++ b/embassy-stm32/src/macros.rs @@ -43,7 +43,7 @@ macro_rules! peri_trait_impl { macro_rules! pin_trait { ($signal:ident, $instance:path $(, $mode:path)? $(, @$afio:ident)?) => { #[doc = concat!(stringify!($signal), " pin trait")] - pub trait $signal: crate::gpio::Pin { + pub trait $signal: crate::gpio::Pin { #[doc = concat!("Get the AF number needed to use this pin as ", stringify!($signal))] fn af_num(&self) -> u8; @@ -56,16 +56,23 @@ macro_rules! pin_trait { macro_rules! pin_trait_impl { (crate::$mod:ident::$trait:ident$(<$mode:ident>)?, $instance:ident, $pin:ident, $af:expr $(, $afio:path)?) => { + #[cfg(afio)] impl crate::$mod::$trait for crate::peripherals::$pin { fn af_num(&self) -> u8 { $af } - #[cfg(afio)] fn afio_remap(&self) { // nothing } } + + #[cfg(not(afio))] + impl crate::$mod::$trait for crate::peripherals::$pin { + fn af_num(&self) -> u8 { + $af + } + } }; } @@ -190,3 +197,46 @@ macro_rules! new_pin { Some(pin.into()) }}; } + +#[cfg(afio)] +macro_rules! if_afio { + ($($t:tt)*) => { + $($t)* + } +} +#[cfg(not(afio))] +macro_rules! if_afio { + (($a:ty, A)) => { + ($a,) + }; + (($a:ty, $b:ty, A)) => { + ($a,$b) + }; + (($a:ty, $b:ty, $c:ty, A)) => { + ($a,$b, $c) + }; + ($type:ident<$lt:lifetime, $a:ty, $b:ty, A>) => { + $type<$lt, $a, $b> + }; + ($type:ident<$lt:lifetime, $a:ty, $b:ty, $c:ty, A>) => { + $type<$lt, $a, $b, $c> + }; + ($type:ident<$a:ty, A>) => { + $type<$a> + }; + ($type:ident<$a:ty, $b:ty, A>) => { + $type<$a, $b> + }; + ($type:ident<$a:ty, $b:ty, $c:ty, A>) => { + $type<$a, $b, $c> + }; + (impl $trait:ident<$a:ty, A>) => { + impl $trait<$a> + }; + (impl $trait:ident<$a:ty, $b:ty, A>) => { + impl $trait<$a, $b> + }; + (impl $trait:ident<$a:ty, $b:ty, $c:ty, A>) => { + impl $trait<$a, $b, $c> + }; +} diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 105c617d8..c5373a54d 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs @@ -471,11 +471,11 @@ impl<'d, M: PeriMode> Spi<'d, M> { impl<'d> Spi<'d, Blocking> { /// Create a new blocking SPI driver. - pub fn new_blocking( + pub fn new_blocking( peri: Peri<'d, T>, - sck: Peri<'d, impl SckPin>, - mosi: Peri<'d, impl MosiPin>, - miso: Peri<'d, impl MisoPin>, + sck: Peri<'d, if_afio!(impl SckPin)>, + mosi: Peri<'d, if_afio!(impl MosiPin)>, + miso: Peri<'d, if_afio!(impl MisoPin)>, config: Config, ) -> Self { Self::new_inner( @@ -490,10 +490,10 @@ impl<'d> Spi<'d, Blocking> { } /// Create a new blocking SPI driver, in RX-only mode (only MISO pin, no MOSI). - pub fn new_blocking_rxonly( + pub fn new_blocking_rxonly( peri: Peri<'d, T>, - sck: Peri<'d, impl SckPin>, - miso: Peri<'d, impl MisoPin>, + sck: Peri<'d, if_afio!(impl SckPin)>, + miso: Peri<'d, if_afio!(impl MisoPin)>, config: Config, ) -> Self { Self::new_inner( @@ -508,10 +508,10 @@ impl<'d> Spi<'d, Blocking> { } /// Create a new blocking SPI driver, in TX-only mode (only MOSI pin, no MISO). - pub fn new_blocking_txonly( + pub fn new_blocking_txonly( peri: Peri<'d, T>, - sck: Peri<'d, impl SckPin>, - mosi: Peri<'d, impl MosiPin>, + sck: Peri<'d, if_afio!(impl SckPin)>, + mosi: Peri<'d, if_afio!(impl MosiPin)>, config: Config, ) -> Self { Self::new_inner( @@ -528,9 +528,9 @@ impl<'d> Spi<'d, Blocking> { /// Create a new SPI driver, in TX-only mode, without SCK pin. /// /// This can be useful for bit-banging non-SPI protocols. - pub fn new_blocking_txonly_nosck( + pub fn new_blocking_txonly_nosck( peri: Peri<'d, T>, - mosi: Peri<'d, impl MosiPin>, + mosi: Peri<'d, if_afio!(impl MosiPin)>, config: Config, ) -> Self { Self::new_inner( @@ -547,11 +547,11 @@ impl<'d> Spi<'d, Blocking> { impl<'d> Spi<'d, Async> { /// Create a new SPI driver. - pub fn new( + pub fn new( peri: Peri<'d, T>, - sck: Peri<'d, impl SckPin>, - mosi: Peri<'d, impl MosiPin>, - miso: Peri<'d, impl MisoPin>, + sck: Peri<'d, if_afio!(impl SckPin)>, + mosi: Peri<'d, if_afio!(impl MosiPin)>, + miso: Peri<'d, if_afio!(impl MisoPin)>, tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, config: Config, @@ -568,10 +568,10 @@ impl<'d> Spi<'d, Async> { } /// Create a new SPI driver, in RX-only mode (only MISO pin, no MOSI). - pub fn new_rxonly( + pub fn new_rxonly( peri: Peri<'d, T>, - sck: Peri<'d, impl SckPin>, - miso: Peri<'d, impl MisoPin>, + sck: Peri<'d, if_afio!(impl SckPin)>, + miso: Peri<'d, if_afio!(impl MisoPin)>, #[cfg(any(spi_v1, spi_v2, spi_v3))] tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, config: Config, @@ -591,10 +591,10 @@ impl<'d> Spi<'d, Async> { } /// Create a new SPI driver, in TX-only mode (only MOSI pin, no MISO). - pub fn new_txonly( + pub fn new_txonly( peri: Peri<'d, T>, - sck: Peri<'d, impl SckPin>, - mosi: Peri<'d, impl MosiPin>, + sck: Peri<'d, if_afio!(impl SckPin)>, + mosi: Peri<'d, if_afio!(impl MosiPin)>, tx_dma: Peri<'d, impl TxDma>, config: Config, ) -> Self { @@ -612,9 +612,9 @@ impl<'d> Spi<'d, Async> { /// Create a new SPI driver, in TX-only mode, without SCK pin. /// /// This can be useful for bit-banging non-SPI protocols. - pub fn new_txonly_nosck( + pub fn new_txonly_nosck( peri: Peri<'d, T>, - mosi: Peri<'d, impl MosiPin>, + mosi: Peri<'d, if_afio!(impl MosiPin)>, tx_dma: Peri<'d, impl TxDma>, config: Config, ) -> Self { diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index d3b84ed16..693eb3456 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs @@ -16,15 +16,15 @@ use crate::Peri; /// Complementary PWM pin wrapper. /// /// This wraps a pin to make it usable with PWM. -pub struct ComplementaryPwmPin<'d, T, C, A> { +pub struct ComplementaryPwmPin<'d, T, C, #[cfg(afio)] A> { #[allow(unused)] pin: Peri<'d, AnyPin>, - phantom: PhantomData<(T, C, A)>, + phantom: PhantomData, } -impl<'d, T: AdvancedInstance4Channel, C: TimerChannel, A> ComplementaryPwmPin<'d, T, C, A> { +impl<'d, T: AdvancedInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(ComplementaryPwmPin<'d, T, C, A>) { /// Create a new complementary PWM pin instance. - pub fn new(pin: Peri<'d, impl TimerComplementaryPin>, output_type: OutputType) -> Self { + pub fn new(pin: Peri<'d, if_afio!(impl TimerComplementaryPin)>, output_type: OutputType) -> Self { critical_section::with(|_| { pin.set_low(); pin.set_as_af( @@ -58,16 +58,16 @@ pub enum IdlePolarity { impl<'d, T: AdvancedInstance4Channel> ComplementaryPwm<'d, T> { /// Create a new complementary PWM driver. #[allow(clippy::too_many_arguments, unused)] - pub fn new( + pub fn new<#[cfg(afio)] A>( tim: Peri<'d, T>, - ch1: Option>, - ch1n: Option>, - ch2: Option>, - ch2n: Option>, - ch3: Option>, - ch3n: Option>, - ch4: Option>, - ch4n: Option>, + ch1: Option)>, + ch1n: Option)>, + ch2: Option)>, + ch2n: Option)>, + ch3: Option)>, + ch3n: Option)>, + ch4: Option)>, + ch4n: Option)>, freq: Hertz, counting_mode: CountingMode, ) -> Self { diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs index 262f9d067..41391bd6d 100644 --- a/embassy-stm32/src/timer/input_capture.rs +++ b/embassy-stm32/src/timer/input_capture.rs @@ -17,14 +17,14 @@ use crate::Peri; /// Capture pin wrapper. /// /// This wraps a pin to make it usable with capture. -pub struct CapturePin<'d, T, C, A> { +pub struct CapturePin<'d, T, C, #[cfg(afio)] A> { #[allow(unused)] pin: Peri<'d, AnyPin>, - phantom: PhantomData<(T, C, A)>, + phantom: PhantomData, } -impl<'d, T: GeneralInstance4Channel, C: TimerChannel, A> CapturePin<'d, T, C, A> { +impl<'d, T: GeneralInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(CapturePin<'d, T, C, A>) { /// Create a new capture pin instance. - pub fn new(pin: Peri<'d, impl TimerPin>, pull: Pull) -> Self { + pub fn new(pin: Peri<'d, if_afio!(impl TimerPin)>, pull: Pull) -> Self { pin.set_as_af(pin.af_num(), AfType::input(pull)); CapturePin { pin: pin.into(), @@ -41,12 +41,12 @@ pub struct InputCapture<'d, T: GeneralInstance4Channel> { impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> { /// Create a new input capture driver. #[allow(unused)] - pub fn new( + pub fn new<#[cfg(afio)] A>( tim: Peri<'d, T>, - ch1: Option>, - ch2: Option>, - ch3: Option>, - ch4: Option>, + ch1: Option)>, + ch2: Option)>, + ch3: Option)>, + ch4: Option)>, _irq: impl Binding> + 'd, freq: Hertz, counting_mode: CountingMode, diff --git a/embassy-stm32/src/timer/one_pulse.rs b/embassy-stm32/src/timer/one_pulse.rs index b15cea679..edab38022 100644 --- a/embassy-stm32/src/timer/one_pulse.rs +++ b/embassy-stm32/src/timer/one_pulse.rs @@ -64,7 +64,7 @@ impl SealedTriggerSource for Ext {} impl<'d, T: GeneralInstance4Channel, C: TriggerSource + TimerChannel> TriggerPin<'d, T, C> { /// Create a new Channel trigger pin instance. - pub fn new(pin: Peri<'d, impl TimerPin>, pull: Pull) -> Self { + pub fn new<#[cfg(afio)] A>(pin: Peri<'d, if_afio!(impl TimerPin)>, pull: Pull) -> Self { pin.set_as_af(pin.af_num(), AfType::input(pull)); #[cfg(afio)] pin.afio_remap(); @@ -77,7 +77,7 @@ impl<'d, T: GeneralInstance4Channel, C: TriggerSource + TimerChannel> TriggerPin impl<'d, T: GeneralInstance4Channel> TriggerPin<'d, T, Ext> { /// Create a new external trigger pin instance. - pub fn new_external(pin: Peri<'d, impl ExternalTriggerPin>, pull: Pull) -> Self { + pub fn new_external<#[cfg(afio)] A>(pin: Peri<'d, if_afio!(impl ExternalTriggerPin)>, pull: Pull) -> Self { pin.set_as_af(pin.af_num(), AfType::input(pull)); #[cfg(afio)] pin.afio_remap(); diff --git a/embassy-stm32/src/timer/pwm_input.rs b/embassy-stm32/src/timer/pwm_input.rs index 62d7a8550..4c1df0316 100644 --- a/embassy-stm32/src/timer/pwm_input.rs +++ b/embassy-stm32/src/timer/pwm_input.rs @@ -18,7 +18,12 @@ pub struct PwmInput<'d, T: GeneralInstance4Channel> { impl<'d, T: GeneralInstance4Channel> PwmInput<'d, T> { /// Create a new PWM input driver. - pub fn new_ch1(tim: Peri<'d, T>, pin: Peri<'d, impl TimerPin>, pull: Pull, freq: Hertz) -> Self { + pub fn new_ch1<#[cfg(afio)] A>( + tim: Peri<'d, T>, + pin: Peri<'d, if_afio!(impl TimerPin)>, + pull: Pull, + freq: Hertz, + ) -> Self { pin.set_as_af(pin.af_num(), AfType::input(pull)); #[cfg(afio)] pin.afio_remap(); @@ -27,7 +32,12 @@ impl<'d, T: GeneralInstance4Channel> PwmInput<'d, T> { } /// Create a new PWM input driver. - pub fn new_ch2(tim: Peri<'d, T>, pin: Peri<'d, impl TimerPin>, pull: Pull, freq: Hertz) -> Self { + pub fn new_ch2<#[cfg(afio)] A>( + tim: Peri<'d, T>, + pin: Peri<'d, if_afio!(impl TimerPin)>, + pull: Pull, + freq: Hertz, + ) -> Self { pin.set_as_af(pin.af_num(), AfType::input(pull)); #[cfg(afio)] pin.afio_remap(); diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index 39d051294..528c4a904 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs @@ -20,15 +20,15 @@ pub enum Direction { } /// Wrapper for using a pin with QEI. -pub struct QeiPin<'d, T, Channel, A> { +pub struct QeiPin<'d, T, Channel, #[cfg(afio)] A> { #[allow(unused)] pin: Peri<'d, AnyPin>, - phantom: PhantomData<(T, Channel, A)>, + phantom: PhantomData, } -impl<'d, T: GeneralInstance4Channel, C: QeiChannel, A> QeiPin<'d, T, C, A> { +impl<'d, T: GeneralInstance4Channel, C: QeiChannel, #[cfg(afio)] A> if_afio!(QeiPin<'d, T, C, A>) { /// Create a new QEI pin instance. - pub fn new(pin: Peri<'d, impl TimerPin>) -> Self { + pub fn new(pin: Peri<'d, if_afio!(impl TimerPin)>) -> Self { critical_section::with(|_| { pin.set_low(); pin.set_as_af(pin.af_num(), AfType::input(Pull::None)); @@ -62,7 +62,11 @@ pub struct Qei<'d, T: GeneralInstance4Channel> { impl<'d, T: GeneralInstance4Channel> Qei<'d, T> { /// Create a new quadrature decoder driver. #[allow(unused)] - pub fn new(tim: Peri<'d, T>, ch1: QeiPin<'d, T, Ch1, A>, ch2: QeiPin<'d, T, Ch2, A>) -> Self { + pub fn new<#[cfg(afio)] A>( + tim: Peri<'d, T>, + ch1: if_afio!(QeiPin<'d, T, Ch1, A>), + ch2: if_afio!(QeiPin<'d, T, Ch2, A>), + ) -> Self { Self::new_inner(tim) } diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 53f7cdd22..c08a3939f 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs @@ -14,10 +14,10 @@ use crate::Peri; /// PWM pin wrapper. /// /// This wraps a pin to make it usable with PWM. -pub struct PwmPin<'d, T, C, A> { +pub struct PwmPin<'d, T, C, #[cfg(afio)] A> { #[allow(unused)] pub(crate) pin: Peri<'d, AnyPin>, - phantom: PhantomData<(T, C, A)>, + phantom: PhantomData, } /// PWM pin config @@ -35,9 +35,9 @@ pub struct PwmPinConfig { pub pull: Pull, } -impl<'d, T: GeneralInstance4Channel, C: TimerChannel, A> PwmPin<'d, T, C, A> { +impl<'d, T: GeneralInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(PwmPin<'d, T, C, A>) { /// Create a new PWM pin instance. - pub fn new(pin: Peri<'d, impl TimerPin>, output_type: OutputType) -> Self { + pub fn new(pin: Peri<'d, if_afio!(impl TimerPin)>, output_type: OutputType) -> Self { critical_section::with(|_| { pin.set_low(); pin.set_as_af(pin.af_num(), AfType::output(output_type, Speed::VeryHigh)); @@ -50,8 +50,8 @@ impl<'d, T: GeneralInstance4Channel, C: TimerChannel, A> PwmPin<'d, T, C, A> { } } - /// Create a new PWM pin instance with config. - pub fn new_with_config(pin: Peri<'d, impl TimerPin>, pin_config: PwmPinConfig) -> Self { + /// Create a new PWM pin instance with a specific configuration. + pub fn new_with_config(pin: Peri<'d, if_afio!(impl TimerPin)>, pin_config: PwmPinConfig) -> Self { critical_section::with(|_| { pin.set_low(); pin.set_as_af( @@ -184,12 +184,12 @@ pub struct SimplePwm<'d, T: GeneralInstance4Channel> { impl<'d, T: GeneralInstance4Channel> SimplePwm<'d, T> { /// Create a new simple PWM driver. #[allow(unused)] - pub fn new( + pub fn new<#[cfg(afio)] A>( tim: Peri<'d, T>, - ch1: Option>, - ch2: Option>, - ch3: Option>, - ch4: Option>, + ch1: Option)>, + ch2: Option)>, + ch3: Option)>, + ch4: Option)>, freq: Hertz, counting_mode: CountingMode, ) -> Self { diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs index 72aeb8357..890c8a80e 100644 --- a/embassy-stm32/src/usart/buffered.rs +++ b/embassy-stm32/src/usart/buffered.rs @@ -208,10 +208,10 @@ impl<'d> SetConfig for BufferedUartTx<'d> { impl<'d> BufferedUart<'d> { /// Create a new bidirectional buffered UART driver - pub fn new( + pub fn new( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], _irq: impl interrupt::typelevel::Binding> + 'd, @@ -231,12 +231,12 @@ impl<'d> BufferedUart<'d> { } /// Create a new bidirectional buffered UART driver with request-to-send and clear-to-send pins - pub fn new_with_rtscts( + pub fn new_with_rtscts( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, - rts: Peri<'d, impl RtsPin>, - cts: Peri<'d, impl CtsPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, + rts: Peri<'d, if_afio!(impl RtsPin)>, + cts: Peri<'d, if_afio!(impl CtsPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], @@ -256,11 +256,11 @@ impl<'d> BufferedUart<'d> { } /// Create a new bidirectional buffered UART driver with only the RTS pin as the DE pin - pub fn new_with_rts_as_de( + pub fn new_with_rts_as_de( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, - rts: Peri<'d, impl RtsPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, + rts: Peri<'d, if_afio!(impl RtsPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], @@ -280,11 +280,11 @@ impl<'d> BufferedUart<'d> { } /// Create a new bidirectional buffered UART driver with only the request-to-send pin - pub fn new_with_rts( + pub fn new_with_rts( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, - rts: Peri<'d, impl RtsPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, + rts: Peri<'d, if_afio!(impl RtsPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], @@ -305,11 +305,11 @@ impl<'d> BufferedUart<'d> { /// Create a new bidirectional buffered UART driver with a driver-enable pin #[cfg(not(any(usart_v1, usart_v2)))] - pub fn new_with_de( + pub fn new_with_de( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, - de: Peri<'d, impl DePin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, + de: Peri<'d, if_afio!(impl DePin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], @@ -340,9 +340,9 @@ impl<'d> BufferedUart<'d> { /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict /// on the line must be managed by software (for instance by using a centralized arbiter). #[doc(alias("HDSEL"))] - pub fn new_half_duplex( + pub fn new_half_duplex( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], @@ -379,9 +379,9 @@ impl<'d> BufferedUart<'d> { /// on the line must be managed by software (for instance by using a centralized arbiter). #[cfg(not(any(usart_v1, usart_v2)))] #[doc(alias("HDSEL"))] - pub fn new_half_duplex_on_rx( + pub fn new_half_duplex_on_rx( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_buffer: &'d mut [u8], rx_buffer: &'d mut [u8], diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index 21d174bf0..ff211e0c9 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -429,9 +429,9 @@ impl<'d, M: Mode> SetConfig for UartRx<'d, M> { impl<'d> UartTx<'d, Async> { /// Useful if you only want Uart Tx. It saves 1 pin and consumes a little less power. - pub fn new( + pub fn new( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, tx_dma: Peri<'d, impl TxDma>, config: Config, ) -> Result { @@ -439,10 +439,10 @@ impl<'d> UartTx<'d, Async> { } /// Create a new tx-only UART with a clear-to-send pin - pub fn new_with_cts( + pub fn new_with_cts( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, - cts: Peri<'d, impl CtsPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, + cts: Peri<'d, if_afio!(impl CtsPin)>, tx_dma: Peri<'d, impl TxDma>, config: Config, ) -> Result { @@ -482,19 +482,19 @@ impl<'d> UartTx<'d, Blocking> { /// Create a new blocking tx-only UART with no hardware flow control. /// /// Useful if you only want Uart Tx. It saves 1 pin and consumes a little less power. - pub fn new_blocking( + pub fn new_blocking( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, config: Config, ) -> Result { Self::new_inner(peri, new_pin!(tx, config.tx_af()), None, None, config) } /// Create a new blocking tx-only UART with a clear-to-send pin - pub fn new_blocking_with_cts( + pub fn new_blocking_with_cts( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, - cts: Peri<'d, impl CtsPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, + cts: Peri<'d, if_afio!(impl CtsPin)>, config: Config, ) -> Result { Self::new_inner( @@ -662,10 +662,10 @@ impl<'d> UartRx<'d, Async> { /// Create a new rx-only UART with no hardware flow control. /// /// Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power. - pub fn new( + pub fn new( peri: Peri<'d, T>, _irq: impl interrupt::typelevel::Binding> + 'd, - rx: Peri<'d, impl RxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, rx_dma: Peri<'d, impl RxDma>, config: Config, ) -> Result { @@ -673,11 +673,11 @@ impl<'d> UartRx<'d, Async> { } /// Create a new rx-only UART with a request-to-send pin - pub fn new_with_rts( + pub fn new_with_rts( peri: Peri<'d, T>, _irq: impl interrupt::typelevel::Binding> + 'd, - rx: Peri<'d, impl RxPin>, - rts: Peri<'d, impl RtsPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + rts: Peri<'d, if_afio!(impl RtsPin)>, rx_dma: Peri<'d, impl RxDma>, config: Config, ) -> Result { @@ -913,19 +913,19 @@ impl<'d> UartRx<'d, Blocking> { /// Create a new rx-only UART with no hardware flow control. /// /// Useful if you only want Uart Rx. It saves 1 pin and consumes a little less power. - pub fn new_blocking( + pub fn new_blocking( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, config: Config, ) -> Result { Self::new_inner(peri, new_pin!(rx, config.rx_af()), None, None, config) } /// Create a new rx-only UART with a request-to-send pin - pub fn new_blocking_with_rts( + pub fn new_blocking_with_rts( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - rts: Peri<'d, impl RtsPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + rts: Peri<'d, if_afio!(impl RtsPin)>, config: Config, ) -> Result { Self::new_inner( @@ -1109,10 +1109,10 @@ fn drop_tx_rx(info: &Info, state: &State) { impl<'d> Uart<'d, Async> { /// Create a new bidirectional UART - pub fn new( + pub fn new( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, @@ -1132,13 +1132,13 @@ impl<'d> Uart<'d, Async> { } /// Create a new bidirectional UART with request-to-send and clear-to-send pins - pub fn new_with_rtscts( + pub fn new_with_rtscts( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, - rts: Peri<'d, impl RtsPin>, - cts: Peri<'d, impl CtsPin>, + rts: Peri<'d, if_afio!(impl RtsPin)>, + cts: Peri<'d, if_afio!(impl CtsPin)>, tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, config: Config, @@ -1158,12 +1158,12 @@ impl<'d> Uart<'d, Async> { #[cfg(not(any(usart_v1, usart_v2)))] /// Create a new bidirectional UART with a driver-enable pin - pub fn new_with_de( + pub fn new_with_de( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, - de: Peri<'d, impl DePin>, + de: Peri<'d, if_afio!(impl DePin)>, tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, config: Config, @@ -1193,9 +1193,9 @@ impl<'d> Uart<'d, Async> { /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict /// on the line must be managed by software (for instance by using a centralized arbiter). #[doc(alias("HDSEL"))] - pub fn new_half_duplex( + pub fn new_half_duplex( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, @@ -1232,9 +1232,9 @@ impl<'d> Uart<'d, Async> { /// on the line must be managed by software (for instance by using a centralized arbiter). #[cfg(not(any(usart_v1, usart_v2)))] #[doc(alias("HDSEL"))] - pub fn new_half_duplex_on_rx( + pub fn new_half_duplex_on_rx( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, _irq: impl interrupt::typelevel::Binding> + 'd, tx_dma: Peri<'d, impl TxDma>, rx_dma: Peri<'d, impl RxDma>, @@ -1280,10 +1280,10 @@ impl<'d> Uart<'d, Async> { impl<'d> Uart<'d, Blocking> { /// Create a new blocking bidirectional UART. - pub fn new_blocking( + pub fn new_blocking( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, config: Config, ) -> Result { Self::new_inner( @@ -1300,12 +1300,12 @@ impl<'d> Uart<'d, Blocking> { } /// Create a new bidirectional UART with request-to-send and clear-to-send pins - pub fn new_blocking_with_rtscts( + pub fn new_blocking_with_rtscts( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, - rts: Peri<'d, impl RtsPin>, - cts: Peri<'d, impl CtsPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, + rts: Peri<'d, if_afio!(impl RtsPin)>, + cts: Peri<'d, if_afio!(impl CtsPin)>, config: Config, ) -> Result { Self::new_inner( @@ -1323,11 +1323,11 @@ impl<'d> Uart<'d, Blocking> { #[cfg(not(any(usart_v1, usart_v2)))] /// Create a new bidirectional UART with a driver-enable pin - pub fn new_blocking_with_de( + pub fn new_blocking_with_de( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, - tx: Peri<'d, impl TxPin>, - de: Peri<'d, impl DePin>, + rx: Peri<'d, if_afio!(impl RxPin)>, + tx: Peri<'d, if_afio!(impl TxPin)>, + de: Peri<'d, if_afio!(impl DePin)>, config: Config, ) -> Result { Self::new_inner( @@ -1354,9 +1354,9 @@ impl<'d> Uart<'d, Blocking> { /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict /// on the line must be managed by software (for instance by using a centralized arbiter). #[doc(alias("HDSEL"))] - pub fn new_blocking_half_duplex( + pub fn new_blocking_half_duplex( peri: Peri<'d, T>, - tx: Peri<'d, impl TxPin>, + tx: Peri<'d, if_afio!(impl TxPin)>, mut config: Config, readback: HalfDuplexReadback, ) -> Result { @@ -1390,9 +1390,9 @@ impl<'d> Uart<'d, Blocking> { /// on the line must be managed by software (for instance by using a centralized arbiter). #[cfg(not(any(usart_v1, usart_v2)))] #[doc(alias("HDSEL"))] - pub fn new_blocking_half_duplex_on_rx( + pub fn new_blocking_half_duplex_on_rx( peri: Peri<'d, T>, - rx: Peri<'d, impl RxPin>, + rx: Peri<'d, if_afio!(impl RxPin)>, mut config: Config, readback: HalfDuplexReadback, ) -> Result { -- cgit