From 1f9dd9f705e5ffdcecac9f35606ca425e0636f96 Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Thu, 20 Oct 2022 20:08:48 +0200 Subject: [PATCH] DMA: add a method to wait for transfer completion --- CHANGELOG.md | 1 + src/dma/mod.rs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f242b84b..37619dde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - example of using USB CDC with interrupts. - Added non-blocking I2C based on DMA [#534] - Added Transactional I2C API [#542] +- Added wait method for DMA Transfer. [#481]: https://github.com/stm32-rs/stm32f4xx-hal/pull/481 [#489]: https://github.com/stm32-rs/stm32f4xx-hal/pull/489 diff --git a/src/dma/mod.rs b/src/dma/mod.rs index dbd9912e..c168fdad 100644 --- a/src/dma/mod.rs +++ b/src/dma/mod.rs @@ -1355,6 +1355,12 @@ where &mut self.stream } + /// Wait for the transfer to complete. + #[inline(always)] + pub fn wait(&self) { + while !STREAM::get_transfer_complete_flag() {} + } + /// Applies all fields in DmaConfig. fn apply_config(stream: &mut STREAM, config: config::DmaConfig) { let msize = mem::size_of::<::MemSize>() / 2;