Skip to content

Commit 07365ca

Browse files
rfuestmvertescher
authored andcommitted
Enable DMA and SPI for all devices
1 parent d44a093 commit 07365ca

File tree

5 files changed

+28
-59
lines changed

5 files changed

+28
-59
lines changed

Cargo.toml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,22 @@ embedded-graphics = "0.6.1"
4646

4747
[features]
4848
device-selected = []
49-
dma-support = []
5049
ltdc = []
5150
rt = ["stm32f7/rt"]
5251
stm32f722 = ["stm32f7/stm32f7x2", "device-selected"]
5352
stm32f723 = ["stm32f7/stm32f7x3", "device-selected"]
5453
stm32f730 = ["stm32f7/stm32f730", "device-selected"]
5554
stm32f732 = ["stm32f7/stm32f7x2", "device-selected"]
5655
stm32f733 = ["stm32f7/stm32f7x3", "device-selected"]
57-
stm32f745 = ["stm32f7/stm32f745", "device-selected","dma-support"]
58-
stm32f746 = ["stm32f7/stm32f7x6", "device-selected","dma-support","ltdc"]
59-
stm32f756 = ["stm32f7/stm32f7x6", "device-selected","dma-support","ltdc"]
60-
stm32f765 = ["stm32f7/stm32f765", "device-selected","dma-support"]
61-
stm32f767 = ["stm32f7/stm32f7x7", "device-selected","dma-support","ltdc"]
62-
stm32f769 = ["stm32f7/stm32f7x9", "device-selected","dma-support","ltdc"]
63-
stm32f777 = ["stm32f7/stm32f7x7", "device-selected","dma-support","ltdc"]
64-
stm32f778 = ["stm32f7/stm32f7x9", "device-selected","dma-support","ltdc"]
65-
stm32f779 = ["stm32f7/stm32f7x9", "device-selected","dma-support","ltdc"]
56+
stm32f745 = ["stm32f7/stm32f745", "device-selected"]
57+
stm32f746 = ["stm32f7/stm32f7x6", "device-selected", "ltdc"]
58+
stm32f756 = ["stm32f7/stm32f7x6", "device-selected", "ltdc"]
59+
stm32f765 = ["stm32f7/stm32f765", "device-selected"]
60+
stm32f767 = ["stm32f7/stm32f7x7", "device-selected", "ltdc"]
61+
stm32f769 = ["stm32f7/stm32f7x9", "device-selected", "ltdc"]
62+
stm32f777 = ["stm32f7/stm32f7x7", "device-selected", "ltdc"]
63+
stm32f778 = ["stm32f7/stm32f7x9", "device-selected", "ltdc"]
64+
stm32f779 = ["stm32f7/stm32f7x9", "device-selected", "ltdc"]
6665

6766
[profile.dev]
6867
incremental = false

src/dma.rs

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -389,21 +389,6 @@ macro_rules! impl_target {
389389
//
390390
// There's probably a smart way to achieve this, but I decided to declare
391391
// victory and leave this problem to someone who actually needs this capability.
392-
#[cfg(any(
393-
feature = "stm32f722",
394-
feature = "stm32f723",
395-
feature = "stm32f732",
396-
feature = "stm32f733",
397-
feature = "stm32f745",
398-
feature = "stm32f746",
399-
feature = "stm32f756",
400-
feature = "stm32f765",
401-
feature = "stm32f767",
402-
feature = "stm32f769",
403-
feature = "stm32f777",
404-
feature = "stm32f778",
405-
feature = "stm32f779",
406-
))]
407392
impl_target!(
408393
// SPI receive
409394
spi::Rx<device::SPI1>, DMA2, Stream0, Channel3, DMA2_STREAM0;
@@ -415,7 +400,6 @@ impl_target!(
415400
// SPI4 for DMA2, stream 3, channel 5 is unsupported
416401
spi::Rx<device::SPI5>, DMA2, Stream3, Channel2, DMA2_STREAM3;
417402
// SPI5 for DMA2, stream 5, channel 7 is unsupported
418-
spi::Rx<device::SPI6>, DMA2, Stream6, Channel1, DMA2_STREAM6;
419403

420404
// SPI transmit
421405
spi::Tx<device::SPI1>, DMA2, Stream3, Channel3, DMA2_STREAM3;
@@ -427,7 +411,6 @@ impl_target!(
427411
// SPI4 for DMA2, stream 4, channel 5 is unsupported
428412
spi::Tx<device::SPI5>, DMA2, Stream4, Channel2, DMA2_STREAM4;
429413
// SPI5 for DMA2, stream 6, channel 7 is unsupported
430-
spi::Tx<device::SPI6>, DMA2, Stream5, Channel1, DMA2_STREAM5;
431414

432415
// USART receive
433416
serial::Rx<device::USART1>, DMA2, Stream2, Channel4, DMA2_STREAM2;
@@ -454,6 +437,22 @@ impl_target!(
454437
serial::Tx<device::UART8>, DMA1, Stream0, Channel5, DMA1_STREAM0;
455438
);
456439

440+
#[cfg(any(
441+
feature = "stm32f745",
442+
feature = "stm32f746",
443+
feature = "stm32f756",
444+
feature = "stm32f765",
445+
feature = "stm32f767",
446+
feature = "stm32f769",
447+
feature = "stm32f777",
448+
feature = "stm32f778",
449+
feature = "stm32f779",
450+
))]
451+
impl_target!(
452+
spi::Rx<device::SPI6>, DMA2, Stream6, Channel1, DMA2_STREAM6;
453+
spi::Tx<device::SPI6>, DMA2, Stream5, Channel1, DMA2_STREAM5;
454+
);
455+
457456
/// Implemented for all types that represent DMA streams
458457
///
459458
/// This is an internal trait. End users neither need to implement it, nor use
@@ -578,7 +577,7 @@ macro_rules! impl_channel {
578577
{
579578
// This is safe, as long as the macro caller passes in valid
580579
// channel numbers.
581-
unsafe { w.chsel().bits($number) }
580+
w.chsel().bits($number)
582581
}
583582
}
584583
)*

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ pub use crate::device::interrupt;
7474
#[cfg(feature = "device-selected")]
7575
pub mod delay;
7676

