Skip to content

Commit c70f340

Browse files
committed
simplify spi dma builder
1 parent 2674866 commit c70f340

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

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)