From 2e63fffa0fa5a9900a1fb0f9957be64ad52d3ddd Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Thu, 13 Oct 2022 19:31:02 +0200 Subject: [PATCH 1/7] SPI: introduce OPERATION parameter for DmaBuilder --- src/spi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spi.rs b/src/spi.rs index 949c87c1..f11a040e 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -680,7 +680,7 @@ impl // Spi DMA -impl Spi { +impl Spi { pub fn use_dma(self) -> DmaBuilder { DmaBuilder { spi: self.spi } } From c394e4e350145cdf1e12c5d905e8b2ec8b0ff679 Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Thu, 13 Oct 2022 20:48:21 +0200 Subject: [PATCH 2/7] Release Spi from DMA Tx and Rx --- src/dma/traits.rs | 185 +++++++++++++++++++++++++++++++++++++++------- src/spi.rs | 54 ++++++++------ 2 files changed, 189 insertions(+), 50 deletions(-) diff --git a/src/dma/traits.rs b/src/dma/traits.rs index e99eca8b..04c1d1dd 100644 --- a/src/dma/traits.rs +++ b/src/dma/traits.rs @@ -283,6 +283,15 @@ macro_rules! dma_map { }; } +macro_rules! dma_spi_map { + ($(($Stream:ty, $C:literal, $RxTx:ident, $Peripheral:ty, $Dir:ty)),+ $(,)*) => { + $( + unsafe impl + DMASet<$Stream, $C, $Dir> for spi::$RxTx<$Peripheral, PINS, BIDI, OPERATION> {} + )+ + }; +} + #[cfg(any( feature = "stm32f401", feature = "stm32f417", @@ -329,14 +338,35 @@ dma_map!( (Stream7, 5, timer::CCR3, MemoryToPeripheral), //TIM3_CH3 (Stream7, 5, timer::CCR3, PeripheralToMemory), //TIM3_CH3 (Stream0, 0, pac::SPI3, PeripheralToMemory), //SPI3_RX - (Stream0, 0, spi::Rx, PeripheralToMemory), //SPI3_RX (Stream2, 0, pac::SPI3, PeripheralToMemory), //SPI3_RX - (Stream2, 0, spi::Rx, PeripheralToMemory), //SPI3_RX (Stream4, 3, pac::I2C3, MemoryToPeripheral), //I2C3_TX (Stream5, 0, pac::SPI3, MemoryToPeripheral), //SPI3_TX - (Stream5, 0, spi::Tx, MemoryToPeripheral), //SPI3_TX (Stream7, 0, pac::SPI3, MemoryToPeripheral), //SPI3_TX - (Stream7, 0, spi::Tx, MemoryToPeripheral), //SPI3_TX +); + +#[cfg(any( + feature = "stm32f401", + feature = "stm32f417", + feature = "stm32f415", + feature = "stm32f405", + feature = "stm32f407", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f439", + feature = "stm32f437", + feature = "stm32f429", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] +dma_spi_map!( + (Stream0, 0, Rx, pac::SPI3, PeripheralToMemory), //SPI3_RX + (Stream2, 0, Rx, pac::SPI3, PeripheralToMemory), //SPI3_RX + (Stream5, 0, Tx, pac::SPI3, MemoryToPeripheral), //SPI3_TX + (Stream7, 0, Tx, pac::SPI3, MemoryToPeripheral), //SPI3_TX ); #[cfg(any( @@ -433,10 +463,8 @@ dma_map!( (Stream0, 1, pac::I2C1, PeripheralToMemory), //I2C1_RX (Stream2, 7, pac::I2C2, PeripheralToMemory), //I2C2_RX (Stream3, 0, pac::SPI2, PeripheralToMemory), //SPI2_RX - (Stream3, 0, spi::Rx, PeripheralToMemory), //SPI2_RX (Stream3, 7, pac::I2C2, PeripheralToMemory), //I2C2_RX (Stream4, 0, pac::SPI2, MemoryToPeripheral), //SPI2_TX - (Stream4, 0, spi::Tx, MemoryToPeripheral), // SPI2_TX (Stream5, 1, pac::I2C1, PeripheralToMemory), //I2C1_RX (Stream5, 4, pac::USART2, PeripheralToMemory), //USART2_RX (Stream5, 4, serial::Rx, PeripheralToMemory), //USART2_RX @@ -446,11 +474,9 @@ dma_map!( (Stream0, 0, pac::ADC1, PeripheralToMemory), //ADC1 (Stream0, 0, Adc, PeripheralToMemory), (Stream0, 3, pac::SPI1, PeripheralToMemory), //SPI1_RX - (Stream0, 3, spi::Rx, PeripheralToMemory), //SPI1_RX (Stream1, 5, pac::USART6, PeripheralToMemory), //USART6_RX (Stream1, 5, serial::Rx, PeripheralToMemory), //USART6_RX (Stream2, 3, pac::SPI1, PeripheralToMemory), //SPI1_RX - (Stream2, 3, spi::Rx, PeripheralToMemory), //SPI1_RX (Stream2, 4, pac::USART1, PeripheralToMemory), //USART1_RX (Stream2, 4, serial::Rx, PeripheralToMemory), //USART1_RX (Stream2, 5, pac::USART6, PeripheralToMemory), //USART6_RX @@ -490,6 +516,33 @@ dma_map!( (Stream7, 0, MemoryToMemory, MemoryToMemory), ); +#[cfg(any( + feature = "stm32f401", + feature = "stm32f417", + feature = "stm32f415", + feature = "stm32f405", + feature = "stm32f407", + feature = "stm32f410", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f439", + feature = "stm32f437", + feature = "stm32f429", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] +dma_spi_map!( + (Stream3, 0, Rx, pac::SPI2, PeripheralToMemory), //SPI2_RX + (Stream4, 0, Tx, pac::SPI2, MemoryToPeripheral), // SPI2_TX + (Stream0, 3, Rx, pac::SPI1, PeripheralToMemory), //SPI1_RX + (Stream2, 3, Rx, pac::SPI1, PeripheralToMemory), //SPI1_RX +); + + #[cfg(any( feature = "stm32f401", feature = "stm32f417", @@ -572,9 +625,26 @@ dma_map!( (Stream6, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX (Stream7, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX (Stream3, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX - (Stream3, 3, spi::Tx, MemoryToPeripheral), //SPI1_TX (Stream5, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX - (Stream5, 3, spi::Tx, MemoryToPeripheral), //SPI1_TX +); + +#[cfg(any( + feature = "stm32f401", + feature = "stm32f417", + feature = "stm32f415", + feature = "stm32f405", + feature = "stm32f407", + feature = "stm32f427", + feature = "stm32f439", + feature = "stm32f437", + feature = "stm32f429", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] +dma_spi_map!( + (Stream3, 3, Tx, pac::SPI1, MemoryToPeripheral), //SPI1_TX + (Stream5, 3, Tx, pac::SPI1, MemoryToPeripheral), //SPI1_TX ); #[cfg(any( @@ -593,13 +663,30 @@ dma_map!( ))] dma_map!( (Stream0, 4, pac::SPI4, PeripheralToMemory), //SPI4_RX - (Stream0, 4, spi::Rx, PeripheralToMemory), //SPI4_RX (Stream1, 4, pac::SPI4, MemoryToPeripheral), //SPI4_TX - (Stream1, 4, spi::Tx, MemoryToPeripheral), //SPI4_TX (Stream3, 5, pac::SPI4, PeripheralToMemory), //SPI4_RX:DMA_CHANNEL_5 - (Stream3, 5, spi::Rx, PeripheralToMemory), //SPI4_RX:DMA_CHANNEL_5 (Stream4, 5, pac::SPI4, MemoryToPeripheral), //SPI4_TX:DMA_CHANNEL_5 - (Stream4, 5, spi::Tx, MemoryToPeripheral), //SPI4_TX:DMA_CHANNEL_5 +); + +#[cfg(any( + feature = "stm32f401", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f439", + feature = "stm32f437", + feature = "stm32f429", + feature = "stm32f446", + feature = "stm32f469", + feature = "stm32f479", +))] +dma_spi_map!( + (Stream0, 4, Rx, pac::SPI4, PeripheralToMemory), //SPI4_RX + (Stream1, 4, Tx, pac::SPI4, MemoryToPeripheral), //SPI4_TX + (Stream3, 5, Rx, pac::SPI4, PeripheralToMemory), //SPI4_RX:DMA_CHANNEL_5 + (Stream4, 5, Tx, pac::SPI4, MemoryToPeripheral), //SPI4_TX:DMA_CHANNEL_5 ); #[cfg(any( @@ -918,13 +1005,23 @@ dma_map!( (Stream7, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1 (Stream7, 6, pac::USART2, PeripheralToMemory), //USART2_RX:DMA_CHANNEL_6 (Stream2, 2, pac::SPI1, MemoryToPeripheral), //SPI1_TX - (Stream2, 2, spi::Tx, MemoryToPeripheral), //SPI1_TX (Stream3, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3 - (Stream3, 3, spi::Tx, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3 (Stream5, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3 - (Stream5, 3, spi::Tx, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3 (Stream5, 5, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_5 - (Stream5, 5, spi::Tx, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_5 +); + +#[cfg(any( + feature = "stm32f410", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f423", +))] +dma_spi_map!( + (Stream2, 2, Tx, pac::SPI1, MemoryToPeripheral), //SPI1_TX + (Stream3, 3, Tx, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3 + (Stream5, 3, Tx, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3 + (Stream5, 5, Tx, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_5 ); #[cfg(any( @@ -942,13 +1039,29 @@ dma_map!( ))] dma_map!( (Stream3, 2, pac::SPI5, PeripheralToMemory), //SPI5_RX - (Stream3, 2, spi::Rx, PeripheralToMemory), //SPI5_RX (Stream4, 2, pac::SPI5, MemoryToPeripheral), //SPI5_TX - (Stream4, 2, spi::Tx, MemoryToPeripheral), //SPI5_TX (Stream5, 7, pac::SPI5, PeripheralToMemory), //SPI5_RX:DMA_CHANNEL_7 - (Stream5, 7, spi::Rx, PeripheralToMemory), //SPI5_RX:DMA_CHANNEL_7 (Stream6, 7, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_7 - (Stream6, 7, spi::Tx, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_7 +); + +#[cfg(any( + feature = "stm32f410", + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f423", + feature = "stm32f427", + feature = "stm32f439", + feature = "stm32f437", + feature = "stm32f429", + feature = "stm32f469", + feature = "stm32f479", +))] +dma_spi_map!( + (Stream3, 2, Rx, pac::SPI5, PeripheralToMemory), //SPI5_RX + (Stream4, 2, Tx, pac::SPI5, MemoryToPeripheral), //SPI5_TX + (Stream5, 7, Rx, pac::SPI5, PeripheralToMemory), //SPI5_RX:DMA_CHANNEL_7 + (Stream6, 7, Tx, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_7 ); #[cfg(any( @@ -974,8 +1087,17 @@ address!((pac::SPI5, dr, u8),); ))] dma_map!( (Stream4, 4, pac::SPI4, PeripheralToMemory), //SPI4_RX); - (Stream4, 4, spi::Rx, PeripheralToMemory), -); //SPI4_RX); +); + +#[cfg(any( + feature = "stm32f411", + feature = "stm32f412", + feature = "stm32f413", + feature = "stm32f423", +))] +dma_spi_map!( + (Stream4, 4, Rx, pac::SPI4, PeripheralToMemory), // SPI4_RX +); /* TODO: DFSDM support #[cfg(feature = "stm32f412")] @@ -1129,9 +1251,20 @@ address!( ))] dma_map!( (Stream5, 1, pac::SPI6, MemoryToPeripheral), //SPI6_TX - (Stream5, 1, spi::Tx, MemoryToPeripheral), //SPI6_TX (Stream6, 1, pac::SPI6, PeripheralToMemory), //SPI6_RX - (Stream6, 1, spi::Rx, PeripheralToMemory), //SPI6_RX +); + +#[cfg(any( + feature = "stm32f427", + feature = "stm32f439", + feature = "stm32f437", + feature = "stm32f429", + feature = "stm32f469", + feature = "stm32f479", +))] +dma_spi_map!( + (Stream5, 1, Tx, pac::SPI6, MemoryToPeripheral), //SPI6_TX + (Stream6, 1, Rx, pac::SPI6, PeripheralToMemory), //SPI6_RX ); #[cfg(any( diff --git a/src/spi.rs b/src/spi.rs index f11a040e..148f79c6 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -681,48 +681,54 @@ impl // Spi DMA impl Spi { - pub fn use_dma(self) -> DmaBuilder { - DmaBuilder { spi: self.spi } + pub fn use_dma(self) -> DmaBuilder { + DmaBuilder { spi: self } } } -pub struct DmaBuilder { - spi: SPI, +pub struct DmaBuilder { + spi: Spi, } -pub struct Tx { - spi: PhantomData, +pub struct Tx { + spi: Spi, } -pub struct Rx { - spi: PhantomData, +pub struct Rx { + spi: Spi, } -impl DmaBuilder { - pub fn tx(self) -> Tx { - self.new_tx() +impl DmaBuilder { + pub fn tx(self) -> Tx { + self.spi.spi.cr2.modify(|_, w| w.txdmaen().enabled()); + Tx { spi: self.spi } } - pub fn rx(self) -> Rx { - self.new_rx() + pub fn rx(self) -> Rx { + self.spi.spi.cr2.modify(|_, w| w.rxdmaen().enabled()); + Rx { spi: self.spi } } - pub fn txrx(self) -> (Tx, Rx) { - (self.new_tx(), self.new_rx()) - } + // pub fn txrx(self) -> (Tx, Rx) { + // (self.new_tx(), self.new_rx()) + // } +} - fn new_tx(&self) -> Tx { - self.spi.cr2.modify(|_, w| w.txdmaen().enabled()); - Tx { spi: PhantomData } +impl Rx { + pub fn release(self) -> Spi { + self.spi.spi.cr2.modify(|_, w| w.rxdmaen().disabled()); + self.spi } +} - fn new_rx(self) -> Rx { - self.spi.cr2.modify(|_, w| w.rxdmaen().enabled()); - Rx { spi: PhantomData } +impl Tx { + pub fn release(self) -> Spi { + self.spi.spi.cr2.modify(|_, w| w.txdmaen().disabled()); + self.spi } } -unsafe impl PeriAddress for Rx { +unsafe impl PeriAddress for Rx { #[inline(always)] fn address(&self) -> u32 { unsafe { &(*SPI::ptr()).dr as *const _ as u32 } @@ -731,7 +737,7 @@ unsafe impl PeriAddress for Rx { type MemSize = u8; } -unsafe impl PeriAddress for Tx { +unsafe impl PeriAddress for Tx { #[inline(always)] fn address(&self) -> u32 { unsafe { &(*SPI::ptr()).dr as *const _ as u32 } From b841f0012db96994d6c1264e238fbf48656c93ad Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Thu, 13 Oct 2022 21:03:02 +0200 Subject: [PATCH 3/7] Coupled Tx/Rx for SPI DMA transfers --- Cargo.toml | 1 + src/dma/traits.rs | 6 ++++ src/spi.rs | 73 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 75 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7301e4a5..fe9ea735 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ rtic-monotonic = { version = "1.0", optional = true } systick-monotonic = { version = "1.0", optional = true } bitflags = "1.3.2" embedded-storage = "0.2" +paste = "1.0.9" [dependencies.time] version = "0.3.14" diff --git a/src/dma/traits.rs b/src/dma/traits.rs index 04c1d1dd..f365a71f 100644 --- a/src/dma/traits.rs +++ b/src/dma/traits.rs @@ -5,6 +5,7 @@ use crate::{ serial, spi, timer, }; use core::ops::Deref; +use paste::paste; pub(crate) mod sealed { /// Converts value to bits for setting a register value. @@ -288,6 +289,11 @@ macro_rules! dma_spi_map { $( unsafe impl DMASet<$Stream, $C, $Dir> for spi::$RxTx<$Peripheral, PINS, BIDI, OPERATION> {} + + paste! { + unsafe impl + DMASet<$Stream, $C, $Dir> for spi::[<$RxTx Coupled>]<$Peripheral, PINS, BIDI, OPERATION> {} + } )+ }; } diff --git a/src/spi.rs b/src/spi.rs index 148f79c6..07d17459 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -698,6 +698,14 @@ pub struct Rx { spi: Spi, } +pub struct TxCoupled { + spi: Spi, +} + +pub struct RxCoupled { + spi: PhantomData>, +} + impl DmaBuilder { pub fn tx(self) -> Tx { self.spi.spi.cr2.modify(|_, w| w.txdmaen().enabled()); @@ -709,9 +717,25 @@ impl DmaBuilder (Tx, Rx) { - // (self.new_tx(), self.new_rx()) - // } + pub fn txrx( + self, + ) -> ( + TxCoupled, + RxCoupled, + ) { + self.spi + .spi + .cr2 + .modify(|_, w| w.txdmaen().enabled().rxdmaen().enabled()); + ( + TxCoupled { + spi: self.spi + }, + RxCoupled { + spi: PhantomData + } + ) + } } impl Rx { @@ -728,7 +752,44 @@ impl Tx PeriAddress for Rx { +impl TxCoupled { + pub fn release(self, _couple: RxCoupled) -> Spi { + self.spi.spi.cr2.modify(|_, w| w.rxdmaen().disabled().txdmaen().disabled()); + self.spi + } +} + +impl RxCoupled { + pub fn release(self, couple: TxCoupled) -> Spi { + couple.release(self) + } +} + +unsafe impl PeriAddress + for Rx +{ + #[inline(always)] + fn address(&self) -> u32 { + unsafe { &(*SPI::ptr()).dr as *const _ as u32 } + } + + type MemSize = u8; +} + +unsafe impl PeriAddress + for Tx +{ + #[inline(always)] + fn address(&self) -> u32 { + unsafe { &(*SPI::ptr()).dr as *const _ as u32 } + } + + type MemSize = u8; +} + +unsafe impl PeriAddress + for RxCoupled +{ #[inline(always)] fn address(&self) -> u32 { unsafe { &(*SPI::ptr()).dr as *const _ as u32 } @@ -737,7 +798,9 @@ unsafe impl PeriAddress for Rx type MemSize = u8; } -unsafe impl PeriAddress for Tx { +unsafe impl PeriAddress + for TxCoupled +{ #[inline(always)] fn address(&self) -> u32 { unsafe { &(*SPI::ptr()).dr as *const _ as u32 } From a7915436fb34fe3d2aaceca59aef6c41a498918a Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Thu, 13 Oct 2022 21:06:26 +0200 Subject: [PATCH 4/7] Apply rustfmt --- src/dma/traits.rs | 1 - src/spi.rs | 24 +++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/dma/traits.rs b/src/dma/traits.rs index f365a71f..989a8a5f 100644 --- a/src/dma/traits.rs +++ b/src/dma/traits.rs @@ -548,7 +548,6 @@ dma_spi_map!( (Stream2, 3, Rx, pac::SPI1, PeripheralToMemory), //SPI1_RX ); - #[cfg(any( feature = "stm32f401", feature = "stm32f417", diff --git a/src/spi.rs b/src/spi.rs index 07d17459..190e7935 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -727,14 +727,7 @@ impl DmaBuilder Tx TxCoupled { - pub fn release(self, _couple: RxCoupled) -> Spi { - self.spi.spi.cr2.modify(|_, w| w.rxdmaen().disabled().txdmaen().disabled()); + pub fn release( + self, + _couple: RxCoupled, + ) -> Spi { + self.spi + .spi + .cr2 + .modify(|_, w| w.rxdmaen().disabled().txdmaen().disabled()); self.spi } } impl RxCoupled { - pub fn release(self, couple: TxCoupled) -> Spi { + pub fn release( + self, + couple: TxCoupled, + ) -> Spi { couple.release(self) } } From 8f1d6a98c4cf6d658f6e9a28997f291219d0463c Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Thu, 13 Oct 2022 21:11:54 +0200 Subject: [PATCH 5/7] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 863cc294..487e214e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `SysMonoTimerExt` helper trait, `Pwm::(get/set)_duty_time` [#497] - example of using i2s in out with rtic and interrupt. - example of using USB CDC with interrupts. +- Capability to release and reuse SPI peripheral after using it with DMA. [#481]: https://github.com/stm32-rs/stm32f4xx-hal/pull/481 [#489]: https://github.com/stm32-rs/stm32f4xx-hal/pull/489 From e6c4fcdccaa696e94b2bf739a0050164e4f6c452 Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Sun, 16 Oct 2022 20:46:55 +0200 Subject: [PATCH 6/7] Fix example --- examples/spi_dma.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/spi_dma.rs b/examples/spi_dma.rs index 3d5d8921..dd81de75 100644 --- a/examples/spi_dma.rs +++ b/examples/spi_dma.rs @@ -14,6 +14,7 @@ use stm32f4xx_hal::{ pac, prelude::*, spi::*, + gpio::{PB13, PB15}, }; const ARRAY_SIZE: usize = 100; @@ -21,7 +22,7 @@ const ARRAY_SIZE: usize = 100; type SpiDma = Transfer< Stream4, 0, - Tx, + Tx, MemoryToPeripheral, &'static mut [u8; ARRAY_SIZE], >; @@ -39,8 +40,8 @@ fn main() -> ! { let stream = steams.4; let gpiob = dp.GPIOB.split(); - let pb15 = gpiob.pb15.into_alternate().internal_pull_up(true); - let pb13 = gpiob.pb13.into_alternate(); + let pb15 = gpiob.pb15.internal_pull_up(true); + let pb13 = gpiob.pb13; let mode = Mode { polarity: Polarity::IdleLow, From de12a86fb44380296c2d847d016d9383303c8d3c Mon Sep 17 00:00:00 2001 From: Ivan Mikhailov Date: Mon, 17 Oct 2022 19:13:36 +0200 Subject: [PATCH 7/7] Apply rustfmt --- examples/spi_dma.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/spi_dma.rs b/examples/spi_dma.rs index dd81de75..c1b3ed8e 100644 --- a/examples/spi_dma.rs +++ b/examples/spi_dma.rs @@ -11,10 +11,10 @@ use embedded_hal::spi::{Mode, Phase, Polarity}; use stm32f4xx_hal::pac::interrupt; use stm32f4xx_hal::{ dma::{config, traits::StreamISR, MemoryToPeripheral, Stream4, StreamsTuple, Transfer}, + gpio::{PB13, PB15}, pac, prelude::*, spi::*, - gpio::{PB13, PB15}, }; const ARRAY_SIZE: usize = 100;