diff options
Diffstat (limited to 'embassy-stm32/src/dma/gpdma/mod.rs')
| -rw-r--r-- | embassy-stm32/src/dma/gpdma/mod.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/embassy-stm32/src/dma/gpdma/mod.rs b/embassy-stm32/src/dma/gpdma/mod.rs index 4a14c2a8e..afb18ec1a 100644 --- a/embassy-stm32/src/dma/gpdma/mod.rs +++ b/embassy-stm32/src/dma/gpdma/mod.rs | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | use core::future::Future; | 3 | use core::future::Future; |
| 4 | use core::pin::Pin; | 4 | use core::pin::Pin; |
| 5 | use core::sync::atomic::{fence, AtomicUsize, Ordering}; | 5 | use core::sync::atomic::{AtomicUsize, Ordering, fence}; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::Peri; | 8 | use embassy_hal_internal::Peri; |
| @@ -14,6 +14,7 @@ use super::{AnyChannel, Channel, Dir, Request, STATE}; | |||
| 14 | use crate::interrupt::typelevel::Interrupt; | 14 | use crate::interrupt::typelevel::Interrupt; |
| 15 | use crate::pac; | 15 | use crate::pac; |
| 16 | use crate::pac::gpdma::vals; | 16 | use crate::pac::gpdma::vals; |
| 17 | use crate::rcc::BusyPeripheral; | ||
| 17 | 18 | ||
| 18 | pub mod linked_list; | 19 | pub mod linked_list; |
| 19 | pub mod ringbuffered; | 20 | pub mod ringbuffered; |
| @@ -236,6 +237,11 @@ impl AnyChannel { | |||
| 236 | // "Preceding reads and writes cannot be moved past subsequent writes." | 237 | // "Preceding reads and writes cannot be moved past subsequent writes." |
| 237 | fence(Ordering::SeqCst); | 238 | fence(Ordering::SeqCst); |
| 238 | 239 | ||
| 240 | if ch.cr().read().en() { | ||
| 241 | ch.cr().modify(|w| w.set_susp(true)); | ||
| 242 | while !ch.sr().read().suspf() {} | ||
| 243 | } | ||
| 244 | |||
| 239 | ch.cr().write(|w| w.set_reset(true)); | 245 | ch.cr().write(|w| w.set_reset(true)); |
| 240 | ch.fcr().write(|w| { | 246 | ch.fcr().write(|w| { |
| 241 | // Clear all irqs | 247 | // Clear all irqs |
| @@ -407,7 +413,7 @@ impl AnyChannel { | |||
| 407 | /// Linked-list DMA transfer. | 413 | /// Linked-list DMA transfer. |
| 408 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 414 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 409 | pub struct LinkedListTransfer<'a, const ITEM_COUNT: usize> { | 415 | pub struct LinkedListTransfer<'a, const ITEM_COUNT: usize> { |
| 410 | channel: Peri<'a, AnyChannel>, | 416 | channel: BusyPeripheral<Peri<'a, AnyChannel>>, |
| 411 | } | 417 | } |
| 412 | 418 | ||
| 413 | impl<'a, const ITEM_COUNT: usize> LinkedListTransfer<'a, ITEM_COUNT> { | 419 | impl<'a, const ITEM_COUNT: usize> LinkedListTransfer<'a, ITEM_COUNT> { |
| @@ -428,7 +434,9 @@ impl<'a, const ITEM_COUNT: usize> LinkedListTransfer<'a, ITEM_COUNT> { | |||
| 428 | channel.configure_linked_list(&table, options); | 434 | channel.configure_linked_list(&table, options); |
| 429 | channel.start(); | 435 | channel.start(); |
| 430 | 436 | ||
| 431 | Self { channel } | 437 | Self { |
| 438 | channel: BusyPeripheral::new(channel), | ||
| 439 | } | ||
| 432 | } | 440 | } |
| 433 | 441 | ||
| 434 | /// Request the transfer to pause, keeping the existing configuration for this channel. | 442 | /// Request the transfer to pause, keeping the existing configuration for this channel. |
| @@ -504,7 +512,7 @@ impl<'a, const ITEM_COUNT: usize> Future for LinkedListTransfer<'a, ITEM_COUNT> | |||
| 504 | /// DMA transfer. | 512 | /// DMA transfer. |
| 505 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 513 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 506 | pub struct Transfer<'a> { | 514 | pub struct Transfer<'a> { |
| 507 | channel: Peri<'a, AnyChannel>, | 515 | channel: BusyPeripheral<Peri<'a, AnyChannel>>, |
| 508 | } | 516 | } |
| 509 | 517 | ||
| 510 | impl<'a> Transfer<'a> { | 518 | impl<'a> Transfer<'a> { |
| @@ -624,7 +632,9 @@ impl<'a> Transfer<'a> { | |||
| 624 | ); | 632 | ); |
| 625 | channel.start(); | 633 | channel.start(); |
| 626 | 634 | ||
| 627 | Self { channel } | 635 | Self { |
| 636 | channel: BusyPeripheral::new(channel), | ||
| 637 | } | ||
| 628 | } | 638 | } |
| 629 | 639 | ||
| 630 | /// Request the transfer to pause, keeping the existing configuration for this channel. | 640 | /// Request the transfer to pause, keeping the existing configuration for this channel. |
