From 113e26f2b239499204feffb61a9c9253fb8a0eb6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 28 Dec 2022 21:14:44 +0100 Subject: [PATCH] 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