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/i2c/master/mod.rs b/esp-hal/src/i2c/master/mod.rs index 1fedfcaeaf7..bcd88653a58 100644 --- a/esp-hal/src/i2c/master/mod.rs +++ b/esp-hal/src/i2c/master/mod.rs @@ -274,16 +274,16 @@ impl Default for Config { } /// I2C driver -pub struct I2c<'d, DM: Mode, T = AnyI2c> { +pub struct I2c<'d, Dm: Mode, T = AnyI2c> { i2c: PeripheralRef<'d, T>, - phantom: PhantomData, + phantom: PhantomData, config: Config, guard: PeripheralGuard, } #[cfg(any(doc, feature = "unstable"))] #[cfg_attr(docsrs, doc(cfg(feature = "unstable")))] -impl SetConfig for I2c<'_, DM, T> { +impl SetConfig for I2c<'_, Dm, T> { type Config = Config; type ConfigError = ConfigError; @@ -292,11 +292,11 @@ impl SetConfig for I2c<'_, DM, T> { } } -impl embedded_hal::i2c::ErrorType for I2c<'_, DM, T> { +impl embedded_hal::i2c::ErrorType for I2c<'_, Dm, T> { type Error = Error; } -impl embedded_hal::i2c::I2c for I2c<'_, DM, T> +impl embedded_hal::i2c::I2c for I2c<'_, Dm, T> where T: Instance, { @@ -310,7 +310,7 @@ where } } -impl<'d, T, DM: Mode> I2c<'d, DM, T> +impl<'d, T, Dm: Mode> I2c<'d, Dm, T> where T: Instance, { 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/i2s/parallel.rs b/esp-hal/src/i2s/parallel.rs index 030fcf38e78..7a1da93fa06 100644 --- a/esp-hal/src/i2s/parallel.rs +++ b/esp-hal/src/i2s/parallel.rs @@ -236,13 +236,13 @@ impl<'d> TxPins<'d> for TxEightBits<'d> { } /// I2S Parallel Interface -pub struct I2sParallel<'d, DM, I = AnyI2s> +pub struct I2sParallel<'d, Dm, I = AnyI2s> where - DM: Mode, + Dm: Mode, I: Instance, { instance: PeripheralRef<'d, I>, - tx_channel: ChannelTx<'d, DM, PeripheralTxChannel>, + tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel>, _guard: PeripheralGuard, } @@ -323,16 +323,16 @@ where } } -impl<'d, I, DM> I2sParallel<'d, DM, I> +impl<'d, I, Dm> I2sParallel<'d, Dm, I> where I: Instance, - DM: Mode, + Dm: Mode, { /// Write data to the I2S peripheral pub fn send( mut self, mut data: BUF, - ) -> Result, (DmaError, Self, BUF)> { + ) -> Result, (DmaError, Self, BUF)> { self.instance.tx_reset(); self.instance.tx_fifo_reset(); let result = unsafe { @@ -354,21 +354,21 @@ where /// Represents an ongoing (or potentially finished) transfer using the i2s /// parallel interface -pub struct I2sParallelTransfer<'d, BUF, DM, I = AnyI2s> +pub struct I2sParallelTransfer<'d, BUF, Dm, I = AnyI2s> where I: Instance, BUF: DmaTxBuffer, - DM: Mode, + Dm: Mode, { - i2s: ManuallyDrop>, + i2s: ManuallyDrop>, buf_view: ManuallyDrop, } -impl<'d, I, BUF, DM> I2sParallelTransfer<'d, BUF, DM, I> +impl<'d, I, BUF, Dm> I2sParallelTransfer<'d, BUF, Dm, I> where I: Instance, BUF: DmaTxBuffer, - DM: Mode, + Dm: Mode, { /// Returns true when [Self::wait] will not block. pub fn is_done(&self) -> bool { @@ -376,7 +376,7 @@ where } /// Wait for the transfer to finish - pub fn wait(mut self) -> (I2sParallel<'d, DM, I>, BUF) { + pub fn wait(mut self) -> (I2sParallel<'d, Dm, I>, BUF) { self.i2s.instance.tx_wait_done(); let i2s = unsafe { ManuallyDrop::take(&mut self.i2s) }; let view = unsafe { ManuallyDrop::take(&mut self.buf_view) }; @@ -401,11 +401,11 @@ where } } -impl Deref for I2sParallelTransfer<'_, BUF, DM, I> +impl Deref for I2sParallelTransfer<'_, BUF, Dm, I> where I: Instance, BUF: DmaTxBuffer, - DM: Mode, + Dm: Mode, { type Target = BUF::View; @@ -414,22 +414,22 @@ where } } -impl DerefMut for I2sParallelTransfer<'_, BUF, DM, I> +impl DerefMut for I2sParallelTransfer<'_, BUF, Dm, I> where I: Instance, BUF: DmaTxBuffer, - DM: Mode, + Dm: Mode, { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.buf_view } } -impl Drop for I2sParallelTransfer<'_, BUF, DM, I> +impl Drop for I2sParallelTransfer<'_, BUF, Dm, I> where I: Instance, BUF: DmaTxBuffer, - DM: Mode, + Dm: Mode, { fn drop(&mut self) { self.stop_peripherals(); diff --git a/esp-hal/src/lcd_cam/lcd/dpi.rs b/esp-hal/src/lcd_cam/lcd/dpi.rs index 7c43a54dccc..0b321f4da00 100644 --- a/esp-hal/src/lcd_cam/lcd/dpi.rs +++ b/esp-hal/src/lcd_cam/lcd/dpi.rs @@ -128,19 +128,19 @@ pub enum ConfigError { } /// Represents the RGB LCD interface. -pub struct Dpi<'d, DM: Mode> { +pub struct Dpi<'d, Dm: Mode> { lcd_cam: PeripheralRef<'d, LCD_CAM>, tx_channel: ChannelTx<'d, Blocking, PeripheralTxChannel>, - _mode: PhantomData, + _mode: PhantomData, } -impl<'d, DM> Dpi<'d, DM> +impl<'d, Dm> Dpi<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Create a new instance of the RGB/DPI driver. pub fn new( - lcd: Lcd<'d, DM>, + lcd: Lcd<'d, Dm>, channel: impl Peripheral