77-
#[cfg(feature = "dma-support")]
77+
#[cfg(feature = "device-selected")]
7878
pub mod dma;
7979

8080
#[cfg(feature = "device-selected")]
@@ -89,7 +89,7 @@ pub mod rcc;
8989
#[cfg(feature = "device-selected")]
9090
pub mod serial;
9191

92-
#[cfg(feature = "dma-support")]
92+
#[cfg(feature = "device-selected")]
9393
pub mod spi;
9494

9595
#[cfg(feature = "device-selected")]

src/serial.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
use core::fmt;
22
use core::marker::PhantomData;
33
use core::ops::Deref;
4-
#[cfg(feature="dma-support")]
54
use core::ops::DerefMut;
6-
#[cfg(feature="dma-support")]
75
use core::pin::Pin;
86
use core::ptr;
97

10-
#[cfg(feature="dma-support")]
118
use as_slice::{AsMutSlice, AsSlice};
129

1310
use crate::device;
14-
#[cfg(feature="dma-support")]
1511
use crate::dma;
1612
use crate::hal::prelude::*;
1713
use crate::hal::serial;
18-
#[cfg(feature="dma-support")]
1914
use crate::state;
2015
use crate::time::U32Ext;
2116
use nb::block;
@@ -219,7 +214,6 @@ pub struct Rx<USART> {
219214
_usart: PhantomData<USART>,
220215
}
221216

222-
#[cfg(feature="dma-support")]
223217
impl<USART> Rx<USART>
224218
where
225219
USART: Instance,
@@ -306,7 +300,6 @@ pub struct Tx<USART> {
306300
_usart: PhantomData<USART>,
307301
}
308302

309-
#[cfg(feature="dma-support")]
310303
impl<USART> Tx<USART>
311304
where
312305
Self: dma::Target,

src/spi.rs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use crate::{
2323
state,
2424
};
2525

26-
#[cfg(feature="dma-support")]
2726
use crate::dma;
2827

2928
/// Entry point to the SPI API
@@ -72,7 +71,6 @@ where
7271
}
7372
}
7473

75-
#[cfg(feature="dma-support")]
7674
impl<I, P, Word> Spi<I, P, Enabled<Word>>
7775
where
7876
I: Instance,
@@ -454,21 +452,6 @@ macro_rules! impl_instance {
454452
}
455453
}
456454

457-
#[cfg(any(
458-
feature = "stm32f722",
459-
feature = "stm32f723",
460-
feature = "stm32f732",
461-
feature = "stm32f733",
462-
feature = "stm32f745",
463-
feature = "stm32f746",
464-
feature = "stm32f756",
465-
feature = "stm32f765",
466-
feature = "stm32f767",
467-
feature = "stm32f769",
468-
feature = "stm32f777",
469-
feature = "stm32f778",
470-
feature = "stm32f779",
471-
))]
472455
impl_instance!(
473456
device::SPI1 {
474457
regs: (apb2, spi1rst, spi1en),
@@ -566,9 +549,6 @@ impl_instance!(
566549
);
567550

568551
#[cfg(any(
569-
feature = "stm32f723",
570-
feature = "stm32f732",
571-
feature = "stm32f733",
572552
feature = "stm32f745",
573553
feature = "stm32f746",
574554
feature = "stm32f756",
@@ -736,7 +716,6 @@ where
736716
}
737717

738718
/// The resources that an ongoing transfer needs exclusive access to
739-
#[cfg(feature="dma-support")]
740719
pub struct TransferResources<Word, I, P, Rx: dma::Target, Tx: dma::Target, Buffer> {
741720
pub rx_stream: Rx::Stream,
742721
pub tx_stream: Tx::Stream,
@@ -747,7 +726,6 @@ pub struct TransferResources<Word, I, P, Rx: dma::Target, Tx: dma::Target, Buffe
747726
// As `TransferResources` is used in the error variant of `Result`, it needs a
748727
// `Debug` implementation to enable stuff like `unwrap` and `expect`. This can't
749728
// be derived without putting requirements on the type arguments.
750-
#[cfg(feature="dma-support")]
751729
impl<Word, I, P, Rx, Tx, Buffer> fmt::Debug for TransferResources<Word, I, P, Rx, Tx, Buffer>
752730
where
753731
Rx: dma::Target,

0 commit comments

Comments
 (0)