diff --git a/CHANGELOG.md b/CHANGELOG.md index d357e1f7..5654405a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased -No changes. +- dma: Added `get_remaining_transfer_len` for the `Channel` trait + to read the NDTR register. ## [v0.10.0] - 2023-11-30 diff --git a/src/dma.rs b/src/dma.rs index 01f771c9..a8ea40f0 100644 --- a/src/dma.rs +++ b/src/dma.rs @@ -368,6 +368,16 @@ pub trait Channel: private::Channel { self.ch().ndtr.write(|w| w.ndt().bits(len)); } + /// Get the content of the number of data (NDTR) register + /// + /// If the DMA has not been enabled yet, this will be the value which + /// was set with [`set_transfer_length`]. If the DMA is active, the value + /// indicates the number of remaining bytes to be transmitted. This value + /// is decremented by the hardware after each DMA transfer. + fn get_remaining_transfer_len(&self) -> u16 { + self.ch().ndtr.read().ndt().bits() + } + /// Set the word size. /// /// # Panics