+ 'd, config: Config, ) -> Result @@ -548,7 +548,7 @@ where mut self, next_frame_en: bool, mut buf: TX, - ) -> Result, (DmaError, Self, TX)> { + ) -> Result, (DmaError, Self, TX)> { let result = unsafe { self.tx_channel .prepare_transfer(DmaPeripheral::LcdCam, &mut buf) @@ -587,12 +587,12 @@ where /// Represents an ongoing (or potentially finished) transfer using the RGB LCD /// interface -pub struct DpiTransfer<'d, BUF: DmaTxBuffer, DM: Mode> { - dpi: ManuallyDrop>, +pub struct DpiTransfer<'d, BUF: DmaTxBuffer, Dm: Mode> { + dpi: ManuallyDrop>, buffer_view: ManuallyDrop, } -impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> { +impl<'d, BUF: DmaTxBuffer, Dm: Mode> DpiTransfer<'d, BUF, Dm> { /// Returns true when [Self::wait] will not block. pub fn is_done(&self) -> bool { self.dpi @@ -604,7 +604,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> { } /// Stops this transfer on the spot and returns the peripheral and buffer. - pub fn stop(mut self) -> (Dpi<'d, DM>, BUF) { + pub fn stop(mut self) -> (Dpi<'d, Dm>, BUF) { self.stop_peripherals(); let (dpi, view) = self.release(); (dpi, BUF::from_view(view)) @@ -614,7 +614,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> { /// /// Note: If you specified `next_frame_en` as true in [Dpi::send], you're /// just waiting for a DMA error when you call this. - pub fn wait(mut self) -> (Result<(), DmaError>, Dpi<'d, DM>, BUF) { + pub fn wait(mut self) -> (Result<(), DmaError>, Dpi<'d, Dm>, BUF) { while !self.is_done() { core::hint::spin_loop(); } @@ -637,7 +637,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> { (result, dpi, BUF::from_view(view)) } - fn release(mut self) -> (Dpi<'d, DM>, BUF::View) { + fn release(mut self) -> (Dpi<'d, Dm>, BUF::View) { // SAFETY: Since forget is called on self, we know that self.dpi and // self.buffer_view won't be touched again. let result = unsafe { @@ -661,7 +661,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> DpiTransfer<'d, BUF, DM> { } } -impl Deref for DpiTransfer<'_, BUF, DM> { +impl Deref for DpiTransfer<'_, BUF, Dm> { type Target = BUF::View; fn deref(&self) -> &Self::Target { @@ -669,13 +669,13 @@ impl Deref for DpiTransfer<'_, BUF, DM> { } } -impl DerefMut for DpiTransfer<'_, BUF, DM> { +impl DerefMut for DpiTransfer<'_, BUF, Dm> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.buffer_view } } -impl Drop for DpiTransfer<'_, BUF, DM> { +impl Drop for DpiTransfer<'_, BUF, Dm> { fn drop(&mut self) { self.stop_peripherals(); diff --git a/esp-hal/src/lcd_cam/lcd/i8080.rs b/esp-hal/src/lcd_cam/lcd/i8080.rs index 2f351ca3993..86750b661d1 100644 --- a/esp-hal/src/lcd_cam/lcd/i8080.rs +++ b/esp-hal/src/lcd_cam/lcd/i8080.rs @@ -92,19 +92,19 @@ pub enum ConfigError { } /// Represents the I8080 LCD interface. -pub struct I8080<'d, DM: Mode> { +pub struct I8080<'d, Dm: Mode> { lcd_cam: PeripheralRef<'d, LCD_CAM>, tx_channel: ChannelTx<'d, Blocking, PeripheralTxChannel>, - _mode: PhantomData, + _mode: PhantomData, } -impl<'d, DM> I8080<'d, DM> +impl<'d, Dm> I8080<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Creates a new instance of the I8080 LCD interface. pub fn new( - lcd: Lcd<'d, DM>, + lcd: Lcd<'d, Dm>, channel: impl Peripheral

+ 'd, mut pins: P, config: Config, @@ -300,7 +300,7 @@ where cmd: impl Into>, dummy: u8, mut data: BUF, - ) -> Result, (DmaError, Self, BUF)> { + ) -> Result, (DmaError, Self, BUF)> { let cmd = cmd.into(); // Reset LCD control unit and Async Tx FIFO @@ -396,7 +396,7 @@ where } } -impl core::fmt::Debug for I8080<'_, DM> { +impl core::fmt::Debug for I8080<'_, Dm> { fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { f.debug_struct("I8080").finish() } @@ -404,12 +404,12 @@ impl core::fmt::Debug for I8080<'_, DM> { /// Represents an ongoing (or potentially finished) transfer using the I8080 LCD /// interface -pub struct I8080Transfer<'d, BUF: DmaTxBuffer, DM: Mode> { - i8080: ManuallyDrop>, +pub struct I8080Transfer<'d, BUF: DmaTxBuffer, Dm: Mode> { + i8080: ManuallyDrop>, buf_view: ManuallyDrop, } -impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> { +impl<'d, BUF: DmaTxBuffer, Dm: Mode> I8080Transfer<'d, BUF, Dm> { /// Returns true when [Self::wait] will not block. pub fn is_done(&self) -> bool { self.i8080 @@ -421,7 +421,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> { } /// Stops this transfer on the spot and returns the peripheral and buffer. - pub fn cancel(mut self) -> (I8080<'d, DM>, BUF) { + pub fn cancel(mut self) -> (I8080<'d, Dm>, BUF) { self.stop_peripherals(); let (_, i8080, buf) = self.wait(); (i8080, buf) @@ -431,7 +431,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> { /// /// Note: This also clears the transfer interrupt so it can be used in /// interrupt handlers to "handle" the interrupt. - pub fn wait(mut self) -> (Result<(), DmaError>, I8080<'d, DM>, BUF) { + pub fn wait(mut self) -> (Result<(), DmaError>, I8080<'d, Dm>, BUF) { while !self.is_done() {} // Clear "done" interrupt. @@ -470,7 +470,7 @@ impl<'d, BUF: DmaTxBuffer, DM: Mode> I8080Transfer<'d, BUF, DM> { } } -impl Deref for I8080Transfer<'_, BUF, DM> { +impl Deref for I8080Transfer<'_, BUF, Dm> { type Target = BUF::View; fn deref(&self) -> &Self::Target { @@ -478,7 +478,7 @@ impl Deref for I8080Transfer<'_, BUF, DM> { } } -impl DerefMut for I8080Transfer<'_, BUF, DM> { +impl DerefMut for I8080Transfer<'_, BUF, Dm> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.buf_view } @@ -523,7 +523,7 @@ impl<'d, BUF: DmaTxBuffer> I8080Transfer<'d, BUF, crate::Async> { } } -impl Drop for I8080Transfer<'_, BUF, DM> { +impl Drop for I8080Transfer<'_, BUF, Dm> { fn drop(&mut self) { self.stop_peripherals(); diff --git a/esp-hal/src/lcd_cam/lcd/mod.rs b/esp-hal/src/lcd_cam/lcd/mod.rs index 53ec894bcd2..97e7a5cdd20 100644 --- a/esp-hal/src/lcd_cam/lcd/mod.rs +++ b/esp-hal/src/lcd_cam/lcd/mod.rs @@ -17,12 +17,12 @@ pub mod dpi; pub mod i8080; /// Represents an LCD interface. -pub struct Lcd<'d, DM: crate::Mode> { +pub struct Lcd<'d, Dm: crate::Mode> { /// The `LCD_CAM` peripheral reference for managing the LCD functionality. pub(crate) lcd_cam: PeripheralRef<'d, LCD_CAM>, /// A marker for the mode of operation (blocking or asynchronous). - pub(crate) _mode: core::marker::PhantomData, + pub(crate) _mode: core::marker::PhantomData, pub(super) _guard: GenericPeripheralGuard<{ system::Peripheral::LcdCam as u8 }>, } diff --git a/esp-hal/src/lcd_cam/mod.rs b/esp-hal/src/lcd_cam/mod.rs index b6f9320dcbd..543750a0288 100644 --- a/esp-hal/src/lcd_cam/mod.rs +++ b/esp-hal/src/lcd_cam/mod.rs @@ -24,9 +24,9 @@ use crate::{ }; /// Represents a combined LCD and Camera interface. -pub struct LcdCam<'d, DM: crate::Mode> { +pub struct LcdCam<'d, Dm: crate::Mode> { /// The LCD interface. - pub lcd: Lcd<'d, DM>, + pub lcd: Lcd<'d, Dm>, /// The Camera interface. pub cam: Cam<'d>, } diff --git a/esp-hal/src/parl_io.rs b/esp-hal/src/parl_io.rs index d8660c8c244..3085bd18f15 100644 --- a/esp-hal/src/parl_io.rs +++ b/esp-hal/src/parl_io.rs @@ -844,9 +844,9 @@ impl ContainsValidSignalPin for RxEightBits<'_> {} #[cfg(esp32c6)] impl ContainsValidSignalPin for RxSixteenBits<'_> {} -impl<'d, DM> TxCreatorFullDuplex<'d, DM> +impl<'d, Dm> TxCreatorFullDuplex<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Configure TX to use the given pins and settings pub fn with_config( @@ -856,7 +856,7 @@ where idle_value: u16, sample_edge: SampleEdge, bit_order: BitPackOrder, - ) -> Result, Error> + ) -> Result, Error> where P: FullDuplex + TxPins + ConfigurePins, CP: TxClkPin, @@ -876,9 +876,9 @@ where } } -impl<'d, DM> TxCreator<'d, DM> +impl<'d, Dm> TxCreator<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Configure TX to use the given pins and settings pub fn with_config( @@ -888,7 +888,7 @@ where idle_value: u16, sample_edge: SampleEdge, bit_order: BitPackOrder, - ) -> Result, Error> + ) -> Result, Error> where P: TxPins + ConfigurePins, CP: TxClkPin, @@ -909,27 +909,27 @@ where } /// Parallel IO TX channel -pub struct ParlIoTx<'d, DM> +pub struct ParlIoTx<'d, Dm> where - DM: Mode, + Dm: Mode, { - tx_channel: ChannelTx<'d, DM, PeripheralTxChannel>, + tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel>, tx_chain: DescriptorChain, _guard: GenericPeripheralGuard<{ crate::system::Peripheral::ParlIo as u8 }>, } -impl core::fmt::Debug for ParlIoTx<'_, DM> +impl core::fmt::Debug for ParlIoTx<'_, Dm> where - DM: Mode, + Dm: Mode, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("ParlIoTx").finish() } } -impl<'d, DM> RxCreatorFullDuplex<'d, DM> +impl<'d, Dm> RxCreatorFullDuplex<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Configure RX to use the given pins and settings pub fn with_config( @@ -938,7 +938,7 @@ where clk_pin: &'d mut CP, bit_order: BitPackOrder, timeout_ticks: Option, - ) -> Result, Error> + ) -> Result, Error> where P: FullDuplex + RxPins + ConfigurePins, CP: RxClkPin, @@ -959,9 +959,9 @@ where } } -impl<'d, DM> RxCreator<'d, DM> +impl<'d, Dm> RxCreator<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Configure RX to use the given pins and settings pub fn with_config( @@ -970,7 +970,7 @@ where clk_pin: &'d mut CP, bit_order: BitPackOrder, timeout_ticks: Option, - ) -> Result, Error> + ) -> Result, Error> where P: RxPins + ConfigurePins, CP: RxClkPin, @@ -990,18 +990,18 @@ where } /// Parallel IO RX channel -pub struct ParlIoRx<'d, DM> +pub struct ParlIoRx<'d, Dm> where - DM: Mode, + Dm: Mode, { - rx_channel: ChannelRx<'d, DM, PeripheralRxChannel>, + rx_channel: ChannelRx<'d, Dm, PeripheralRxChannel>, rx_chain: DescriptorChain, _guard: GenericPeripheralGuard<{ crate::system::Peripheral::ParlIo as u8 }>, } -impl core::fmt::Debug for ParlIoRx<'_, DM> +impl core::fmt::Debug for ParlIoRx<'_, Dm> where - DM: Mode, + Dm: Mode, { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_struct("ParlIoTx").finish() @@ -1093,16 +1093,16 @@ fn internal_clear_interrupts(interrupts: EnumSet) { /// Parallel IO in full duplex mode /// /// Full duplex mode might limit the maximum possible bit width. -pub struct ParlIoFullDuplex<'d, DM> +pub struct ParlIoFullDuplex<'d, Dm> where - DM: Mode, + Dm: Mode, { /// The transmitter (TX) channel responsible for handling DMA transfers in /// the parallel I/O full-duplex operation. - pub tx: TxCreatorFullDuplex<'d, DM>, + pub tx: TxCreatorFullDuplex<'d, Dm>, /// The receiver (RX) channel responsible for handling DMA transfers in the /// parallel I/O full-duplex operation. - pub rx: RxCreatorFullDuplex<'d, DM>, + pub rx: RxCreatorFullDuplex<'d, Dm>, } impl<'d> ParlIoFullDuplex<'d, Blocking> { @@ -1219,13 +1219,13 @@ impl<'d> ParlIoFullDuplex<'d, Async> { } /// Parallel IO in half duplex / TX only mode -pub struct ParlIoTxOnly<'d, DM> +pub struct ParlIoTxOnly<'d, Dm> where - DM: Mode, + Dm: Mode, { /// The transmitter (TX) channel responsible for handling DMA transfers in /// the parallel I/O operation. - pub tx: TxCreator<'d, DM>, + pub tx: TxCreator<'d, Dm>, } impl<'d> ParlIoTxOnly<'d, Blocking> { @@ -1325,13 +1325,13 @@ impl InterruptConfigurable for ParlIoTxOnly<'_, Blocking> { } /// Parallel IO in half duplex / RX only mode -pub struct ParlIoRxOnly<'d, DM> +pub struct ParlIoRxOnly<'d, Dm> where - DM: Mode, + Dm: Mode, { /// The receiver (RX) channel responsible for handling DMA transfers in the /// parallel I/O operation. - pub rx: RxCreator<'d, DM>, + pub rx: RxCreator<'d, Dm>, } impl<'d> ParlIoRxOnly<'d, Blocking> { @@ -1461,9 +1461,9 @@ fn internal_init(frequency: HertzU32) -> Result<(), Error> { Ok(()) } -impl ParlIoTx<'_, DM> +impl ParlIoTx<'_, Dm> where - DM: Mode, + Dm: Mode, { /// Perform a DMA write. /// @@ -1516,9 +1516,9 @@ where } } -impl DmaSupport for ParlIoTx<'_, DM> +impl DmaSupport for ParlIoTx<'_, Dm> where - DM: Mode, + Dm: Mode, { fn peripheral_wait_dma(&mut self, _is_rx: bool, _is_tx: bool) { while !Instance::is_tx_eof() {} @@ -1531,11 +1531,11 @@ where } } -impl<'d, DM> DmaSupportTx for ParlIoTx<'d, DM> +impl<'d, Dm> DmaSupportTx for ParlIoTx<'d, Dm> where - DM: Mode, + Dm: Mode, { - type TX = ChannelTx<'d, DM, PeripheralTxChannel>; + type TX = ChannelTx<'d, Dm, PeripheralTxChannel>; fn tx(&mut self) -> &mut Self::TX { &mut self.tx_channel @@ -1546,9 +1546,9 @@ where } } -impl<'d, DM> ParlIoRx<'d, DM> +impl<'d, Dm> ParlIoRx<'d, Dm> where - DM: Mode, + Dm: Mode, { /// Perform a DMA read. /// @@ -1577,7 +1577,7 @@ where } fn start_receive_bytes_dma( - rx_channel: &mut ChannelRx<'d, DM, PeripheralRxChannel>, + rx_channel: &mut ChannelRx<'d, Dm, PeripheralRxChannel>, rx_chain: &mut DescriptorChain, ptr: *mut u8, len: usize, @@ -1605,9 +1605,9 @@ where } } -impl DmaSupport for ParlIoRx<'_, DM> +impl DmaSupport for ParlIoRx<'_, Dm> where - DM: Mode, + Dm: Mode, { fn peripheral_wait_dma(&mut self, _is_rx: bool, _is_tx: bool) { loop { @@ -1627,11 +1627,11 @@ where } } -impl<'d, DM> DmaSupportRx for ParlIoRx<'d, DM> +impl<'d, Dm> DmaSupportRx for ParlIoRx<'d, Dm> where - DM: Mode, + Dm: Mode, { - type RX = ChannelRx<'d, DM, PeripheralRxChannel>; + type RX = ChannelRx<'d, Dm, PeripheralRxChannel>; fn rx(&mut self) -> &mut Self::RX { &mut self.rx_channel @@ -1643,41 +1643,41 @@ where } /// Creates a TX channel -pub struct TxCreator<'d, DM> +pub struct TxCreator<'d, Dm> where - DM: Mode, + Dm: Mode, { - tx_channel: ChannelTx<'d, DM, PeripheralTxChannel>, + tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel>, descriptors: &'static mut [DmaDescriptor], _guard: GenericPeripheralGuard<{ system::Peripheral::ParlIo as u8 }>, } /// Creates a RX channel -pub struct RxCreator<'d, DM> +pub struct RxCreator<'d, Dm> where - DM: Mode, + Dm: Mode, { - rx_channel: ChannelRx<'d, DM, PeripheralRxChannel>, + rx_channel: ChannelRx<'d, Dm, PeripheralRxChannel>, descriptors: &'static mut [DmaDescriptor], _guard: GenericPeripheralGuard<{ system::Peripheral::ParlIo as u8 }>, } /// Creates a TX channel -pub struct TxCreatorFullDuplex<'d, DM> +pub struct TxCreatorFullDuplex<'d, Dm> where - DM: Mode, + Dm: Mode, { - tx_channel: ChannelTx<'d, DM, PeripheralTxChannel>, + tx_channel: ChannelTx<'d, Dm, PeripheralTxChannel>, descriptors: &'static mut [DmaDescriptor], _guard: GenericPeripheralGuard<{ system::Peripheral::ParlIo as u8 }>, } /// Creates a RX channel -pub struct RxCreatorFullDuplex<'d, DM> +pub struct RxCreatorFullDuplex<'d, Dm> where - DM: Mode, + Dm: Mode, { - rx_channel: ChannelRx<'d, DM, PeripheralRxChannel>, + rx_channel: ChannelRx<'d, Dm, PeripheralRxChannel>, descriptors: &'static mut [DmaDescriptor], _guard: GenericPeripheralGuard<{ system::Peripheral::ParlIo as u8 }>, } 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/rsa/esp32.rs b/esp-hal/src/rsa/esp32.rs index 56b6ea3a547..4802869e830 100644 --- a/esp-hal/src/rsa/esp32.rs +++ b/esp-hal/src/rsa/esp32.rs @@ -10,7 +10,7 @@ use crate::rsa::{ RsaMultiplication, }; -impl Rsa<'_, DM> { +impl Rsa<'_, Dm> { /// After the RSA Accelerator is released from reset, the memory blocks /// needs to be initialized, only after that peripheral should be used. /// This function would return without an error if the memory is initialized @@ -79,11 +79,11 @@ pub mod operand_sizes { ); } -impl<'d, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularMultiplication<'_, 'd, T, DM> +impl<'d, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularMultiplication<'_, 'd, T, Dm> where T: RsaMode, { - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_multi_mode((N / 16 - 1) as u32) } @@ -98,22 +98,22 @@ where } } -impl<'d, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularExponentiation<'_, 'd, T, DM> +impl<'d, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularExponentiation<'_, 'd, T, Dm> where T: RsaMode, { /// Sets the modular exponentiation mode for the RSA hardware. - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_modexp_mode((N / 16 - 1) as u32) } } -impl<'d, T: RsaMode + Multi, DM: crate::Mode, const N: usize> RsaMultiplication<'_, 'd, T, DM> +impl<'d, T: RsaMode + Multi, Dm: crate::Mode, const N: usize> RsaMultiplication<'_, 'd, T, Dm> where T: RsaMode, { /// Sets the multiplication mode for the RSA hardware. - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_multi_mode(((N * 2) / 16 + 7) as u32) } diff --git a/esp-hal/src/rsa/esp32cX.rs b/esp-hal/src/rsa/esp32cX.rs index e74eac7fd7f..a0ee18ce810 100644 --- a/esp-hal/src/rsa/esp32cX.rs +++ b/esp-hal/src/rsa/esp32cX.rs @@ -10,7 +10,7 @@ use crate::rsa::{ RsaMultiplication, }; -impl Rsa<'_, DM> { +impl Rsa<'_, Dm> { /// After the RSA Accelerator is released from reset, the memory blocks /// needs to be initialized, only after that peripheral should be used. /// This function would return without an error if the memory is initialized @@ -229,7 +229,7 @@ pub mod operand_sizes { ); } -impl<'d, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularExponentiation<'_, 'd, T, DM> +impl<'d, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularExponentiation<'_, 'd, T, Dm> where T: RsaMode, { @@ -244,16 +244,16 @@ where } /// Sets the modular exponentiation mode for the RSA hardware. - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_mode((N - 1) as u32) } } -impl<'d, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularMultiplication<'_, 'd, T, DM> +impl<'d, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularMultiplication<'_, 'd, T, Dm> where T: RsaMode, { - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_mode((N - 1) as u32) } @@ -262,7 +262,7 @@ where } } -impl<'d, T: RsaMode + Multi, DM: crate::Mode, const N: usize> RsaMultiplication<'_, 'd, T, DM> +impl<'d, T: RsaMode + Multi, Dm: crate::Mode, const N: usize> RsaMultiplication<'_, 'd, T, Dm> where T: RsaMode, { @@ -271,7 +271,7 @@ where } /// Sets the multiplication mode for the RSA hardware. - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_mode((N * 2 - 1) as u32) } } diff --git a/esp-hal/src/rsa/esp32sX.rs b/esp-hal/src/rsa/esp32sX.rs index 7af4ff4b601..ae62b7ac314 100644 --- a/esp-hal/src/rsa/esp32sX.rs +++ b/esp-hal/src/rsa/esp32sX.rs @@ -10,7 +10,7 @@ use crate::rsa::{ RsaMultiplication, }; -impl Rsa<'_, DM> { +impl Rsa<'_, Dm> { /// After the RSA accelerator is released from reset, the memory blocks /// needs to be initialized, only after that peripheral should be used. /// This function would return without an error if the memory is @@ -248,7 +248,7 @@ pub mod operand_sizes { ); } -impl<'d, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularExponentiation<'_, 'd, T, DM> +impl<'d, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularExponentiation<'_, 'd, T, Dm> where T: RsaMode, { @@ -263,16 +263,16 @@ where } /// Sets the modular exponentiation mode for the RSA hardware. - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_mode((N - 1) as u32) } } -impl<'d, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularMultiplication<'_, 'd, T, DM> +impl<'d, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularMultiplication<'_, 'd, T, Dm> where T: RsaMode, { - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_mode((N - 1) as u32) } @@ -281,12 +281,12 @@ where } } -impl<'d, T: RsaMode + Multi, DM: crate::Mode, const N: usize> RsaMultiplication<'_, 'd, T, DM> +impl<'d, T: RsaMode + Multi, Dm: crate::Mode, const N: usize> RsaMultiplication<'_, 'd, T, Dm> where T: RsaMode, { /// Sets the multiplication mode for the RSA hardware. - pub(super) fn write_mode(rsa: &mut Rsa<'d, DM>) { + pub(super) fn write_mode(rsa: &mut Rsa<'d, Dm>) { rsa.write_mode((N * 2 - 1) as u32) } diff --git a/esp-hal/src/rsa/mod.rs b/esp-hal/src/rsa/mod.rs index f6846eeb264..de6fd61c31c 100644 --- a/esp-hal/src/rsa/mod.rs +++ b/esp-hal/src/rsa/mod.rs @@ -44,9 +44,9 @@ mod rsa_spec_impl; pub use rsa_spec_impl::operand_sizes; /// RSA peripheral container -pub struct Rsa<'d, DM: crate::Mode> { +pub struct Rsa<'d, Dm: crate::Mode> { rsa: PeripheralRef<'d, RSA>, - phantom: PhantomData, + phantom: PhantomData, _guard: GenericPeripheralGuard<{ PeripheralEnable::Rsa as u8 }>, } @@ -93,7 +93,7 @@ impl<'d> Rsa<'d, Async> { } } -impl<'d, DM: crate::Mode> Rsa<'d, DM> { +impl<'d, Dm: crate::Mode> Rsa<'d, Dm> { fn new_internal(rsa: impl Peripheral

+ 'd) -> Self { crate::into_ref!(rsa); @@ -215,12 +215,12 @@ use implement_op; /// used to find the `(base ^ exponent) mod modulus`. /// /// Each operand is a little endian byte array of the same size -pub struct RsaModularExponentiation<'a, 'd, T: RsaMode, DM: crate::Mode> { - rsa: &'a mut Rsa<'d, DM>, +pub struct RsaModularExponentiation<'a, 'd, T: RsaMode, Dm: crate::Mode> { + rsa: &'a mut Rsa<'d, Dm>, phantom: PhantomData, } -impl<'a, 'd, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularExponentiation<'a, 'd, T, DM> +impl<'a, 'd, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularExponentiation<'a, 'd, T, Dm> where T: RsaMode, { @@ -231,7 +231,7 @@ where /// /// For more information refer to 24.3.2 of . pub fn new( - rsa: &'a mut Rsa<'d, DM>, + rsa: &'a mut Rsa<'d, Dm>, exponent: &T::InputType, modulus: &T::InputType, m_prime: u32, @@ -281,12 +281,12 @@ where /// used to find the `(operand a * operand b) mod modulus`. /// /// Each operand is a little endian byte array of the same size -pub struct RsaModularMultiplication<'a, 'd, T: RsaMode, DM: crate::Mode> { - rsa: &'a mut Rsa<'d, DM>, +pub struct RsaModularMultiplication<'a, 'd, T: RsaMode, Dm: crate::Mode> { + rsa: &'a mut Rsa<'d, Dm>, phantom: PhantomData, } -impl<'a, 'd, T: RsaMode, DM: crate::Mode, const N: usize> RsaModularMultiplication<'a, 'd, T, DM> +impl<'a, 'd, T: RsaMode, Dm: crate::Mode, const N: usize> RsaModularMultiplication<'a, 'd, T, Dm> where T: RsaMode, { @@ -298,7 +298,7 @@ where /// /// For more information refer to 20.3.1 of . pub fn new( - rsa: &'a mut Rsa<'d, DM>, + rsa: &'a mut Rsa<'d, Dm>, operand_a: &T::InputType, modulus: &T::InputType, r: &T::InputType, @@ -336,17 +336,17 @@ where /// be used to find the `operand a * operand b`. /// /// Each operand is a little endian byte array of the same size -pub struct RsaMultiplication<'a, 'd, T: RsaMode + Multi, DM: crate::Mode> { - rsa: &'a mut Rsa<'d, DM>, +pub struct RsaMultiplication<'a, 'd, T: RsaMode + Multi, Dm: crate::Mode> { + rsa: &'a mut Rsa<'d, Dm>, phantom: PhantomData, } -impl<'a, 'd, T: RsaMode + Multi, DM: crate::Mode, const N: usize> RsaMultiplication<'a, 'd, T, DM> +impl<'a, 'd, T: RsaMode + Multi, Dm: crate::Mode, const N: usize> RsaMultiplication<'a, 'd, T, Dm> where T: RsaMode, { /// Creates an instance of `RsaMultiplication`. - pub fn new(rsa: &'a mut Rsa<'d, DM>, operand_a: &T::InputType) -> Self { + pub fn new(rsa: &'a mut Rsa<'d, Dm>, operand_a: &T::InputType) -> Self { Self::write_mode(rsa); rsa.write_operand_a(operand_a); diff --git a/esp-hal/src/sha.rs b/esp-hal/src/sha.rs index 892570e8c09..41fdf6dce0a 100644 --- a/esp-hal/src/sha.rs +++ b/esp-hal/src/sha.rs @@ -550,7 +550,7 @@ impl<'d, A: ShaAlgorithm, S: BorrowMut>> digest::FixedOutput for ShaDige } } -/// This macro implements the Sha<'a, DM> trait for a specified Sha algorithm +/// This macro implements the Sha<'a, Dm> trait for a specified Sha algorithm /// and a set of parameters macro_rules! impl_sha { ($name: ident, $mode_bits: tt, $digest_length: tt, $chunk_length: tt) => { 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/twai/mod.rs b/esp-hal/src/twai/mod.rs index 88ab37b5537..4ec1b7a6869 100644 --- a/esp-hal/src/twai/mod.rs +++ b/esp-hal/src/twai/mod.rs @@ -662,18 +662,18 @@ impl BaudRate { } /// An inactive TWAI peripheral in the "Reset"/configuration state. -pub struct TwaiConfiguration<'d, DM: crate::Mode, T = AnyTwai> { +pub struct TwaiConfiguration<'d, Dm: crate::Mode, T = AnyTwai> { twai: PeripheralRef<'d, T>, filter: Option<(FilterType, [u8; 8])>, - phantom: PhantomData, + phantom: PhantomData, mode: TwaiMode, _guard: PeripheralGuard, } -impl<'d, DM, T> TwaiConfiguration<'d, DM, T> +impl<'d, Dm, T> TwaiConfiguration<'d, Dm, T> where T: Instance, - DM: crate::Mode, + Dm: crate::Mode, { fn new_internal( twai: impl Peripheral

+ 'd, @@ -906,7 +906,7 @@ where /// Put the peripheral into Operation Mode, allowing the transmission and /// reception of packets using the new object. - pub fn start(self) -> Twai<'d, DM, T> { + pub fn start(self) -> Twai<'d, Dm, T> { self.apply_filter(); self.set_mode(self.mode); @@ -1075,17 +1075,17 @@ where /// /// In this mode, the TWAI controller can transmit and receive messages /// including error signals (such as error and overload frames). -pub struct Twai<'d, DM: crate::Mode, T = AnyTwai> { +pub struct Twai<'d, Dm: crate::Mode, T = AnyTwai> { twai: PeripheralRef<'d, T>, - tx: TwaiTx<'d, DM, T>, - rx: TwaiRx<'d, DM, T>, - phantom: PhantomData, + tx: TwaiTx<'d, Dm, T>, + rx: TwaiRx<'d, Dm, T>, + phantom: PhantomData, } -impl<'d, T, DM> Twai<'d, DM, T> +impl<'d, T, Dm> Twai<'d, Dm, T> where T: Instance, - DM: crate::Mode, + Dm: crate::Mode, { fn mode(&self) -> TwaiMode { let mode = self.twai.register_block().mode().read(); @@ -1101,7 +1101,7 @@ where /// Stop the peripheral, putting it into reset mode and enabling /// reconfiguration. - pub fn stop(self) -> TwaiConfiguration<'d, DM, T> { + pub fn stop(self) -> TwaiConfiguration<'d, Dm, T> { // Put the peripheral into reset/configuration mode by setting the reset mode // bit. self.twai @@ -1190,22 +1190,22 @@ where /// Consumes this `Twai` instance and splits it into transmitting and /// receiving halves. - pub fn split(self) -> (TwaiRx<'d, DM, T>, TwaiTx<'d, DM, T>) { + pub fn split(self) -> (TwaiRx<'d, Dm, T>, TwaiTx<'d, Dm, T>) { (self.rx, self.tx) } } /// Interface to the TWAI transmitter part. -pub struct TwaiTx<'d, DM: crate::Mode, T = AnyTwai> { +pub struct TwaiTx<'d, Dm: crate::Mode, T = AnyTwai> { twai: PeripheralRef<'d, T>, - phantom: PhantomData, + phantom: PhantomData, _guard: PeripheralGuard, } -impl TwaiTx<'_, DM, T> +impl TwaiTx<'_, Dm, T> where T: Instance, - DM: crate::Mode, + Dm: crate::Mode, { /// Transmit a frame. /// @@ -1239,16 +1239,16 @@ where } /// Interface to the TWAI receiver part. -pub struct TwaiRx<'d, DM: crate::Mode, T = AnyTwai> { +pub struct TwaiRx<'d, Dm: crate::Mode, T = AnyTwai> { twai: PeripheralRef<'d, T>, - phantom: PhantomData, + phantom: PhantomData, _guard: PeripheralGuard, } -impl TwaiRx<'_, DM, T> +impl TwaiRx<'_, Dm, T> where T: Instance, - DM: crate::Mode, + Dm: crate::Mode, { /// Receive a frame pub fn receive(&mut self) -> nb::Result { @@ -1335,10 +1335,10 @@ unsafe fn copy_to_data_register(dest: *mut u32, src: &[u8]) { } #[cfg(any(doc, feature = "unstable"))] -impl embedded_can::nb::Can for Twai<'_, DM, T> +impl embedded_can::nb::Can for Twai<'_, Dm, T> where T: Instance, - DM: crate::Mode, + Dm: crate::Mode, { type Frame = EspTwaiFrame; type Error = EspTwaiError; 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..195238f179a 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,16 +2071,13 @@ 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> { - pub(crate) fn new( - _device: PeripheralRef<'d, crate::hal::peripherals::WIFI>, - mode: MODE, - ) -> Self { +impl<'d, Dm: WifiDeviceMode> WifiDevice<'d, Dm> { + pub(crate) fn new(_device: PeripheralRef<'d, crate::hal::peripherals::WIFI>, mode: Dm) -> Self { Self { _device, mode } } @@ -2092,14 +2089,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 +2616,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 +2651,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 +2683,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 +2694,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 +2723,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 +3121,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 +3130,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 +3139,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);