Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Allow `Serial` reconfiguration by references to the `Tx` and `Rx` parts.
- Allow `Serial` release after splitting.
- `Spi::is_busy()`
- Allow to stop an incomplete DMA transfer.

## [v0.9.0] - 2022-03-02

Expand Down
27 changes: 24 additions & 3 deletions src/dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,16 @@ macro_rules! dma {
!self.payload.channel.in_progress()
}

pub fn wait(mut self) -> (BUFFER, RxDma<PAYLOAD, $CX>) {
/// Waits for the transfer to complete,
/// then stops it and returns the underlying buffer and RxDma.
pub fn wait(self) -> (BUFFER, RxDma<PAYLOAD, $CX>) {
while !self.is_done() {}

self.stop()
}

/// Stops the transfer and returns the underlying buffer and RxDma.
pub fn stop(mut self) -> (BUFFER, RxDma<PAYLOAD, $CX>) {
atomic::compiler_fence(Ordering::Acquire);

self.payload.stop();
Expand Down Expand Up @@ -340,9 +347,16 @@ macro_rules! dma {
!self.payload.channel.in_progress()
}

pub fn wait(mut self) -> (BUFFER, TxDma<PAYLOAD, $CX>) {
/// Waits for the transfer to complete,
/// then stops it and returns the underlying buffer and TxDma.
pub fn wait(self) -> (BUFFER, TxDma<PAYLOAD, $CX>) {
while !self.is_done() {}

self.stop()
}

/// Stops the transfer and returns the underlying buffer and TxDma.
pub fn stop(mut self) -> (BUFFER, TxDma<PAYLOAD, $CX>) {
atomic::compiler_fence(Ordering::Acquire);

self.payload.stop();
Expand Down Expand Up @@ -378,9 +392,16 @@ macro_rules! dma {
!self.payload.rxchannel.in_progress()
}

pub fn wait(mut self) -> (BUFFER, RxTxDma<PAYLOAD, $CX, TXC>) {
/// Waits for the transfer to complete,
/// then stops it and returns the underlying buffer and RxTxDma.
pub fn wait(self) -> (BUFFER, RxTxDma<PAYLOAD, $CX, TXC>) {
while !self.is_done() {}

self.stop()
}

/// Stops the transfer and returns the underlying buffer and RxTxDma.
pub fn stop(mut self) -> (BUFFER, RxTxDma<PAYLOAD, $CX, TXC>) {
atomic::compiler_fence(Ordering::Acquire);

self.payload.stop();
Expand Down