From 113e26f2b239499204feffb61a9c9253fb8a0eb6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Dec 2022 21:14:44 +0100 Subject: [PATCH 1/2] add DMA cndtr getter function --- src/dma.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/dma.rs b/src/dma.rs index 00b0c160..919bc220 100644 --- a/src/dma.rs +++ b/src/dma.rs @@ -343,6 +343,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 From cf378ba703fce3a88572d23089c23aec1baf2ffa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Dec 2022 22:26:47 +0100 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b3840ce..1b613a83 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.9.1] - 2022-09-07