From 1d9f945cd39f61b695d02246dbbcccf1572845d6 Mon Sep 17 00:00:00 2001 From: Juraj Sadel Date: Tue, 17 Dec 2024 16:51:02 +0100 Subject: [PATCH] Rename M, DmaMode, MODE type parameters to Dm --- esp-hal/src/dma/gdma.rs | 2 +- esp-hal/src/dma/m2m.rs | 20 ++--- esp-hal/src/dma/mod.rs | 44 +++++----- esp-hal/src/dma/pdma/mod.rs | 4 +- esp-hal/src/i2s/master.rs | 98 +++++++++++------------ esp-hal/src/rmt.rs | 142 ++++++++++++++++----------------- esp-hal/src/spi/master.rs | 110 ++++++++++++------------- esp-hal/src/spi/slave.rs | 38 ++++----- esp-hal/src/timer/mod.rs | 30 +++---- esp-hal/src/touch.rs | 14 ++-- esp-hal/src/uart.rs | 118 +++++++++++++-------------- esp-hal/src/usb_serial_jtag.rs | 100 +++++++++++------------ esp-wifi/src/wifi/mod.rs | 62 +++++++------- esp-wifi/src/wifi/utils.rs | 8 +- 14 files changed, 395 insertions(+), 395 deletions(-) diff --git a/esp-hal/src/dma/gdma.rs b/esp-hal/src/dma/gdma.rs index a4d7152baf8..23f646f382c 100644 --- a/esp-hal/src/dma/gdma.rs +++ b/esp-hal/src/dma/gdma.rs @@ -581,7 +581,7 @@ impl InterruptAccess for AnyGdmaRxChannel { } } -impl Channel<'_, M, CH> { +impl Channel<'_, Dm, CH> { /// Asserts that the channel is compatible with the given peripheral. pub fn runtime_ensure_compatible(&self, _peripheral: &PeripheralRef<'_, P>) { // No runtime checks; GDMA channels are compatible with any peripheral diff --git a/esp-hal/src/dma/m2m.rs b/esp-hal/src/dma/m2m.rs index 55356354ebe..2e625dd2344 100644 --- a/esp-hal/src/dma/m2m.rs +++ b/esp-hal/src/dma/m2m.rs @@ -28,11 +28,11 @@ use crate::{ /// This is a pseudo-peripheral that allows for memory to memory transfers. /// It is not a real peripheral, but a way to use the DMA engine for memory /// to memory transfers. -pub struct Mem2Mem<'d, M> +pub struct Mem2Mem<'d, Dm> where - M: Mode, + Dm: Mode, { - channel: Channel<'d, M, AnyGdmaChannel>, + channel: Channel<'d, Dm, AnyGdmaChannel>, rx_chain: DescriptorChain, tx_chain: DescriptorChain, peripheral: DmaPeripheral, @@ -123,9 +123,9 @@ impl<'d> Mem2Mem<'d, Blocking> { } } -impl Mem2Mem<'_, M> +impl Mem2Mem<'_, Dm> where - M: Mode, + Dm: Mode, { /// Start a memory to memory transfer. pub fn start_transfer<'t, TXBUF, RXBUF>( @@ -156,9 +156,9 @@ where } } -impl DmaSupport for Mem2Mem<'_, MODE> +impl DmaSupport for Mem2Mem<'_, Dm> where - MODE: Mode, + Dm: Mode, { fn peripheral_wait_dma(&mut self, _is_rx: bool, _is_tx: bool) { while !self.channel.rx.is_done() {} @@ -169,11 +169,11 @@ where } } -impl<'d, M> DmaSupportRx for Mem2Mem<'d, M> +impl<'d, Dm> DmaSupportRx for Mem2Mem<'d, Dm> where - M: Mode, + Dm: Mode, { - type RX = ChannelRx<'d, M, AnyGdmaRxChannel>; + type RX = ChannelRx<'d, Dm, AnyGdmaRxChannel>; fn rx(&mut self) -> &mut Self::RX { &mut self.channel.rx diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index 9b697b11478..c853be4edda 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -1808,13 +1808,13 @@ fn create_guard(_ch: &impl RegisterAccess) -> PeripheralGuard { // DMA receive channel #[non_exhaustive] #[doc(hidden)] -pub struct ChannelRx<'a, M, CH> +pub struct ChannelRx<'a, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaRxChannel, { pub(crate) rx_impl: PeripheralRef<'a, CH>, - pub(crate) _phantom: PhantomData, + pub(crate) _phantom: PhantomData, pub(crate) _guard: PeripheralGuard, } @@ -1892,9 +1892,9 @@ where } } -impl ChannelRx<'_, M, CH> +impl ChannelRx<'_, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaRxChannel, { /// Configure the channel. @@ -1936,16 +1936,16 @@ where } } -impl crate::private::Sealed for ChannelRx<'_, M, CH> +impl crate::private::Sealed for ChannelRx<'_, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaRxChannel, { } -impl Rx for ChannelRx<'_, M, CH> +impl Rx for ChannelRx<'_, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaRxChannel, { // TODO: used by I2S, which should be rewritten to use the Preparation-based @@ -2108,13 +2108,13 @@ pub trait Tx: crate::private::Sealed { /// DMA transmit channel #[doc(hidden)] -pub struct ChannelTx<'a, M, CH> +pub struct ChannelTx<'a, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaTxChannel, { pub(crate) tx_impl: PeripheralRef<'a, CH>, - pub(crate) _phantom: PhantomData, + pub(crate) _phantom: PhantomData, pub(crate) _guard: PeripheralGuard, } @@ -2186,9 +2186,9 @@ where } } -impl ChannelTx<'_, M, CH> +impl ChannelTx<'_, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaTxChannel, { /// Configure the channel priority. @@ -2230,16 +2230,16 @@ where } } -impl crate::private::Sealed for ChannelTx<'_, M, CH> +impl crate::private::Sealed for ChannelTx<'_, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaTxChannel, { } -impl Tx for ChannelTx<'_, M, CH> +impl Tx for ChannelTx<'_, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaTxChannel, { // TODO: used by I2S, which should be rewritten to use the Preparation-based @@ -2448,15 +2448,15 @@ pub trait InterruptAccess: crate::private::Sealed { /// DMA Channel #[non_exhaustive] -pub struct Channel<'d, M, CH> +pub struct Channel<'d, Dm, CH> where - M: Mode, + Dm: Mode, CH: DmaChannel, { /// RX half of the channel - pub rx: ChannelRx<'d, M, CH::Rx>, + pub rx: ChannelRx<'d, Dm, CH::Rx>, /// TX half of the channel - pub tx: ChannelTx<'d, M, CH::Tx>, + pub tx: ChannelTx<'d, Dm, CH::Tx>, } impl<'d, CH> Channel<'d, Blocking, CH> diff --git a/esp-hal/src/dma/pdma/mod.rs b/esp-hal/src/dma/pdma/mod.rs index 7461cab5e4f..5e529f01dbf 100644 --- a/esp-hal/src/dma/pdma/mod.rs +++ b/esp-hal/src/dma/pdma/mod.rs @@ -194,10 +194,10 @@ pub(super) fn init_dma(_cs: CriticalSection<'_>) { } } -impl Channel<'_, M, CH> +impl Channel<'_, Dm, CH> where CH: DmaChannel, - M: Mode, + Dm: Mode, { /// Asserts that the channel is compatible with the given peripheral. pub fn runtime_ensure_compatible(&self, peripheral: &PeripheralRef<'_, impl DmaEligible>) { diff --git a/esp-hal/src/i2s/master.rs b/esp-hal/src/i2s/master.rs index a9c467ff24d..ae7ac0f122a 100644 --- a/esp-hal/src/i2s/master.rs +++ b/esp-hal/src/i2s/master.rs @@ -250,15 +250,15 @@ impl DataFormat { /// Instance of the I2S peripheral driver #[non_exhaustive] -pub struct I2s<'d, M, T = AnyI2s> +pub struct I2s<'d, Dm, T = AnyI2s> where T: RegisterAccess, - M: Mode, + Dm: Mode, { /// Handles the reception (RX) side of the I2S peripheral. - pub i2s_rx: RxCreator<'d, M, T>, + pub i2s_rx: RxCreator<'d, Dm, T>, /// Handles the transmission (TX) side of the I2S peripheral. - pub i2s_tx: TxCreator<'d, M, T>, + pub i2s_tx: TxCreator<'d, Dm, T>, } impl<'d, T> I2s<'d, Blocking, T> @@ -308,10 +308,10 @@ where } } -impl I2s<'_, DmaMode, T> +impl I2s<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { /// Sets the interrupt handler /// @@ -346,17 +346,17 @@ where } } -impl crate::private::Sealed for I2s<'_, DmaMode, I> +impl crate::private::Sealed for I2s<'_, Dm, I> where I: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { } -impl InterruptConfigurable for I2s<'_, DmaMode, I> +impl InterruptConfigurable for I2s<'_, Dm, I> where I: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn set_interrupt_handler(&mut self, handler: crate::interrupt::InterruptHandler) { I2s::set_interrupt_handler(self, handler); @@ -441,10 +441,10 @@ where } } -impl<'d, M, T> I2s<'d, M, T> +impl<'d, Dm, T> I2s<'d, Dm, T> where T: RegisterAccess, - M: Mode, + Dm: Mode, { /// Configures the I2S peripheral to use a master clock (MCLK) output pin. pub fn with_mclk(self, pin: impl Peripheral

+ 'd) -> Self { @@ -457,31 +457,31 @@ where } /// I2S TX channel -pub struct I2sTx<'d, DmaMode, T = AnyI2s> +pub struct I2sTx<'d, Dm, T = AnyI2s> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { i2s: PeripheralRef<'d, T>, - tx_channel: ChannelTx<'d, DmaMode, PeripheralTxChannel>, + tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel>, tx_chain: DescriptorChain, _guard: PeripheralGuard, } -impl core::fmt::Debug for I2sTx<'_, DmaMode, T> +impl core::fmt::Debug for I2sTx<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("I2sTx").finish() } } -impl DmaSupport for I2sTx<'_, DmaMode, T> +impl DmaSupport for I2sTx<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn peripheral_wait_dma(&mut self, _is_rx: bool, _is_tx: bool) { self.i2s.wait_for_tx_done(); @@ -492,12 +492,12 @@ where } } -impl<'d, DmaMode, T> DmaSupportTx for I2sTx<'d, DmaMode, T> +impl<'d, Dm, T> DmaSupportTx for I2sTx<'d, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { - type TX = ChannelTx<'d, DmaMode, PeripheralTxChannel>; + type TX = ChannelTx<'d, Dm, PeripheralTxChannel>; fn tx(&mut self) -> &mut Self::TX { &mut self.tx_channel @@ -508,10 +508,10 @@ where } } -impl I2sTx<'_, DmaMode, T> +impl I2sTx<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn write_bytes(&mut self, data: &[u8]) -> Result<(), Error> { self.start_tx_transfer(&data, false)?; @@ -529,7 +529,7 @@ where ) -> Result<(), Error> where TXBUF: ReadBuffer, - DmaMode: Mode, + Dm: Mode, { let (ptr, len) = unsafe { words.read_buffer() }; @@ -590,31 +590,31 @@ where } /// I2S RX channel -pub struct I2sRx<'d, DmaMode, T = AnyI2s> +pub struct I2sRx<'d, Dm, T = AnyI2s> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { i2s: PeripheralRef<'d, T>, - rx_channel: ChannelRx<'d, DmaMode, PeripheralRxChannel>, + rx_channel: ChannelRx<'d, Dm, PeripheralRxChannel>, rx_chain: DescriptorChain, _guard: PeripheralGuard, } -impl core::fmt::Debug for I2sRx<'_, DmaMode, T> +impl core::fmt::Debug for I2sRx<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("I2sRx").finish() } } -impl DmaSupport for I2sRx<'_, DmaMode, T> +impl DmaSupport for I2sRx<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn peripheral_wait_dma(&mut self, _is_rx: bool, _is_tx: bool) { self.i2s.wait_for_rx_done(); @@ -625,12 +625,12 @@ where } } -impl<'d, DmaMode, T> DmaSupportRx for I2sRx<'d, DmaMode, T> +impl<'d, Dm, T> DmaSupportRx for I2sRx<'d, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { - type RX = ChannelRx<'d, DmaMode, PeripheralRxChannel>; + type RX = ChannelRx<'d, Dm, PeripheralRxChannel>; fn rx(&mut self) -> &mut Self::RX { &mut self.rx_channel @@ -641,10 +641,10 @@ where } } -impl I2sRx<'_, DmaMode, T> +impl I2sRx<'_, Dm, T> where T: RegisterAccess, - DmaMode: Mode, + Dm: Mode, { fn read_bytes(&mut self, mut data: &mut [u8]) -> Result<(), Error> { self.start_rx_transfer(&mut data, false)?; @@ -760,23 +760,23 @@ mod private { Mode, }; - pub struct TxCreator<'d, M, T> + pub struct TxCreator<'d, Dm, T> where T: RegisterAccess, - M: Mode, + Dm: Mode, { pub i2s: PeripheralRef<'d, T>, - pub tx_channel: ChannelTx<'d, M, PeripheralTxChannel>, + pub tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel>, pub descriptors: &'static mut [DmaDescriptor], pub(crate) guard: PeripheralGuard, } - impl<'d, M, T> TxCreator<'d, M, T> + impl<'d, Dm, T> TxCreator<'d, Dm, T> where - M: Mode, + Dm: Mode, T: RegisterAccess, { - pub fn build(self) -> I2sTx<'d, M, T> { + pub fn build(self) -> I2sTx<'d, Dm, T> { let peripheral = self.i2s.peripheral(); I2sTx { i2s: self.i2s, @@ -820,23 +820,23 @@ mod private { } } - pub struct RxCreator<'d, M, T> + pub struct RxCreator<'d, Dm, T> where T: RegisterAccess, - M: Mode, + Dm: Mode, { pub i2s: PeripheralRef<'d, T>, - pub rx_channel: ChannelRx<'d, M, PeripheralRxChannel>, + pub rx_channel: ChannelRx<'d, Dm, PeripheralRxChannel>, pub descriptors: &'static mut [DmaDescriptor], pub(crate) guard: PeripheralGuard, } - impl<'d, M, T> RxCreator<'d, M, T> + impl<'d, Dm, T> RxCreator<'d, Dm, T> where - M: Mode, + Dm: Mode, T: RegisterAccess, { - pub fn build(self) -> I2sRx<'d, M, T> { + pub fn build(self) -> I2sRx<'d, Dm, T> { let peripheral = self.i2s.peripheral(); I2sRx { i2s: self.i2s, diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index e72c2bbd8b5..e32066def9d 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -351,9 +351,9 @@ pub struct RxChannelConfig { pub use impl_for_chip::{ChannelCreator, Rmt}; -impl<'d, M> Rmt<'d, M> +impl<'d, Dm> Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(crate) fn new_internal( peripheral: impl Peripheral

