diff --git a/esp-hal/src/i2s/master.rs b/esp-hal/src/i2s/master.rs index 8c89ebf52a7..5a8e4a84b26 100644 --- a/esp-hal/src/i2s/master.rs +++ b/esp-hal/src/i2s/master.rs @@ -259,7 +259,6 @@ where pub i2s_rx: RxCreator<'d, M, T>, /// Handles the transmission (TX) side of the I2S peripheral. pub i2s_tx: TxCreator<'d, M, T>, - guard: PeripheralGuard, } impl<'d, DmaMode, T> I2s<'d, DmaMode, T> @@ -287,7 +286,8 @@ where // make sure the peripheral is enabled before configuring it let peripheral = i2s.peripheral(); - let guard = PeripheralGuard::new(peripheral); + let rx_guard = PeripheralGuard::new(peripheral); + let tx_guard = PeripheralGuard::new(peripheral); i2s.set_clock(calculate_clock(sample_rate, 2, data_format.channel_bits())); i2s.configure(&standard, &data_format); @@ -300,15 +300,14 @@ where i2s: unsafe { i2s.clone_unchecked() }, rx_channel: channel.rx, descriptors: rx_descriptors, - guard, + guard: rx_guard, }, i2s_tx: TxCreator { i2s, tx_channel: channel.tx, descriptors: tx_descriptors, - guard: PeripheralGuard::new(peripheral), + guard: tx_guard, }, - guard: PeripheralGuard::new(peripheral), } } } @@ -446,7 +445,6 @@ where descriptors: self.i2s_tx.descriptors, guard: self.i2s_tx.guard, }, - guard: self.guard, } } } diff --git a/esp-hal/src/parl_io.rs b/esp-hal/src/parl_io.rs index 797b102369c..a67e6ba19f5 100644 --- a/esp-hal/src/parl_io.rs +++ b/esp-hal/src/parl_io.rs @@ -1005,8 +1005,6 @@ where /// The receiver (RX) channel responsible for handling DMA transfers in the /// parallel I/O full-duplex operation. pub rx: RxCreatorFullDuplex<'d, DM>, - - _guard: PeripheralGuard, } impl<'d> ParlIoFullDuplex<'d, Blocking> { @@ -1023,7 +1021,8 @@ impl<'d> ParlIoFullDuplex<'d, Blocking> { CH: DmaChannelConvert<::Dma>, Channel<'d, Blocking, CH>: From>, { - let guard = PeripheralGuard::new(crate::system::Peripheral::ParlIo); + let tx_guard = PeripheralGuard::new(crate::system::Peripheral::ParlIo); + let rx_guard = PeripheralGuard::new(crate::system::Peripheral::ParlIo); let dma_channel = Channel::::from(dma_channel); internal_init(frequency)?; @@ -1031,14 +1030,13 @@ impl<'d> ParlIoFullDuplex<'d, Blocking> { tx: TxCreatorFullDuplex { tx_channel: dma_channel.tx.degrade(), descriptors: tx_descriptors, - _guard: PeripheralGuard::new(crate::system::Peripheral::ParlIo), + _guard: tx_guard, }, rx: RxCreatorFullDuplex { rx_channel: dma_channel.rx.degrade(), descriptors: rx_descriptors, - _guard: PeripheralGuard::new(crate::system::Peripheral::ParlIo), + _guard: rx_guard, }, - _guard: guard, }) } @@ -1055,7 +1053,6 @@ impl<'d> ParlIoFullDuplex<'d, Blocking> { descriptors: self.rx.descriptors, _guard: self.rx._guard, }, - _guard: self._guard, } } @@ -1110,7 +1107,6 @@ impl<'d> ParlIoFullDuplex<'d, Async> { descriptors: self.rx.descriptors, _guard: self.rx._guard, }, - _guard: self._guard, } } } @@ -1123,7 +1119,6 @@ where /// The transmitter (TX) channel responsible for handling DMA transfers in /// the parallel I/O operation. pub tx: TxCreator<'d, DM>, - _guard: PeripheralGuard, } impl<'d, DM> ParlIoTxOnly<'d, DM> @@ -1148,8 +1143,8 @@ where tx: TxCreator { tx_channel: dma_channel.tx.degrade(), descriptors, + _guard: guard, }, - _guard: guard, }) } } @@ -1200,8 +1195,6 @@ where /// The receiver (RX) channel responsible for handling DMA transfers in the /// parallel I/O operation. pub rx: RxCreator<'d, DM>, - - _guard: PeripheralGuard, } impl<'d, DM> ParlIoRxOnly<'d, DM> @@ -1226,8 +1219,8 @@ where rx: RxCreator { rx_channel: dma_channel.rx.degrade(), descriptors, + _guard: guard, }, - _guard: guard, }) } } @@ -1488,6 +1481,7 @@ where { tx_channel: ChannelTx<'d, DM, ::Dma>, descriptors: &'static mut [DmaDescriptor], + _guard: PeripheralGuard, } /// Creates a RX channel @@ -1497,6 +1491,7 @@ where { rx_channel: ChannelRx<'d, DM, ::Dma>, descriptors: &'static mut [DmaDescriptor], + _guard: PeripheralGuard, } /// Creates a TX channel diff --git a/esp-hal/src/rmt.rs b/esp-hal/src/rmt.rs index 78777be15e8..78020de33e4 100644 --- a/esp-hal/src/rmt.rs +++ b/esp-hal/src/rmt.rs @@ -1016,6 +1016,7 @@ mod impl_for_chip { } /// RMT Channel +#[derive(Debug)] #[non_exhaustive] pub struct Channel where @@ -1025,12 +1026,6 @@ where _guard: PeripheralGuard, } -impl core::fmt::Debug for Channel { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - write!(f, "Rmt Channel {}", CHANNEL) - } -} - /// Channel in TX mode pub trait TxChannel: TxChannelInternal { /// Start transmitting the given pulse code sequence. diff --git a/esp-hal/src/system.rs b/esp-hal/src/system.rs index 299ba7522ab..b3019ed50aa 100755 --- a/esp-hal/src/system.rs +++ b/esp-hal/src/system.rs @@ -150,6 +150,7 @@ pub(crate) fn disable_peripherals() { } } +#[derive(Debug)] pub(crate) struct PeripheralGuard { peripheral: Peripheral, }