diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-03-15 04:13:33 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-03-15 04:13:33 +0100 |
| commit | 1dc618f0e4e045de63007893fb36fcaba82acfa4 (patch) | |
| tree | 50fb3b7175ceb0063dc440ec7221ff8399532981 /embassy-stm32/src | |
| parent | 49ef19c0b284eeb6d97cec597bbb1f82d18397c5 (diff) | |
stm32/spi: fix blocking transfer hanging after async.
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index a743a036c..764a967ca 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -575,6 +575,7 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | pub fn blocking_write<W: Word>(&mut self, words: &[W]) -> Result<(), Error> { | 577 | pub fn blocking_write<W: Word>(&mut self, words: &[W]) -> Result<(), Error> { |
| 578 | unsafe { T::REGS.cr1().modify(|w| w.set_spe(true)) } | ||
| 578 | flush_rx_fifo(T::REGS); | 579 | flush_rx_fifo(T::REGS); |
| 579 | self.set_word_size(W::WORDSIZE); | 580 | self.set_word_size(W::WORDSIZE); |
| 580 | for word in words.iter() { | 581 | for word in words.iter() { |
| @@ -584,6 +585,7 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 584 | } | 585 | } |
| 585 | 586 | ||
| 586 | pub fn blocking_read<W: Word>(&mut self, words: &mut [W]) -> Result<(), Error> { | 587 | pub fn blocking_read<W: Word>(&mut self, words: &mut [W]) -> Result<(), Error> { |
| 588 | unsafe { T::REGS.cr1().modify(|w| w.set_spe(true)) } | ||
| 587 | flush_rx_fifo(T::REGS); | 589 | flush_rx_fifo(T::REGS); |
| 588 | self.set_word_size(W::WORDSIZE); | 590 | self.set_word_size(W::WORDSIZE); |
| 589 | for word in words.iter_mut() { | 591 | for word in words.iter_mut() { |
| @@ -593,6 +595,7 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 593 | } | 595 | } |
| 594 | 596 | ||
| 595 | pub fn blocking_transfer_in_place<W: Word>(&mut self, words: &mut [W]) -> Result<(), Error> { | 597 | pub fn blocking_transfer_in_place<W: Word>(&mut self, words: &mut [W]) -> Result<(), Error> { |
| 598 | unsafe { T::REGS.cr1().modify(|w| w.set_spe(true)) } | ||
| 596 | flush_rx_fifo(T::REGS); | 599 | flush_rx_fifo(T::REGS); |
| 597 | self.set_word_size(W::WORDSIZE); | 600 | self.set_word_size(W::WORDSIZE); |
| 598 | for word in words.iter_mut() { | 601 | for word in words.iter_mut() { |
| @@ -602,6 +605,7 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 602 | } | 605 | } |
| 603 | 606 | ||
| 604 | pub fn blocking_transfer<W: Word>(&mut self, read: &mut [W], write: &[W]) -> Result<(), Error> { | 607 | pub fn blocking_transfer<W: Word>(&mut self, read: &mut [W], write: &[W]) -> Result<(), Error> { |
| 608 | unsafe { T::REGS.cr1().modify(|w| w.set_spe(true)) } | ||
| 605 | flush_rx_fifo(T::REGS); | 609 | flush_rx_fifo(T::REGS); |
| 606 | self.set_word_size(W::WORDSIZE); | 610 | self.set_word_size(W::WORDSIZE); |
| 607 | let len = read.len().max(write.len()); | 611 | let len = read.len().max(write.len()); |
