Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Nov 20, 2024
1 parent 518a0a4 commit 3a20d37
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
10 changes: 4 additions & 6 deletions esp-hal/src/i2s/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand All @@ -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),
}
}
}
Expand Down Expand Up @@ -446,7 +445,6 @@ where
descriptors: self.i2s_tx.descriptors,
guard: self.i2s_tx.guard,
},
guard: self.guard,
}
}
}
Expand Down
21 changes: 8 additions & 13 deletions esp-hal/src/parl_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -1023,22 +1021,22 @@ impl<'d> ParlIoFullDuplex<'d, Blocking> {
CH: DmaChannelConvert<<PARL_IO as DmaEligible>::Dma>,
Channel<'d, Blocking, CH>: From<Channel<'d, DM, CH>>,
{
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::<Blocking, CH>::from(dma_channel);
internal_init(frequency)?;

Ok(Self {
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,
})
}

Expand All @@ -1055,7 +1053,6 @@ impl<'d> ParlIoFullDuplex<'d, Blocking> {
descriptors: self.rx.descriptors,
_guard: self.rx._guard,
},
_guard: self._guard,
}
}

Expand Down Expand Up @@ -1110,7 +1107,6 @@ impl<'d> ParlIoFullDuplex<'d, Async> {
descriptors: self.rx.descriptors,
_guard: self.rx._guard,
},
_guard: self._guard,
}
}
}
Expand All @@ -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>
Expand All @@ -1148,8 +1143,8 @@ where
tx: TxCreator {
tx_channel: dma_channel.tx.degrade(),
descriptors,
_guard: guard,
},
_guard: guard,
})
}
}
Expand Down Expand Up @@ -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>
Expand All @@ -1226,8 +1219,8 @@ where
rx: RxCreator {
rx_channel: dma_channel.rx.degrade(),
descriptors,
_guard: guard,
},
_guard: guard,
})
}
}
Expand Down Expand Up @@ -1488,6 +1481,7 @@ where
{
tx_channel: ChannelTx<'d, DM, <PARL_IO as DmaEligible>::Dma>,
descriptors: &'static mut [DmaDescriptor],
_guard: PeripheralGuard,
}

/// Creates a RX channel
Expand All @@ -1497,6 +1491,7 @@ where
{
rx_channel: ChannelRx<'d, DM, <PARL_IO as DmaEligible>::Dma>,
descriptors: &'static mut [DmaDescriptor],
_guard: PeripheralGuard,
}

/// Creates a TX channel
Expand Down
7 changes: 1 addition & 6 deletions esp-hal/src/rmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ mod impl_for_chip {
}

/// RMT Channel
#[derive(Debug)]
#[non_exhaustive]
pub struct Channel<M, const CHANNEL: u8>
where
Expand All @@ -1025,12 +1026,6 @@ where
_guard: PeripheralGuard,
}

impl<M: crate::Mode, const CHANNEL: u8> core::fmt::Debug for Channel<M, 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<Blocking> {
/// Start transmitting the given pulse code sequence.
Expand Down
1 change: 1 addition & 0 deletions esp-hal/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub(crate) fn disable_peripherals() {
}
}

#[derive(Debug)]
pub(crate) struct PeripheralGuard {
peripheral: Peripheral,
}
Expand Down

0 comments on commit 3a20d37

Please sign in to comment.