Skip to content

Commit 88748f2

Browse files
committed
Fix dma enable
1 parent d32befd commit 88748f2

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/spi.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,12 @@ impl<SPI: Instance, W: Word> Inner<SPI, W> {
503503
self.spi.cr1().modify(|_, w| w.spe().enabled());
504504
}
505505

506-
/// Enable SPI
506+
#[inline]
507+
pub fn start_transfer(&self) {
508+
self.spi.cr1().modify(|_, w| w.cstart().started());
509+
}
510+
511+
/// Disable SPI
507512
fn disable(&mut self) {
508513
self.spi.cr1().modify(|_, w| w.spe().disabled());
509514
}
@@ -583,13 +588,13 @@ impl<SPI: Instance, W: Word> Inner<SPI, W> {
583588
/// Disable DMA for both Rx and Tx
584589
#[inline]
585590
pub fn enable_tx_dma(&self) {
586-
self.spi.cfg1().modify(|_, w| w.txdmaen().disabled());
591+
self.spi.cfg1().modify(|_, w| w.txdmaen().enabled());
587592
}
588593

589594
/// Disable DMA for both Rx and Tx
590595
#[inline]
591596
pub fn enable_rx_dma(&self) {
592-
self.spi.cfg1().modify(|_, w| w.rxdmaen().disabled());
597+
self.spi.cfg1().modify(|_, w| w.rxdmaen().enabled());
593598
}
594599

595600
/// Disable DMA for both Rx and Tx
@@ -598,11 +603,6 @@ impl<SPI: Instance, W: Word> Inner<SPI, W> {
598603
self.spi.cfg1().modify(|_, w| w.rxdmaen().disabled().txdmaen().disabled());
599604
}
600605

601-
#[inline]
602-
pub fn start_transfer(&self) {
603-
self.spi.cr1().modify(|_, w| w.cstart().started());
604-
}
605-
606606
/// Read a single word from the receive data register
607607
#[inline(always)]
608608
fn read_data_reg(&mut self) -> W {

src/spi/dma.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ where
182182
}
183183

184184
pub fn wait_for_complete(&mut self) -> Result<(), Error> {
185-
while !self.is_dma_complete()? {}
185+
self.tx_transfer.wait_for_transfer_complete()?;
186+
self.rx_transfer.wait_for_transfer_complete()?;
186187
self.spi.end_transaction();
187188
self.spi.disable_dma();
188189
Ok(())

0 commit comments

Comments
 (0)