+ 'd, @@ -425,7 +425,7 @@ impl InterruptConfigurable for Rmt<'_, Blocking> { } } -fn configure_rx_channel<'d, P: PeripheralInput, T: RxChannelInternal, M: crate::Mode>( +fn configure_rx_channel<'d, P: PeripheralInput, T: RxChannelInternal, Dm: crate::Mode>( pin: impl Peripheral

+ 'd, config: RxChannelConfig, ) -> Result { @@ -462,7 +462,7 @@ fn configure_rx_channel<'d, P: PeripheralInput, T: RxChannelInternal, M: crat Ok(T::new()) } -fn configure_tx_channel<'d, P: PeripheralOutput, T: TxChannelInternal, M: crate::Mode>( +fn configure_tx_channel<'d, P: PeripheralOutput, T: TxChannelInternal, Dm: crate::Mode>( pin: impl Peripheral

+ 'd, config: TxChannelConfig, ) -> Result { @@ -744,25 +744,25 @@ mod impl_for_chip { }; /// RMT Instance - pub struct Rmt<'d, M> + pub struct Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) peripheral: PeripheralRef<'d, crate::peripherals::RMT>, /// RMT Channel 0. - pub channel0: ChannelCreator, + pub channel0: ChannelCreator, /// RMT Channel 1. - pub channel1: ChannelCreator, + pub channel1: ChannelCreator, /// RMT Channel 2. - pub channel2: ChannelCreator, + pub channel2: ChannelCreator, /// RMT Channel 3. - pub channel3: ChannelCreator, - phantom: PhantomData, + pub channel3: ChannelCreator, + phantom: PhantomData, } - impl<'d, M> Rmt<'d, M> + impl<'d, Dm> Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) fn create( peripheral: impl Peripheral

+ 'd, @@ -793,11 +793,11 @@ mod impl_for_chip { } /// RMT Channel Creator - pub struct ChannelCreator + pub struct ChannelCreator where - M: crate::Mode, + Dm: crate::Mode, { - phantom: PhantomData, + phantom: PhantomData, _guard: GenericPeripheralGuard<{ crate::system::Peripheral::Rmt as u8 }>, } @@ -824,33 +824,33 @@ mod impl_for_chip { }; /// RMT Instance - pub struct Rmt<'d, M> + pub struct Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) peripheral: PeripheralRef<'d, crate::peripherals::RMT>, /// RMT Channel 0. - pub channel0: ChannelCreator, + pub channel0: ChannelCreator, /// RMT Channel 1. - pub channel1: ChannelCreator, + pub channel1: ChannelCreator, /// RMT Channel 2. - pub channel2: ChannelCreator, + pub channel2: ChannelCreator, /// RMT Channel 3. - pub channel3: ChannelCreator, + pub channel3: ChannelCreator, /// RMT Channel 4. - pub channel4: ChannelCreator, + pub channel4: ChannelCreator, /// RMT Channel 5. - pub channel5: ChannelCreator, + pub channel5: ChannelCreator, /// RMT Channel 6. - pub channel6: ChannelCreator, + pub channel6: ChannelCreator, /// RMT Channel 7. - pub channel7: ChannelCreator, - phantom: PhantomData, + pub channel7: ChannelCreator, + phantom: PhantomData, } - impl<'d, M> Rmt<'d, M> + impl<'d, Dm> Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) fn create( peripheral: impl Peripheral

+ 'd, @@ -896,11 +896,11 @@ mod impl_for_chip { } /// RMT Channel Creator - pub struct ChannelCreator + pub struct ChannelCreator where - M: crate::Mode, + Dm: crate::Mode, { - phantom: PhantomData, + phantom: PhantomData, _guard: GenericPeripheralGuard<{ crate::system::Peripheral::Rmt as u8 }>, } @@ -951,25 +951,25 @@ mod impl_for_chip { }; /// RMT Instance - pub struct Rmt<'d, M> + pub struct Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) peripheral: PeripheralRef<'d, crate::peripherals::RMT>, /// RMT Channel 0. - pub channel0: ChannelCreator, + pub channel0: ChannelCreator, /// RMT Channel 1. - pub channel1: ChannelCreator, + pub channel1: ChannelCreator, /// RMT Channel 2. - pub channel2: ChannelCreator, + pub channel2: ChannelCreator, /// RMT Channel 3. - pub channel3: ChannelCreator, - phantom: PhantomData, + pub channel3: ChannelCreator, + phantom: PhantomData, } - impl<'d, M> Rmt<'d, M> + impl<'d, Dm> Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) fn create( peripheral: impl Peripheral

+ 'd, @@ -1000,11 +1000,11 @@ mod impl_for_chip { } /// RMT Channel Creator - pub struct ChannelCreator + pub struct ChannelCreator where - M: crate::Mode, + Dm: crate::Mode, { - phantom: PhantomData, + phantom: PhantomData, _guard: GenericPeripheralGuard<{ crate::system::Peripheral::Rmt as u8 }>, } @@ -1039,33 +1039,33 @@ mod impl_for_chip { }; /// RMT Instance - pub struct Rmt<'d, M> + pub struct Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) peripheral: PeripheralRef<'d, crate::peripherals::RMT>, /// RMT Channel 0. - pub channel0: ChannelCreator, + pub channel0: ChannelCreator, /// RMT Channel 1. - pub channel1: ChannelCreator, + pub channel1: ChannelCreator, /// RMT Channel 2. - pub channel2: ChannelCreator, + pub channel2: ChannelCreator, /// RMT Channel 3. - pub channel3: ChannelCreator, + pub channel3: ChannelCreator, /// RMT Channel 4. - pub channel4: ChannelCreator, + pub channel4: ChannelCreator, /// RMT Channel 5. - pub channel5: ChannelCreator, + pub channel5: ChannelCreator, /// RMT Channel 6. - pub channel6: ChannelCreator, + pub channel6: ChannelCreator, /// RMT Channel 7. - pub channel7: ChannelCreator, - phantom: PhantomData, + pub channel7: ChannelCreator, + phantom: PhantomData, } - impl<'d, M> Rmt<'d, M> + impl<'d, Dm> Rmt<'d, Dm> where - M: crate::Mode, + Dm: crate::Mode, { pub(super) fn create( peripheral: impl Peripheral

