Skip to content

Commit 0defb02

Browse files
committed
doc: DMA Tx streaming buffer and update async wait_for_available
comments
1 parent a95c8bc commit 0defb02

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

esp-hal/src/dma/buffers.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1405,7 +1405,27 @@ impl DmaRxStreamBufView {
14051405
}
14061406
}
14071407

1408-
/// A continuous DMA transfer buffer for Tx.
1408+
/// DMA Streaming Transmit Buffer.
1409+
///
1410+
/// This is symmetric implementation to [DmaTxStreamBuf], used for continuously
1411+
/// streaming data to a peripheral's FIFO.
1412+
///
1413+
/// The list starts out like so `A(full) -> B(full) -> C(full) -> D(full) -> NULL`.
1414+
///
1415+
/// As the DMA writes to FIFO, the list progresses like so:
1416+
/// - `A(full) -> B(full) -> C(full) -> D(full) -> NULL`
1417+
/// - `A(empty) -> B(full) -> C(full) -> D(full) -> NULL`
1418+
/// - `A(empty) -> B(empty) -> C(full) -> D(full) -> NULL`
1419+
/// - `A(empty) -> B(empty) -> C(empty) -> D(full) -> NULL`
1420+
///
1421+
/// As you call [DmaTxStreamBufView::push] the list (approximately) progresses like so:
1422+
/// - `A(empty) -> B(empty) -> C(empty) -> D(full) -> NULL`
1423+
/// - `B(empty) -> C(empty) -> D(full) -> A(full) -> NULL`
1424+
/// - `C(empty) -> D(full) -> A(full) -> B(full) -> NULL`
1425+
/// - `D(full) -> A(full) -> B(full) -> C(full) -> NULL`
1426+
///
1427+
/// If all the descriptors fill up, the [DmaTxInterrupt::TotalEof] interrupt will fire and DMA
1428+
/// will stop writing, at which point it is up to you to resume/restart the transfer.
14091429
pub struct DmaTxStreamBuf {
14101430
descriptors: &'static mut [DmaDescriptor],
14111431
buffer: &'static mut [u8],

esp-hal/src/i2s/master.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1822,7 +1822,13 @@ pub mod asynch {
18221822
/// Waits for DMA process to be made and additional room to be
18231823
/// available.
18241824
///
1825-
/// Returns [crate::dma::DmaError::Late] if DMA is already completed.
1825+
/// In particular, it waits for [crate::dma::DmaTxInterrupt::Done]
1826+
/// which is trigger every time a descriptor in the list has been filled.
1827+
/// In addition, if [crate::dma::DmaTxInterrupt::TotalEof] has been triggered,
1828+
/// it means that the descriptor list is most likely used up and user needs to
1829+
/// manually reset the I2S and DMA channel.
1830+
///
1831+
/// Returns [crate::dma::DmaError::Late] if DMA descriptors are used up.
18261832
pub async fn wait_for_available(&mut self) -> Result<(), Error> {
18271833
DmaTxDoneChFuture::new(&mut self.i2s_tx.tx_channel).await?;
18281834
Ok(())
@@ -1832,6 +1838,9 @@ pub mod asynch {
18321838
impl<BUFFER: DmaRxBuffer> I2sRxDmaTransfer<'_, Async, BUFFER> {
18331839
/// Waits for DMA process to be made and additional room to be
18341840
/// available.
1841+
///
1842+
/// In particular, it waits for [crate::dma::DmaRxInterrupt::Done]
1843+
/// which is trigger every time a descriptor in the list has been filled.
18351844
pub async fn wait_for_available(&mut self) -> Result<(), Error> {
18361845
DmaRxDoneChFuture::new(&mut self.i2s_rx.rx_channel).await?;
18371846
Ok(())

0 commit comments

Comments
 (0)