aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/dma/ringbuffer/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32/src/dma/ringbuffer/mod.rs')
-rw-r--r--embassy-stm32/src/dma/ringbuffer/mod.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/embassy-stm32/src/dma/ringbuffer/mod.rs b/embassy-stm32/src/dma/ringbuffer/mod.rs
index 44ea497fe..659ffa9e5 100644
--- a/embassy-stm32/src/dma/ringbuffer/mod.rs
+++ b/embassy-stm32/src/dma/ringbuffer/mod.rs
@@ -1,5 +1,3 @@
1#![cfg_attr(gpdma, allow(unused))]
2
3use core::future::poll_fn; 1use core::future::poll_fn;
4use core::task::{Poll, Waker}; 2use core::task::{Poll, Waker};
5 3
@@ -285,17 +283,20 @@ impl<'a, W: Word> WritableDmaRingBuffer<'a, W> {
285 } 283 }
286 284
287 /// Write an exact number of elements to the ringbuffer. 285 /// Write an exact number of elements to the ringbuffer.
286 ///
287 /// Returns the remaining write capacity in the buffer.
288 #[allow(dead_code)]
288 pub async fn write_exact(&mut self, dma: &mut impl DmaCtrl, buffer: &[W]) -> Result<usize, Error> { 289 pub async fn write_exact(&mut self, dma: &mut impl DmaCtrl, buffer: &[W]) -> Result<usize, Error> {
289 let mut written_data = 0; 290 let mut written_len = 0;
290 let buffer_len = buffer.len(); 291 let buffer_len = buffer.len();
291 292
292 poll_fn(|cx| { 293 poll_fn(|cx| {
293 dma.set_waker(cx.waker()); 294 dma.set_waker(cx.waker());
294 295
295 match self.write(dma, &buffer[written_data..buffer_len]) { 296 match self.write(dma, &buffer[written_len..buffer_len]) {
296 Ok((len, remaining)) => { 297 Ok((len, remaining)) => {
297 written_data += len; 298 written_len += len;
298 if written_data == buffer_len { 299 if written_len == buffer_len {
299 Poll::Ready(Ok(remaining)) 300 Poll::Ready(Ok(remaining))
300 } else { 301 } else {
301 Poll::Pending 302 Poll::Pending