+ 'd, @@ -1112,11 +1112,11 @@ mod impl_for_chip { } /// RMT Channel Creator - pub struct ChannelCreator + pub struct ChannelCreator where - M: crate::Mode, + Dm: crate::Mode, { - phantom: PhantomData, + phantom: PhantomData, _guard: GenericPeripheralGuard<{ crate::system::Peripheral::Rmt as u8 }>, } @@ -1144,11 +1144,11 @@ mod impl_for_chip { /// RMT Channel #[derive(Debug)] #[non_exhaustive] -pub struct Channel +pub struct Channel where - M: crate::Mode, + Dm: crate::Mode, { - phantom: PhantomData, + phantom: PhantomData, _guard: GenericPeripheralGuard<{ system::Peripheral::Rmt as u8 }>, } @@ -1530,9 +1530,9 @@ pub enum Event { } #[doc(hidden)] -pub trait TxChannelInternal +pub trait TxChannelInternal where - M: crate::Mode, + Dm: crate::Mode, { const CHANNEL: u8; @@ -1626,9 +1626,9 @@ where } #[doc(hidden)] -pub trait RxChannelInternal +pub trait RxChannelInternal where - M: crate::Mode, + Dm: crate::Mode, { const CHANNEL: u8; @@ -1765,7 +1765,7 @@ mod chip_specific { macro_rules! impl_tx_channel { ($signal:ident, $ch_num:literal) => { paste::paste! { - impl $crate::rmt::TxChannelInternal for $crate::rmt::Channel where M: $crate::Mode { + impl $crate::rmt::TxChannelInternal for $crate::rmt::Channel where Dm: $crate::Mode { const CHANNEL: u8 = $ch_num; fn new() -> Self { @@ -1928,7 +1928,7 @@ mod chip_specific { macro_rules! impl_rx_channel { ($signal:ident, $ch_num:literal, $ch_index:literal) => { paste::paste! { - impl $crate::rmt::RxChannelInternal for $crate::rmt::Channel where M: $crate::Mode { + impl $crate::rmt::RxChannelInternal for $crate::rmt::Channel where Dm: $crate::Mode { const CHANNEL: u8 = $ch_num; fn new() -> Self { @@ -2119,7 +2119,7 @@ mod chip_specific { macro_rules! impl_tx_channel { ($signal:ident, $ch_num:literal) => { paste::paste! { - impl super::TxChannelInternal for $crate::rmt::Channel where M: $crate::Mode { + impl super::TxChannelInternal for $crate::rmt::Channel where Dm: $crate::Mode { const CHANNEL: u8 = $ch_num; fn new() -> Self { @@ -2272,7 +2272,7 @@ mod chip_specific { macro_rules! impl_rx_channel { ($signal:ident, $ch_num:literal) => { paste::paste! { - impl super::RxChannelInternal for $crate::rmt::Channel where M: $crate::Mode { + impl super::RxChannelInternal for $crate::rmt::Channel where Dm: $crate::Mode { const CHANNEL: u8 = $ch_num; fn new() -> Self { diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 0d3e7badc39..1b9d6447ec3 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -457,13 +457,13 @@ pub enum ConfigError {} /// SPI peripheral driver #[derive(Debug, PartialEq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub struct Spi<'d, M, T = AnySpi> { +pub struct Spi<'d, Dm, T = AnySpi> { spi: PeripheralRef<'d, T>, - _mode: PhantomData, + _mode: PhantomData, guard: PeripheralGuard, } -impl Spi<'_, M, T> +impl Spi<'_, Dm, T> where T: Instance, { @@ -550,7 +550,7 @@ where } } -impl<'d, M, T> Spi<'d, M, T> +impl<'d, Dm, T> Spi<'d, Dm, T> where T: Instance, { @@ -652,10 +652,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl SetConfig for Spi<'_, M, T> +impl SetConfig for Spi<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Config = Config; type ConfigError = ConfigError; @@ -665,7 +665,7 @@ where } } -impl<'d, M, T> Spi<'d, M, T> +impl<'d, Dm, T> Spi<'d, Dm, T> where T: QspiInstance, { @@ -706,7 +706,7 @@ where } } -impl Spi<'_, M, T> +impl Spi<'_, Dm, T> where T: Instance, { @@ -831,13 +831,13 @@ mod dma { /// [`SpiDmaBus`] via `with_buffers` to get access /// to a DMA capable SPI bus that implements the /// embedded-hal traits. - pub struct SpiDma<'d, M, T = AnySpi> + pub struct SpiDma<'d, Dm, T = AnySpi> where T: Instance, - M: Mode, + Dm: Mode, { pub(crate) spi: PeripheralRef<'d, T>, - pub(crate) channel: Channel<'d, M, PeripheralDmaChannel>, + pub(crate) channel: Channel<'d, Dm, PeripheralDmaChannel>, tx_transfer_in_progress: bool, rx_transfer_in_progress: bool, #[cfg(all(esp32, spi_address_workaround))] @@ -845,10 +845,10 @@ mod dma { guard: PeripheralGuard, } - impl crate::private::Sealed for SpiDma<'_, M, T> + impl crate::private::Sealed for SpiDma<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { } @@ -888,10 +888,10 @@ mod dma { } } - impl core::fmt::Debug for SpiDma<'_, M, T> + impl core::fmt::Debug for SpiDma<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { /// Formats the `SpiDma` instance for debugging purposes. /// @@ -989,9 +989,9 @@ mod dma { } } - impl<'d, M, T> SpiDma<'d, M, T> + impl<'d, Dm, T> SpiDma<'d, Dm, T> where - M: Mode, + Dm: Mode, T: Instance, { fn driver(&self) -> &'static Info { @@ -1173,17 +1173,17 @@ mod dma { self, dma_rx_buf: DmaRxBuf, dma_tx_buf: DmaTxBuf, - ) -> SpiDmaBus<'d, M, T> { + ) -> SpiDmaBus<'d, Dm, T> { SpiDmaBus::new(self, dma_rx_buf, dma_tx_buf) } } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] - impl SetConfig for SpiDma<'_, M, T> + impl SetConfig for SpiDma<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Config = Config; type ConfigError = ConfigError; @@ -1197,21 +1197,21 @@ mod dma { /// /// This structure holds references to the SPI instance, DMA buffers, and /// transfer status. - pub struct SpiDmaTransfer<'d, M, Buf, T = AnySpi> + pub struct SpiDmaTransfer<'d, Dm, Buf, T = AnySpi> where T: Instance, - M: Mode, + Dm: Mode, { - spi_dma: ManuallyDrop>, + spi_dma: ManuallyDrop>, dma_buf: ManuallyDrop, } - impl<'d, M, T, Buf> SpiDmaTransfer<'d, M, Buf, T> + impl<'d, Dm, T, Buf> SpiDmaTransfer<'d, Dm, Buf, T> where T: Instance, - M: Mode, + Dm: Mode, { - fn new(spi_dma: SpiDma<'d, M, T>, dma_buf: Buf) -> Self { + fn new(spi_dma: SpiDma<'d, Dm, T>, dma_buf: Buf) -> Self { Self { spi_dma: ManuallyDrop::new(spi_dma), dma_buf: ManuallyDrop::new(dma_buf), @@ -1230,7 +1230,7 @@ mod dma { /// /// This method blocks until the transfer is finished and returns the /// `SpiDma` instance and the associated buffer. - pub fn wait(mut self) -> (SpiDma<'d, M, T>, Buf) { + pub fn wait(mut self) -> (SpiDma<'d, Dm, T>, Buf) { self.spi_dma.wait_for_idle(); let retval = unsafe { ( @@ -1250,10 +1250,10 @@ mod dma { } } - impl Drop for SpiDmaTransfer<'_, M, Buf, T> + impl Drop for SpiDmaTransfer<'_, Dm, Buf, T> where T: Instance, - M: Mode, + Dm: Mode, { fn drop(&mut self) { if !self.is_done() { @@ -1280,10 +1280,10 @@ mod dma { } } - impl<'d, M, T> SpiDma<'d, M, T> + impl<'d, Dm, T> SpiDma<'d, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { /// # Safety: /// @@ -1309,7 +1309,7 @@ mod dma { mut self, bytes_to_write: usize, mut buffer: TX, - ) -> Result, (Error, Self, TX)> { + ) -> Result, (Error, Self, TX)> { self.wait_for_idle(); match unsafe { self.start_dma_write(bytes_to_write, &mut buffer) } { @@ -1342,7 +1342,7 @@ mod dma { mut self, bytes_to_read: usize, mut buffer: RX, - ) -> Result, (Error, Self, RX)> { + ) -> Result, (Error, Self, RX)> { self.wait_for_idle(); match unsafe { self.start_dma_read(bytes_to_read, &mut buffer) } { Ok(_) => Ok(SpiDmaTransfer::new(self, buffer)), @@ -1378,7 +1378,7 @@ mod dma { mut rx_buffer: RX, bytes_to_write: usize, mut tx_buffer: TX, - ) -> Result, (Error, Self, RX, TX)> { + ) -> Result, (Error, Self, RX, TX)> { self.wait_for_idle(); match unsafe { self.start_dma_transfer( @@ -1431,7 +1431,7 @@ mod dma { dummy: u8, bytes_to_read: usize, mut buffer: RX, - ) -> Result, (Error, Self, RX)> { + ) -> Result, (Error, Self, RX)> { self.wait_for_idle(); match unsafe { @@ -1496,7 +1496,7 @@ mod dma { dummy: u8, bytes_to_write: usize, mut buffer: TX, - ) -> Result, (Error, Self, TX)> { + ) -> Result, (Error, Self, TX)> { self.wait_for_idle(); match unsafe { @@ -1519,21 +1519,21 @@ mod dma { /// /// This structure is responsible for managing SPI transfers using DMA /// buffers. - pub struct SpiDmaBus<'d, M, T = AnySpi> + pub struct SpiDmaBus<'d, Dm, T = AnySpi> where T: Instance, - M: Mode, + Dm: Mode, { - spi_dma: SpiDma<'d, M, T>, + spi_dma: SpiDma<'d, Dm, T>, rx_buf: DmaRxBuf, tx_buf: DmaTxBuf, } - impl crate::private::Sealed for SpiDmaBus<'_, M, T> + impl crate::private::Sealed for SpiDmaBus<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { } @@ -1565,14 +1565,14 @@ mod dma { } } - impl<'d, M, T> SpiDmaBus<'d, M, T> + impl<'d, Dm, T> SpiDmaBus<'d, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { /// Creates a new `SpiDmaBus` with the specified SPI instance and DMA /// buffers. - pub fn new(spi_dma: SpiDma<'d, M, T>, rx_buf: DmaRxBuf, tx_buf: DmaTxBuf) -> Self { + pub fn new(spi_dma: SpiDma<'d, Dm, T>, rx_buf: DmaRxBuf, tx_buf: DmaTxBuf) -> Self { Self { spi_dma, rx_buf, @@ -1619,10 +1619,10 @@ mod dma { } } - impl SpiDmaBus<'_, M, T> + impl SpiDmaBus<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn wait_for_idle(&mut self) { self.spi_dma.wait_for_idle(); @@ -1811,10 +1811,10 @@ mod dma { #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] - impl SetConfig for SpiDmaBus<'_, M, T> + impl SetConfig for SpiDmaBus<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Config = Config; type ConfigError = ConfigError; @@ -2031,18 +2031,18 @@ mod dma { use super::*; - impl ErrorType for SpiDmaBus<'_, M, T> + impl ErrorType for SpiDmaBus<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Error = Error; } - impl SpiBus for SpiDmaBus<'_, M, T> + impl SpiBus for SpiDmaBus<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { self.read(words) @@ -2074,11 +2074,11 @@ mod ehal1 { use super::*; - impl embedded_hal::spi::ErrorType for Spi<'_, M, T> { + impl embedded_hal::spi::ErrorType for Spi<'_, Dm, T> { type Error = Error; } - impl FullDuplex for Spi<'_, M, T> + impl FullDuplex for Spi<'_, Dm, T> where T: Instance, { @@ -2091,7 +2091,7 @@ mod ehal1 { } } - impl SpiBus for Spi<'_, M, T> + impl SpiBus for Spi<'_, Dm, T> where T: Instance, { diff --git a/esp-hal/src/spi/slave.rs b/esp-hal/src/spi/slave.rs index db7c7314d6c..b3e42444d07 100644 --- a/esp-hal/src/spi/slave.rs +++ b/esp-hal/src/spi/slave.rs @@ -91,11 +91,11 @@ const MAX_DMA_SIZE: usize = 32768 - 32; /// SPI peripheral driver. /// /// See the [module-level documentation][self] for more details. -pub struct Spi<'d, M, T = AnySpi> { +pub struct Spi<'d, Dm, T = AnySpi> { spi: PeripheralRef<'d, T>, #[allow(dead_code)] data_mode: SpiMode, - _mode: PhantomData, + _mode: PhantomData, _guard: PeripheralGuard, } @@ -106,12 +106,12 @@ impl<'d> Spi<'d, Blocking> { } } -impl<'d, M, T> Spi<'d, M, T> +impl<'d, Dm, T> Spi<'d, Dm, T> where T: Instance, { /// Constructs an SPI instance in 8bit dataframe mode. - pub fn new_typed(spi: impl Peripheral

+ 'd, mode: SpiMode) -> Spi<'d, M, T> { + pub fn new_typed(spi: impl Peripheral

+ 'd, mode: SpiMode) -> Spi<'d, Dm, T> { crate::into_ref!(spi); let guard = PeripheralGuard::new(spi.info().peripheral); @@ -218,32 +218,32 @@ pub mod dma { } /// A DMA capable SPI instance. - pub struct SpiDma<'d, M, T = AnySpi> + pub struct SpiDma<'d, Dm, T = AnySpi> where T: InstanceDma, - M: Mode, + Dm: Mode, { pub(crate) spi: PeripheralRef<'d, T>, - pub(crate) channel: Channel<'d, M, PeripheralDmaChannel>, + pub(crate) channel: Channel<'d, Dm, PeripheralDmaChannel>, rx_chain: DescriptorChain, tx_chain: DescriptorChain, _guard: PeripheralGuard, } - impl core::fmt::Debug for SpiDma<'_, DmaMode, T> + impl core::fmt::Debug for SpiDma<'_, Dm, T> where T: InstanceDma, - DmaMode: Mode, + Dm: Mode, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("SpiDma").finish() } } - impl DmaSupport for SpiDma<'_, DmaMode, T> + impl DmaSupport for SpiDma<'_, Dm, T> where T: InstanceDma, - DmaMode: Mode, + Dm: Mode, { fn peripheral_wait_dma(&mut self, is_rx: bool, is_tx: bool) { while !((!is_tx || self.channel.tx.is_done()) @@ -259,12 +259,12 @@ pub mod dma { } } - impl<'d, DmaMode, T> DmaSupportTx for SpiDma<'d, DmaMode, T> + impl<'d, Dm, T> DmaSupportTx for SpiDma<'d, Dm, T> where T: InstanceDma, - DmaMode: Mode, + Dm: Mode, { - type TX = ChannelTx<'d, DmaMode, PeripheralTxChannel>; + type TX = ChannelTx<'d, Dm, PeripheralTxChannel>; fn tx(&mut self) -> &mut Self::TX { &mut self.channel.tx @@ -275,12 +275,12 @@ pub mod dma { } } - impl<'d, DmaMode, T> DmaSupportRx for SpiDma<'d, DmaMode, T> + impl<'d, Dm, T> DmaSupportRx for SpiDma<'d, Dm, T> where T: InstanceDma, - DmaMode: Mode, + Dm: Mode, { - type RX = ChannelRx<'d, DmaMode, PeripheralRxChannel>; + type RX = ChannelRx<'d, Dm, PeripheralRxChannel>; fn rx(&mut self) -> &mut Self::RX { &mut self.channel.rx @@ -315,9 +315,9 @@ pub mod dma { } } - impl SpiDma<'_, M, T> + impl SpiDma<'_, Dm, T> where - M: Mode, + Dm: Mode, T: InstanceDma, { fn driver(&self) -> DmaDriver { diff --git a/esp-hal/src/timer/mod.rs b/esp-hal/src/timer/mod.rs index 481bcd3d382..cc2732ddfa8 100644 --- a/esp-hal/src/timer/mod.rs +++ b/esp-hal/src/timer/mod.rs @@ -119,9 +119,9 @@ pub trait Timer: Into + InterruptConfigurable + 'static + crate::priva } /// A one-shot timer. -pub struct OneShotTimer<'d, M, T = AnyTimer> { +pub struct OneShotTimer<'d, Dm, T = AnyTimer> { inner: PeripheralRef<'d, T>, - _ph: PhantomData, + _ph: PhantomData, } impl<'d> OneShotTimer<'d, Blocking> { @@ -197,9 +197,9 @@ where } } -impl OneShotTimer<'_, M, T> +impl OneShotTimer<'_, Dm, T> where - M: Mode, + Dm: Mode, T: Timer, { /// Delay for *at least* `ms` milliseconds. @@ -267,16 +267,16 @@ where } } -impl crate::private::Sealed for OneShotTimer<'_, M, T> +impl crate::private::Sealed for OneShotTimer<'_, Dm, T> where T: Timer, - M: Mode, + Dm: Mode, { } -impl InterruptConfigurable for OneShotTimer<'_, M, T> +impl InterruptConfigurable for OneShotTimer<'_, Dm, T> where - M: Mode, + Dm: Mode, T: Timer, { fn set_interrupt_handler(&mut self, handler: crate::interrupt::InterruptHandler) { @@ -303,9 +303,9 @@ where } /// A periodic timer. -pub struct PeriodicTimer<'d, M, T = AnyTimer> { +pub struct PeriodicTimer<'d, Dm, T = AnyTimer> { inner: PeripheralRef<'d, T>, - _ph: PhantomData, + _ph: PhantomData, } impl<'d> PeriodicTimer<'d, Blocking> { @@ -329,9 +329,9 @@ where } } -impl PeriodicTimer<'_, M, T> +impl PeriodicTimer<'_, Dm, T> where - M: Mode, + Dm: Mode, T: Timer, { /// Start a new count down. @@ -390,11 +390,11 @@ where } } -impl crate::private::Sealed for PeriodicTimer<'_, M, T> where T: Timer {} +impl crate::private::Sealed for PeriodicTimer<'_, Dm, T> where T: Timer {} -impl InterruptConfigurable for PeriodicTimer<'_, M, T> +impl InterruptConfigurable for PeriodicTimer<'_, Dm, T> where - M: Mode, + Dm: Mode, T: Timer, { fn set_interrupt_handler(&mut self, handler: crate::interrupt::InterruptHandler) { diff --git a/esp-hal/src/touch.rs b/esp-hal/src/touch.rs index 35825953206..81f6190ab66 100644 --- a/esp-hal/src/touch.rs +++ b/esp-hal/src/touch.rs @@ -85,12 +85,12 @@ pub struct TouchConfig { } /// This struct marks a successfully initialized touch peripheral -pub struct Touch<'d, TOUCHMODE: TouchMode, MODE: Mode> { +pub struct Touch<'d, TOUCHMODE: TouchMode, Dm: Mode> { _inner: PeripheralRef<'d, TOUCH>, _touch_mode: PhantomData, - _mode: PhantomData, + _mode: PhantomData, } -impl Touch<'_, TOUCHMODE, MODE> { +impl Touch<'_, TOUCHMODE, Dm> { /// Common initialization of the touch peripheral. fn initialize_common(config: Option) { let rtccntl = unsafe { &*RTC_CNTL::ptr() }; @@ -318,10 +318,10 @@ impl<'d> Touch<'d, Continuous, Async> { } /// A pin that is configured as a TouchPad. -pub struct TouchPad { +pub struct TouchPad { pin: P, _touch_mode: PhantomData, - _mode: PhantomData, + _mode: PhantomData, } impl TouchPad { /// (Re-)Start a touch measurement on the pin. You can get the result by @@ -362,13 +362,13 @@ impl TouchPad { .modify(|_, w| w.touch_start_en().set_bit()); } } -impl TouchPad { +impl TouchPad { /// Construct a new instance of [`TouchPad`]. /// /// ## Parameters: /// - `pin`: The pin that gets configured as touch pad /// - `touch`: The [`Touch`] struct indicating that touch is configured. - pub fn new(pin: P, _touch: &Touch<'_, TOUCHMODE, MODE>) -> Self { + pub fn new(pin: P, _touch: &Touch<'_, TOUCHMODE, Dm>) -> Self { // TODO revert this on drop pin.set_touch(Internal); diff --git a/esp-hal/src/uart.rs b/esp-hal/src/uart.rs index a727745b613..546f0448ec1 100644 --- a/esp-hal/src/uart.rs +++ b/esp-hal/src/uart.rs @@ -537,15 +537,15 @@ impl AtCmdConfig { } } -struct UartBuilder<'d, M, T = AnyUart> { +struct UartBuilder<'d, Dm, T = AnyUart> { uart: PeripheralRef<'d, T>, - phantom: PhantomData, + phantom: PhantomData, } -impl<'d, M, T> UartBuilder<'d, M, T> +impl<'d, Dm, T> UartBuilder<'d, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn new(uart: impl Peripheral

+ 'd) -> Self { crate::into_ref!(uart); @@ -573,7 +573,7 @@ where self } - fn init(self, config: Config) -> Result, ConfigError> { + fn init(self, config: Config) -> Result, ConfigError> { let rx_guard = PeripheralGuard::new(self.uart.parts().0.peripheral); let tx_guard = PeripheralGuard::new(self.uart.parts().0.peripheral); @@ -596,22 +596,22 @@ where } /// UART (Full-duplex) -pub struct Uart<'d, M, T = AnyUart> { - rx: UartRx<'d, M, T>, - tx: UartTx<'d, M, T>, +pub struct Uart<'d, Dm, T = AnyUart> { + rx: UartRx<'d, Dm, T>, + tx: UartTx<'d, Dm, T>, } /// UART (Transmit) -pub struct UartTx<'d, M, T = AnyUart> { +pub struct UartTx<'d, Dm, T = AnyUart> { uart: PeripheralRef<'d, T>, - phantom: PhantomData, + phantom: PhantomData, guard: PeripheralGuard, } /// UART (Receive) -pub struct UartRx<'d, M, T = AnyUart> { +pub struct UartRx<'d, Dm, T = AnyUart> { uart: PeripheralRef<'d, T>, - phantom: PhantomData, + phantom: PhantomData, guard: PeripheralGuard, } @@ -627,10 +627,10 @@ pub enum ConfigError { #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl SetConfig for Uart<'_, M, T> +impl SetConfig for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Config = Config; type ConfigError = ConfigError; @@ -642,10 +642,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl SetConfig for UartRx<'_, M, T> +impl SetConfig for UartRx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Config = Config; type ConfigError = ConfigError; @@ -657,10 +657,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl SetConfig for UartTx<'_, M, T> +impl SetConfig for UartTx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Config = Config; type ConfigError = ConfigError; @@ -670,10 +670,10 @@ where } } -impl<'d, M, T> UartTx<'d, M, T> +impl<'d, Dm, T> UartTx<'d, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { /// Configure RTS pin pub fn with_rts(self, rts: impl Peripheral

+ 'd) -> Self { @@ -861,10 +861,10 @@ fn sync_regs(_register_block: &RegisterBlock) { } } -impl<'d, M, T> UartRx<'d, M, T> +impl<'d, Dm, T> UartRx<'d, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { /// Configure CTS pin pub fn with_cts(self, cts: impl Peripheral

+ 'd) -> Self { @@ -1142,10 +1142,10 @@ pub enum UartInterrupt { RxFifoFull, } -impl<'d, M, T> Uart<'d, M, T> +impl<'d, Dm, T> Uart<'d, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { /// Configure CTS pin pub fn with_cts(mut self, cts: impl Peripheral

+ 'd) -> Self { @@ -1168,7 +1168,7 @@ where /// /// This is particularly useful when having two tasks correlating to /// transmitting and receiving. - pub fn split(self) -> (UartRx<'d, M, T>, UartTx<'d, M, T>) { + pub fn split(self) -> (UartRx<'d, Dm, T>, UartTx<'d, Dm, T>) { (self.rx, self.tx) } @@ -1353,10 +1353,10 @@ where } } -impl ufmt_write::uWrite for Uart<'_, M, T> +impl ufmt_write::uWrite for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Error = Error; @@ -1371,10 +1371,10 @@ where } } -impl ufmt_write::uWrite for UartTx<'_, M, T> +impl ufmt_write::uWrite for UartTx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { type Error = Error; @@ -1385,10 +1385,10 @@ where } } -impl core::fmt::Write for Uart<'_, M, T> +impl core::fmt::Write for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { #[inline] fn write_str(&mut self, s: &str) -> core::fmt::Result { @@ -1396,10 +1396,10 @@ where } } -impl core::fmt::Write for UartTx<'_, M, T> +impl core::fmt::Write for UartTx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { #[inline] fn write_str(&mut self, s: &str) -> core::fmt::Result { @@ -1409,42 +1409,42 @@ where } } -impl embedded_hal_nb::serial::ErrorType for Uart<'_, M, T> { +impl embedded_hal_nb::serial::ErrorType for Uart<'_, Dm, T> { type Error = Error; } -impl embedded_hal_nb::serial::ErrorType for UartTx<'_, M, T> { +impl embedded_hal_nb::serial::ErrorType for UartTx<'_, Dm, T> { type Error = Error; } -impl embedded_hal_nb::serial::ErrorType for UartRx<'_, M, T> { +impl embedded_hal_nb::serial::ErrorType for UartRx<'_, Dm, T> { type Error = Error; } -impl embedded_hal_nb::serial::Read for Uart<'_, M, T> +impl embedded_hal_nb::serial::Read for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read(&mut self) -> nb::Result { self.read_byte() } } -impl embedded_hal_nb::serial::Read for UartRx<'_, M, T> +impl embedded_hal_nb::serial::Read for UartRx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read(&mut self) -> nb::Result { self.read_byte() } } -impl embedded_hal_nb::serial::Write for Uart<'_, M, T> +impl embedded_hal_nb::serial::Write for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { self.write_byte(word) @@ -1455,10 +1455,10 @@ where } } -impl embedded_hal_nb::serial::Write for UartTx<'_, M, T> +impl embedded_hal_nb::serial::Write for UartTx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { self.write_byte(word) @@ -1471,28 +1471,28 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ErrorType for Uart<'_, M, T> { +impl embedded_io::ErrorType for Uart<'_, Dm, T> { type Error = Error; } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ErrorType for UartTx<'_, M, T> { +impl embedded_io::ErrorType for UartTx<'_, Dm, T> { type Error = Error; } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ErrorType for UartRx<'_, M, T> { +impl embedded_io::ErrorType for UartRx<'_, Dm, T> { type Error = Error; } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Read for Uart<'_, M, T> +impl embedded_io::Read for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read(&mut self, buf: &mut [u8]) -> Result { self.rx.read(buf) @@ -1501,10 +1501,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Read for UartRx<'_, M, T> +impl embedded_io::Read for UartRx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read(&mut self, buf: &mut [u8]) -> Result { if buf.is_empty() { @@ -1521,10 +1521,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ReadReady for Uart<'_, M, T> +impl embedded_io::ReadReady for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read_ready(&mut self) -> Result { self.rx.read_ready() @@ -1533,10 +1533,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ReadReady for UartRx<'_, M, T> +impl embedded_io::ReadReady for UartRx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn read_ready(&mut self) -> Result { Ok(self.rx_fifo_count() > 0) @@ -1545,10 +1545,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Write for Uart<'_, M, T> +impl embedded_io::Write for Uart<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn write(&mut self, buf: &[u8]) -> Result { self.tx.write(buf) @@ -1561,10 +1561,10 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Write for UartTx<'_, M, T> +impl embedded_io::Write for UartTx<'_, Dm, T> where T: Instance, - M: Mode, + Dm: Mode, { fn write(&mut self, buf: &[u8]) -> Result { self.write_bytes(buf) diff --git a/esp-hal/src/usb_serial_jtag.rs b/esp-hal/src/usb_serial_jtag.rs index 15ba69dfde0..afa7a1bac91 100644 --- a/esp-hal/src/usb_serial_jtag.rs +++ b/esp-hal/src/usb_serial_jtag.rs @@ -149,26 +149,26 @@ use crate::{ type Error = Infallible; /// USB Serial/JTAG (Full-duplex) -pub struct UsbSerialJtag<'d, M> { - rx: UsbSerialJtagRx<'d, M>, - tx: UsbSerialJtagTx<'d, M>, +pub struct UsbSerialJtag<'d, Dm> { + rx: UsbSerialJtagRx<'d, Dm>, + tx: UsbSerialJtagTx<'d, Dm>, } /// USB Serial/JTAG (Transmit) -pub struct UsbSerialJtagTx<'d, M> { +pub struct UsbSerialJtagTx<'d, Dm> { peripheral: PeripheralRef<'d, USB_DEVICE>, - phantom: PhantomData, + phantom: PhantomData, } /// USB Serial/JTAG (Receive) -pub struct UsbSerialJtagRx<'d, M> { +pub struct UsbSerialJtagRx<'d, Dm> { peripheral: PeripheralRef<'d, USB_DEVICE>, - phantom: PhantomData, + phantom: PhantomData, } -impl<'d, M> UsbSerialJtagTx<'d, M> +impl<'d, Dm> UsbSerialJtagTx<'d, Dm> where - M: Mode, + Dm: Mode, { fn new_inner(peripheral: impl Peripheral

+ 'd) -> Self { crate::into_ref!(peripheral); @@ -245,9 +245,9 @@ where } } -impl<'d, M> UsbSerialJtagRx<'d, M> +impl<'d, Dm> UsbSerialJtagRx<'d, Dm> where - M: Mode, + Dm: Mode, { fn new_inner(peripheral: impl Peripheral

+ 'd) -> Self { crate::into_ref!(peripheral); @@ -361,9 +361,9 @@ impl InterruptConfigurable for UsbSerialJtag<'_, Blocking> { } } -impl<'d, M> UsbSerialJtag<'d, M> +impl<'d, Dm> UsbSerialJtag<'d, Dm> where - M: Mode, + Dm: Mode, { fn new_inner(usb_device: impl Peripheral

+ 'd) -> Self { // Do NOT reset the peripheral. Doing so will result in a broken USB JTAG @@ -398,7 +398,7 @@ where /// Split the USB Serial JTAG peripheral into a transmitter and receiver, /// which is particularly useful when having two tasks correlating to /// transmitting and receiving. - pub fn split(self) -> (UsbSerialJtagRx<'d, M>, UsbSerialJtagTx<'d, M>) { + pub fn split(self) -> (UsbSerialJtagRx<'d, Dm>, UsbSerialJtagTx<'d, Dm>) { (self.rx, self.tx) } @@ -484,18 +484,18 @@ impl Instance for USB_DEVICE { } } -impl core::fmt::Write for UsbSerialJtag<'_, M> +impl core::fmt::Write for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { fn write_str(&mut self, s: &str) -> core::fmt::Result { core::fmt::Write::write_str(&mut self.tx, s) } } -impl core::fmt::Write for UsbSerialJtagTx<'_, M> +impl core::fmt::Write for UsbSerialJtagTx<'_, Dm> where - M: Mode, + Dm: Mode, { fn write_str(&mut self, s: &str) -> core::fmt::Result { self.write_bytes(s.as_bytes()) @@ -504,9 +504,9 @@ where } } -impl ufmt_write::uWrite for UsbSerialJtag<'_, M> +impl ufmt_write::uWrite for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; @@ -521,9 +521,9 @@ where } } -impl ufmt_write::uWrite for UsbSerialJtagTx<'_, M> +impl ufmt_write::uWrite for UsbSerialJtagTx<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; @@ -542,48 +542,48 @@ where } } -impl embedded_hal_nb::serial::ErrorType for UsbSerialJtag<'_, M> +impl embedded_hal_nb::serial::ErrorType for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; } -impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagTx<'_, M> +impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagTx<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; } -impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagRx<'_, M> +impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagRx<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; } -impl embedded_hal_nb::serial::Read for UsbSerialJtag<'_, M> +impl embedded_hal_nb::serial::Read for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { fn read(&mut self) -> nb::Result { embedded_hal_nb::serial::Read::read(&mut self.rx) } } -impl embedded_hal_nb::serial::Read for UsbSerialJtagRx<'_, M> +impl embedded_hal_nb::serial::Read for UsbSerialJtagRx<'_, Dm> where - M: Mode, + Dm: Mode, { fn read(&mut self) -> nb::Result { self.read_byte() } } -impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_, M> +impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { embedded_hal_nb::serial::Write::write(&mut self.tx, word) @@ -594,9 +594,9 @@ where } } -impl embedded_hal_nb::serial::Write for UsbSerialJtagTx<'_, M> +impl embedded_hal_nb::serial::Write for UsbSerialJtagTx<'_, Dm> where - M: Mode, + Dm: Mode, { fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> { self.write_byte_nb(word) @@ -609,36 +609,36 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ErrorType for UsbSerialJtag<'_, M> +impl embedded_io::ErrorType for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ErrorType for UsbSerialJtagTx<'_, M> +impl embedded_io::ErrorType for UsbSerialJtagTx<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::ErrorType for UsbSerialJtagRx<'_, M> +impl embedded_io::ErrorType for UsbSerialJtagRx<'_, Dm> where - M: Mode, + Dm: Mode, { type Error = Error; } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Read for UsbSerialJtag<'_, M> +impl embedded_io::Read for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { fn read(&mut self, buf: &mut [u8]) -> Result { embedded_io::Read::read(&mut self.rx, buf) @@ -647,9 +647,9 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Read for UsbSerialJtagRx<'_, M> +impl embedded_io::Read for UsbSerialJtagRx<'_, Dm> where - M: Mode, + Dm: Mode, { fn read(&mut self, buf: &mut [u8]) -> Result { loop { @@ -663,9 +663,9 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Write for UsbSerialJtag<'_, M> +impl embedded_io::Write for UsbSerialJtag<'_, Dm> where - M: Mode, + Dm: Mode, { fn write(&mut self, buf: &[u8]) -> Result { embedded_io::Write::write(&mut self.tx, buf) @@ -678,9 +678,9 @@ where #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl embedded_io::Write for UsbSerialJtagTx<'_, M> +impl embedded_io::Write for UsbSerialJtagTx<'_, Dm> where - M: Mode, + Dm: Mode, { fn write(&mut self, buf: &[u8]) -> Result { self.write_bytes(buf)?; diff --git a/esp-wifi/src/wifi/mod.rs b/esp-wifi/src/wifi/mod.rs index fa931bc8525..4ce2cba5924 100644 --- a/esp-wifi/src/wifi/mod.rs +++ b/esp-wifi/src/wifi/mod.rs @@ -1789,16 +1789,16 @@ pub(crate) fn wifi_start_scan( /// [`Configuration::Client`] or [`Configuration::AccessPoint`]. /// /// If you want to use AP-STA mode, use `[new_ap_sta]`. -pub fn new_with_config<'d, MODE: WifiDeviceMode>( +pub fn new_with_config<'d, Dm: WifiDeviceMode>( inited: &'d EspWifiController<'d>, device: impl Peripheral

+ 'd, - config: MODE::Config, -) -> Result<(WifiDevice<'d, MODE>, WifiController<'d>), WifiError> { + config: Dm::Config, +) -> Result<(WifiDevice<'d, Dm>, WifiController<'d>), WifiError> { crate::hal::into_ref!(device); Ok(( - WifiDevice::new(unsafe { device.clone_unchecked() }, MODE::new()), - WifiController::new_with_config(inited, device, MODE::wrap_config(config))?, + WifiDevice::new(unsafe { device.clone_unchecked() }, Dm::new()), + WifiController::new_with_config(inited, device, Dm::wrap_config(config))?, )) } @@ -1807,12 +1807,12 @@ pub fn new_with_config<'d, MODE: WifiDeviceMode>( /// /// This function will panic if the mode is [`WifiMode::ApSta`]. /// If you want to use AP-STA mode, use `[new_ap_sta]`. -pub fn new_with_mode<'d, MODE: WifiDeviceMode>( +pub fn new_with_mode<'d, Dm: WifiDeviceMode>( inited: &'d EspWifiController<'d>, device: impl Peripheral

+ 'd, - _mode: MODE, -) -> Result<(WifiDevice<'d, MODE>, WifiController<'d>), WifiError> { - new_with_config(inited, device, ::Config::default()) + _mode: Dm, +) -> Result<(WifiDevice<'d, Dm>, WifiController<'d>), WifiError> { + new_with_config(inited, device, ::Config::default()) } /// Creates a new [WifiDevice] and [WifiController] in AP-STA mode, with a @@ -2071,15 +2071,15 @@ impl WifiDeviceMode for WifiApDevice { } /// A wifi device implementing smoltcp's Device trait. -pub struct WifiDevice<'d, MODE: WifiDeviceMode> { +pub struct WifiDevice<'d, Dm: WifiDeviceMode> { _device: PeripheralRef<'d, crate::hal::peripherals::WIFI>, - mode: MODE, + mode: Dm, } -impl<'d, MODE: WifiDeviceMode> WifiDevice<'d, MODE> { +impl<'d, Dm: WifiDeviceMode> WifiDevice<'d, Dm> { pub(crate) fn new( _device: PeripheralRef<'d, crate::hal::peripherals::WIFI>, - mode: MODE, + mode: Dm, ) -> Self { Self { _device, mode } } @@ -2092,14 +2092,14 @@ impl<'d, MODE: WifiDeviceMode> WifiDevice<'d, MODE> { /// Receives data from the Wi-Fi device (only when `smoltcp` feature is /// disabled). #[cfg(not(feature = "smoltcp"))] - pub fn receive(&mut self) -> Option<(WifiRxToken, WifiTxToken)> { + pub fn receive(&mut self) -> Option<(WifiRxToken, WifiTxToken)> { self.mode.rx_token() } /// Transmits data through the Wi-Fi device (only when `smoltcp` feature is /// disabled). #[cfg(not(feature = "smoltcp"))] - pub fn transmit(&mut self) -> Option> { + pub fn transmit(&mut self) -> Option> { self.mode.tx_token() } } @@ -2619,13 +2619,13 @@ impl<'d> WifiController<'d> { // see https://docs.rs/smoltcp/0.7.1/smoltcp/phy/index.html #[cfg(feature = "smoltcp")] -impl Device for WifiDevice<'_, MODE> { +impl Device for WifiDevice<'_, Dm> { type RxToken<'a> - = WifiRxToken + = WifiRxToken where Self: 'a; type TxToken<'a> - = WifiTxToken + = WifiTxToken where Self: 'a; @@ -2654,11 +2654,11 @@ impl Device for WifiDevice<'_, MODE> { #[doc(hidden)] #[derive(Debug)] -pub struct WifiRxToken { - mode: MODE, +pub struct WifiRxToken { + mode: Dm, } -impl WifiRxToken { +impl WifiRxToken { /// Consumes the RX token and applies the callback function to the received /// data buffer. pub fn consume_token(self, f: F) -> R @@ -2686,7 +2686,7 @@ impl WifiRxToken { } #[cfg(feature = "smoltcp")] -impl RxToken for WifiRxToken { +impl RxToken for WifiRxToken { fn consume(self, f: F) -> R where F: FnOnce(&mut [u8]) -> R, @@ -2697,11 +2697,11 @@ impl RxToken for WifiRxToken { #[doc(hidden)] #[derive(Debug)] -pub struct WifiTxToken { - mode: MODE, +pub struct WifiTxToken { + mode: Dm, } -impl WifiTxToken { +impl WifiTxToken { /// Consumes the TX token and applies the callback function to the received /// data buffer. pub fn consume_token(self, len: usize, f: F) -> R @@ -2726,7 +2726,7 @@ impl WifiTxToken { } #[cfg(feature = "smoltcp")] -impl TxToken for WifiTxToken { +impl TxToken for WifiTxToken { fn consume(self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R, @@ -3124,7 +3124,7 @@ pub(crate) mod embassy { pub(crate) static STA_RECEIVE_WAKER: AtomicWaker = AtomicWaker::new(); pub(crate) static STA_LINK_STATE_WAKER: AtomicWaker = AtomicWaker::new(); - impl RxToken for WifiRxToken { + impl RxToken for WifiRxToken { fn consume(self, f: F) -> R where F: FnOnce(&mut [u8]) -> R, @@ -3133,7 +3133,7 @@ pub(crate) mod embassy { } } - impl TxToken for WifiTxToken { + impl TxToken for WifiTxToken { fn consume(self, len: usize, f: F) -> R where F: FnOnce(&mut [u8]) -> R, @@ -3142,13 +3142,13 @@ pub(crate) mod embassy { } } - impl Driver for WifiDevice<'_, MODE> { + impl Driver for WifiDevice<'_, Dm> { type RxToken<'a> - = WifiRxToken + = WifiRxToken where Self: 'a; type TxToken<'a> - = WifiTxToken + = WifiTxToken where Self: 'a; diff --git a/esp-wifi/src/wifi/utils.rs b/esp-wifi/src/wifi/utils.rs index b7d8831bfd7..1cce24e5d09 100644 --- a/esp-wifi/src/wifi/utils.rs +++ b/esp-wifi/src/wifi/utils.rs @@ -16,7 +16,7 @@ fn timestamp() -> smoltcp::time::Instant { ) } -fn setup_iface(device: &mut WifiDevice<'_, MODE>, mode: MODE) -> Interface { +fn setup_iface(device: &mut WifiDevice<'_, Dm>, mode: Dm) -> Interface { let mac = mode.mac_address(); let hw_address = HardwareAddress::Ethernet(EthernetAddress::from_bytes(&mac)); @@ -26,11 +26,11 @@ fn setup_iface(device: &mut WifiDevice<'_, MODE>, mode: MO } /// Convenient way to create an `smoltcp` ethernet interface -pub fn create_network_interface<'d, MODE: WifiDeviceMode>( +pub fn create_network_interface<'d, Dm: WifiDeviceMode>( inited: &'d EspWifiController<'d>, device: impl crate::hal::peripheral::Peripheral

+ 'd, - mode: MODE, -) -> Result<(Interface, WifiDevice<'d, MODE>, WifiController<'d>), WifiError> { + mode: Dm, +) -> Result<(Interface, WifiDevice<'d, Dm>, WifiController<'d>), WifiError> { let (mut device, controller) = crate::wifi::new_with_mode(inited, device, mode)?; let iface = setup_iface(&mut device, mode);