Skip to content

Commit 42e39b9

Browse files
committed
simplify spi dma builder
1 parent 36afe42 commit 42e39b9

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/dma/traits.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
use super::*;
2-
#[cfg(feature = "uart4")]
3-
use crate::uart;
42
use crate::{
53
pac::{self, DMA1, DMA2},
64
timer,

src/spi.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -831,26 +831,22 @@ pub struct Rx<SPI> {
831831

832832
impl<SPI: Instance> DmaBuilder<SPI> {
833833
pub fn tx(self) -> Tx<SPI> {
834-
self.new_tx()
835-
}
836-
837-
pub fn rx(self) -> Rx<SPI> {
838-
self.new_rx()
839-
}
840-
841-
pub fn txrx(self) -> (Tx<SPI>, Rx<SPI>) {
842-
(self.new_tx(), self.new_rx())
843-
}
844-
845-
fn new_tx(&self) -> Tx<SPI> {
846834
self.spi.cr2.modify(|_, w| w.txdmaen().enabled());
847835
Tx { spi: PhantomData }
848836
}
849837

850-
fn new_rx(self) -> Rx<SPI> {
838+
pub fn rx(self) -> Rx<SPI> {
851839
self.spi.cr2.modify(|_, w| w.rxdmaen().enabled());
852840
Rx { spi: PhantomData }
853841
}
842+
843+
pub fn txrx(self) -> (Tx<SPI>, Rx<SPI>) {
844+
self.spi.cr2.modify(|_, w| {
845+
w.txdmaen().enabled();
846+
w.rxdmaen().enabled()
847+
});
848+
(Tx { spi: PhantomData }, Rx { spi: PhantomData })
849+
}
854850
}
855851

856852
unsafe impl<SPI: Instance> PeriAddress for Rx<SPI> {

0 commit comments

Comments
 (0)