Skip to content

Commit 564f7aa

Browse files
dtjones-atsemvertescher
authored andcommitted
Able to compile for all stm327xx series.
Existing SPI/DMA hal not compatible with 722,723,732,733
1 parent 2e3c2e9 commit 564f7aa

File tree

6 files changed

+310
-100
lines changed

6 files changed

+310
-100
lines changed

Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@ panic-semihosting = "0.5.2"
4444

4545
[features]
4646
device-selected = []
47+
dma-support = []
4748
rt = ["stm32f7/rt"]
4849
stm32f722 = ["stm32f7/stm32f7x2", "device-selected"]
4950
stm32f723 = ["stm32f7/stm32f7x3", "device-selected"]
5051
stm32f732 = ["stm32f7/stm32f7x2", "device-selected"]
5152
stm32f733 = ["stm32f7/stm32f7x3", "device-selected"]
52-
stm32f745 = ["stm32f7/stm32f745", "device-selected"]
53-
stm32f746 = ["stm32f7/stm32f7x6", "device-selected"]
54-
stm32f756 = ["stm32f7/stm32f7x6", "device-selected"]
55-
stm32f765 = ["stm32f7/stm32f765", "device-selected"]
56-
stm32f767 = ["stm32f7/stm32f7x7", "device-selected"]
57-
stm32f769 = ["stm32f7/stm32f7x9", "device-selected"]
58-
stm32f777 = ["stm32f7/stm32f7x7", "device-selected"]
59-
stm32f778 = ["stm32f7/stm32f7x9", "device-selected"]
60-
stm32f779 = ["stm32f7/stm32f7x9", "device-selected"]
53+
stm32f745 = ["stm32f7/stm32f745", "device-selected","dma-support"]
54+
stm32f746 = ["stm32f7/stm32f7x6", "device-selected","dma-support"]
55+
stm32f756 = ["stm32f7/stm32f7x6", "device-selected","dma-support"]
56+
stm32f765 = ["stm32f7/stm32f765", "device-selected","dma-support"]
57+
stm32f767 = ["stm32f7/stm32f7x7", "device-selected","dma-support"]
58+
stm32f769 = ["stm32f7/stm32f7x9", "device-selected","dma-support"]
59+
stm32f777 = ["stm32f7/stm32f7x7", "device-selected","dma-support"]
60+
stm32f778 = ["stm32f7/stm32f7x9", "device-selected","dma-support"]
61+
stm32f779 = ["stm32f7/stm32f7x9", "device-selected","dma-support"]
6162

6263
[profile.dev]
6364
incremental = false

src/dma.rs

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use as_slice::AsSlice;
1212

1313
use crate::{
1414
device::{
15+
self,
1516
dma2::{self, st::cr},
16-
Interrupt, DMA1, DMA2, NVIC, SPI1, SPI2, SPI3, SPI4, SPI5, SPI6, UART4, UART5, UART7,
17-
UART8, USART1, USART2, USART3, USART6,
17+
Interrupt, DMA1, DMA2, NVIC,
1818
},
1919
rcc::Rcc,
2020
serial, spi, state,
@@ -389,54 +389,69 @@ 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+
))]
392407
impl_target!(
393408
// SPI receive
394-
spi::Rx<SPI1>, DMA2, Stream0, Channel3, DMA2_STREAM0;
409+
spi::Rx<device::SPI1>, DMA2, Stream0, Channel3, DMA2_STREAM0;
395410
// SPI1 for DMA2, stream 2, channel 3 is unsupported
396-
spi::Rx<SPI2>, DMA1, Stream3, Channel0, DMA1_STREAM3;
397-
spi::Rx<SPI3>, DMA1, Stream0, Channel0, DMA1_STREAM0;
411+
spi::Rx<device::SPI2>, DMA1, Stream3, Channel0, DMA1_STREAM3;
412+
spi::Rx<device::SPI3>, DMA1, Stream0, Channel0, DMA1_STREAM0;
398413
// SPI3 for DMA1, stream 2, channel 0 is unsupported
399-
spi::Rx<SPI4>, DMA2, Stream0, Channel4, DMA2_STREAM0;
414+
spi::Rx<device::SPI4>, DMA2, Stream0, Channel4, DMA2_STREAM0;
400415
// SPI4 for DMA2, stream 3, channel 5 is unsupported
401-
spi::Rx<SPI5>, DMA2, Stream3, Channel2, DMA2_STREAM3;
416+
spi::Rx<device::SPI5>, DMA2, Stream3, Channel2, DMA2_STREAM3;
402417
// SPI5 for DMA2, stream 5, channel 7 is unsupported
403-
spi::Rx<SPI6>, DMA2, Stream6, Channel1, DMA2_STREAM6;
418+
spi::Rx<device::SPI6>, DMA2, Stream6, Channel1, DMA2_STREAM6;
404419

405420
// SPI transmit
406-
spi::Tx<SPI1>, DMA2, Stream3, Channel3, DMA2_STREAM3;
421+
spi::Tx<device::SPI1>, DMA2, Stream3, Channel3, DMA2_STREAM3;
407422
// SPI1 for DMA2, stream 5, channel 3 is unsupported
408-
spi::Tx<SPI2>, DMA1, Stream4, Channel0, DMA1_STREAM4;
409-
spi::Tx<SPI3>, DMA1, Stream5, Channel0, DMA1_STREAM5;
423+
spi::Tx<device::SPI2>, DMA1, Stream4, Channel0, DMA1_STREAM4;
424+
spi::Tx<device::SPI3>, DMA1, Stream5, Channel0, DMA1_STREAM5;
410425
// SPI3 for DMA1, stream 7, channel 0 is unsupported
411-
spi::Tx<SPI4>, DMA2, Stream1, Channel4, DMA2_STREAM1;
426+
spi::Tx<device::SPI4>, DMA2, Stream1, Channel4, DMA2_STREAM1;
412427
// SPI4 for DMA2, stream 4, channel 5 is unsupported
413-
spi::Tx<SPI5>, DMA2, Stream4, Channel2, DMA2_STREAM4;
428+
spi::Tx<device::SPI5>, DMA2, Stream4, Channel2, DMA2_STREAM4;
414429
// SPI5 for DMA2, stream 6, channel 7 is unsupported
415-
spi::Tx<SPI6>, DMA2, Stream5, Channel1, DMA2_STREAM5;
430+
spi::Tx<device::SPI6>, DMA2, Stream5, Channel1, DMA2_STREAM5;
416431

417432
// USART receive
418-
serial::Rx<USART1>, DMA2, Stream2, Channel4, DMA2_STREAM2;
433+
serial::Rx<device::USART1>, DMA2, Stream2, Channel4, DMA2_STREAM2;
419434
// USART1 for DMA2, stream 5, channel 4 is unsupported
420-
serial::Rx<USART2>, DMA1, Stream5, Channel4, DMA1_STREAM5;
421-
serial::Rx<USART3>, DMA1, Stream1, Channel4, DMA1_STREAM1;
422-
serial::Rx<UART4>, DMA1, Stream2, Channel4, DMA1_STREAM2;
423-
serial::Rx<UART5>, DMA1, Stream0, Channel4, DMA1_STREAM0;
424-
serial::Rx<USART6>, DMA2, Stream1, Channel5, DMA2_STREAM1;
435+
serial::Rx<device::USART2>, DMA1, Stream5, Channel4, DMA1_STREAM5;
436+
serial::Rx<device::USART3>, DMA1, Stream1, Channel4, DMA1_STREAM1;
437+
serial::Rx<device::UART4>, DMA1, Stream2, Channel4, DMA1_STREAM2;
438+
serial::Rx<device::UART5>, DMA1, Stream0, Channel4, DMA1_STREAM0;
439+
serial::Rx<device::USART6>, DMA2, Stream1, Channel5, DMA2_STREAM1;
425440
// USART6 for DMA2, stream 2, channel 5 is unsupported
426-
serial::Rx<UART7>, DMA1, Stream3, Channel5, DMA1_STREAM3;
427-
serial::Rx<UART8>, DMA1, Stream6, Channel5, DMA1_STREAM6;
441+
serial::Rx<device::UART7>, DMA1, Stream3, Channel5, DMA1_STREAM3;
442+
serial::Rx<device::UART8>, DMA1, Stream6, Channel5, DMA1_STREAM6;
428443

429444
// USART transmit
430-
serial::Tx<USART1>, DMA2, Stream7, Channel4, DMA2_STREAM7;
431-
serial::Tx<USART2>, DMA1, Stream6, Channel4, DMA1_STREAM6;
432-
serial::Tx<USART3>, DMA1, Stream3, Channel4, DMA1_STREAM3;
445+
serial::Tx<device::USART1>, DMA2, Stream7, Channel4, DMA2_STREAM7;
446+
serial::Tx<device::USART2>, DMA1, Stream6, Channel4, DMA1_STREAM6;
447+
serial::Tx<device::USART3>, DMA1, Stream3, Channel4, DMA1_STREAM3;
433448
// USART3 for DMA1, stream 4, channel 7 is unsupported
434-
serial::Tx<UART4>, DMA1, Stream4, Channel4, DMA1_STREAM4;
435-
serial::Tx<UART5>, DMA1, Stream7, Channel4, DMA1_STREAM7;
436-
serial::Tx<USART6>, DMA2, Stream6, Channel5, DMA2_STREAM6;
449+
serial::Tx<device::UART4>, DMA1, Stream4, Channel4, DMA1_STREAM4;
450+
serial::Tx<device::UART5>, DMA1, Stream7, Channel4, DMA1_STREAM7;
451+
serial::Tx<device::USART6>, DMA2, Stream6, Channel5, DMA2_STREAM6;
437452
// USART6 for DMA2, stream 7, channel 5 is unsupported
438-
serial::Tx<UART7>, DMA1, Stream1, Channel5, DMA1_STREAM1;
439-
serial::Tx<UART8>, DMA1, Stream0, Channel5, DMA1_STREAM0;
453+
serial::Tx<device::UART7>, DMA1, Stream1, Channel5, DMA1_STREAM1;
454+
serial::Tx<device::UART8>, DMA1, Stream0, Channel5, DMA1_STREAM0;
440455
);
441456

442457
/// Implemented for all types that represent DMA streams

src/gpio.rs

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,21 @@ macro_rules! gpio {
671671
}
672672
}
673673

674+
#[cfg(any(
675+
feature = "stm32f722",
676+
feature = "stm32f723",
677+
feature = "stm32f732",
678+
feature = "stm32f733",
679+
feature = "stm32f745",
680+
feature = "stm32f746",
681+
feature = "stm32f756",
682+
feature = "stm32f765",
683+
feature = "stm32f767",
684+
feature = "stm32f769",
685+
feature = "stm32f777",
686+
feature = "stm32f778",
687+
feature = "stm32f779",
688+
))]
674689
gpio!(GPIOA, gpioa, gpioaen, PA, 0, [
675690
PA0: (pa0, 0, Input<Floating>, exticr1),
676691
PA1: (pa1, 1, Input<Floating>, exticr1),
@@ -690,6 +705,21 @@ gpio!(GPIOA, gpioa, gpioaen, PA, 0, [
690705
PA15: (pa15, 15, Input<Floating>, exticr4),
691706
]);
692707

708+
#[cfg(any(
709+
feature = "stm32f722",
710+
feature = "stm32f723",
711+
feature = "stm32f732",
712+
feature = "stm32f733",
713+
feature = "stm32f745",
714+
feature = "stm32f746",
715+
feature = "stm32f756",
716+
feature = "stm32f765",
717+
feature = "stm32f767",
718+
feature = "stm32f769",
719+
feature = "stm32f777",
720+
feature = "stm32f778",
721+
feature = "stm32f779",
722+
))]
693723
gpio!(GPIOB, gpiob, gpioben, PB, 1, [
694724
PB0: (pb0, 0, Input<Floating>, exticr1),
695725
PB1: (pb1, 1, Input<Floating>, exticr1),
@@ -709,6 +739,21 @@ gpio!(GPIOB, gpiob, gpioben, PB, 1, [
709739
PB15: (pb15, 15, Input<Floating>, exticr4),
710740
]);
711741

742+
#[cfg(any(
743+
feature = "stm32f722",
744+
feature = "stm32f723",
745+
feature = "stm32f732",
746+
feature = "stm32f733",
747+
feature = "stm32f745",
748+
feature = "stm32f746",
749+
feature = "stm32f756",
750+
feature = "stm32f765",
751+
feature = "stm32f767",
752+
feature = "stm32f769",
753+
feature = "stm32f777",
754+
feature = "stm32f778",
755+
feature = "stm32f779",
756+
))]
712757
gpio!(GPIOC, gpioc, gpiocen, PC, 2, [
713758
PC0: (pc0, 0, Input<Floating>, exticr1),
714759
PC1: (pc1, 1, Input<Floating>, exticr1),
@@ -728,6 +773,21 @@ gpio!(GPIOC, gpioc, gpiocen, PC, 2, [
728773
PC15: (pc15, 15, Input<Floating>, exticr4),
729774
]);
730775

776+
#[cfg(any(
777+
feature = "stm32f722",
778+
feature = "stm32f723",
779+
feature = "stm32f732",
780+
feature = "stm32f733",
781+
feature = "stm32f745",
782+
feature = "stm32f746",
783+
feature = "stm32f756",
784+
feature = "stm32f765",
785+
feature = "stm32f767",
786+
feature = "stm32f769",
787+
feature = "stm32f777",
788+
feature = "stm32f778",
789+
feature = "stm32f779",
790+
))]
731791
gpio!(GPIOD, gpiod, gpioden, pd, 3, [
732792
PD0: (pd0, 0, Input<Floating>, exticr1),
733793
PD1: (pd1, 1, Input<Floating>, exticr1),
@@ -747,6 +807,21 @@ gpio!(GPIOD, gpiod, gpioden, pd, 3, [
747807
PD15: (pd15, 15, Input<Floating>, exticr4),
748808
]);
749809

810+
#[cfg(any(
811+
feature = "stm32f722",
812+
feature = "stm32f723",
813+
feature = "stm32f732",
814+
feature = "stm32f733",
815+
feature = "stm32f745",
816+
feature = "stm32f746",
817+
feature = "stm32f756",
818+
feature = "stm32f765",
819+
feature = "stm32f767",
820+
feature = "stm32f769",
821+
feature = "stm32f777",
822+
feature = "stm32f778",
823+
feature = "stm32f779",
824+
))]
750825
gpio!(GPIOE, gpioe, gpioeen, PE, 4, [
751826
PE0: (pe0, 0, Input<Floating>, exticr1),
752827
PE1: (pe1, 1, Input<Floating>, exticr1),
@@ -766,6 +841,21 @@ gpio!(GPIOE, gpioe, gpioeen, PE, 4, [
766841
PE15: (pe15, 15, Input<Floating>, exticr4),
767842
]);
768843

844+
#[cfg(any(
845+
feature = "stm32f722",
846+
feature = "stm32f723",
847+
feature = "stm32f732",
848+
feature = "stm32f733",
849+
feature = "stm32f745",
850+
feature = "stm32f746",
851+
feature = "stm32f756",
852+
feature = "stm32f765",
853+
feature = "stm32f767",
854+
feature = "stm32f769",
855+
feature = "stm32f777",
856+
feature = "stm32f778",
857+
feature = "stm32f779",
858+
))]
769859
gpio!(GPIOF, gpiof, gpiofen, PF, 5, [
770860
PF0: (pf0, 0, Input<Floating>, exticr1),
771861
PF1: (pf1, 1, Input<Floating>, exticr1),
@@ -785,6 +875,21 @@ gpio!(GPIOF, gpiof, gpiofen, PF, 5, [
785875
PF15: (pf15, 15, Input<Floating>, exticr4),
786876
]);
787877

878+
#[cfg(any(
879+
feature = "stm32f722",
880+
feature = "stm32f723",
881+
feature = "stm32f732",
882+
feature = "stm32f733",
883+
feature = "stm32f745",
884+
feature = "stm32f746",
885+
feature = "stm32f756",
886+
feature = "stm32f765",
887+
feature = "stm32f767",
888+
feature = "stm32f769",
889+
feature = "stm32f777",
890+
feature = "stm32f778",
891+
feature = "stm32f779",
892+
))]
788893
gpio!(GPIOG, gpiog, gpiogen, PG, 6,[
789894
PG0: (pg0, 0, Input<Floating>, exticr1),
790895
PG1: (pg1, 1, Input<Floating>, exticr1),
@@ -804,6 +909,21 @@ gpio!(GPIOG, gpiog, gpiogen, PG, 6,[
804909
PG15: (pg15, 15, Input<Floating>, exticr4),
805910
]);
806911

912+
#[cfg(any(
913+
feature = "stm32f722",
914+
feature = "stm32f723",
915+
feature = "stm32f732",
916+
feature = "stm32f733",
917+
feature = "stm32f745",
918+
feature = "stm32f746",
919+
feature = "stm32f756",
920+
feature = "stm32f765",
921+
feature = "stm32f767",
922+
feature = "stm32f769",
923+
feature = "stm32f777",
924+
feature = "stm32f778",
925+
feature = "stm32f779",
926+
))]
807927
gpio!(GPIOH, gpioh, gpiohen, PH, 7, [
808928
PH0: (ph0, 0, Input<Floating>, exticr1),
809929
PH1: (ph1, 1, Input<Floating>, exticr1),
@@ -823,6 +943,21 @@ gpio!(GPIOH, gpioh, gpiohen, PH, 7, [
823943
PH15: (ph15, 15, Input<Floating>, exticr4),
824944
]);
825945

946+
#[cfg(any(
947+
feature = "stm32f722",
948+
feature = "stm32f723",
949+
feature = "stm32f732",
950+
feature = "stm32f733",
951+
feature = "stm32f745",
952+
feature = "stm32f746",
953+
feature = "stm32f756",
954+
feature = "stm32f765",
955+
feature = "stm32f767",
956+
feature = "stm32f769",
957+
feature = "stm32f777",
958+
feature = "stm32f778",
959+
feature = "stm32f779",
960+
))]
826961
gpio!(GPIOI, gpioi, gpioien, PI, 8, [
827962
PI0: (pi0, 0, Input<Floating>, exticr1),
828963
PI1: (pi1, 1, Input<Floating>, exticr1),
@@ -842,6 +977,17 @@ gpio!(GPIOI, gpioi, gpioien, PI, 8, [
842977
PI15: (pi15, 15, Input<Floating>, exticr4),
843978
]);
844979

980+
#[cfg(any(
981+
feature = "stm32f745",
982+
feature = "stm32f746",
983+
feature = "stm32f756",
984+
feature = "stm32f765",
985+
feature = "stm32f767",
986+
feature = "stm32f769",
987+
feature = "stm32f777",
988+
feature = "stm32f778",
989+
feature = "stm32f779",
990+
))]
845991
gpio!(GPIOJ, gpioj, gpiojen, PJ, 9, [
846992
PJ0: (pj0, 0, Input<Floating>, exticr1),
847993
PJ1: (pj1, 1, Input<Floating>, exticr1),
@@ -861,6 +1007,17 @@ gpio!(GPIOJ, gpioj, gpiojen, PJ, 9, [
8611007
PJ15: (pj15, 15, Input<Floating>, exticr4),
8621008
]);
8631009

1010+
#[cfg(any(
1011+
feature = "stm32f745",
1012+
feature = "stm32f746",
1013+
feature = "stm32f756",
1014+
feature = "stm32f765",
1015+
feature = "stm32f767",
1016+
feature = "stm32f769",
1017+
feature = "stm32f777",
1018+
feature = "stm32f778",
1019+
feature = "stm32f779",
1020+
))]
8641021
gpio!(GPIOK, gpiok, gpioken, PK, 10, [
8651022
PK0: (pk0, 0, Input<Floating>, exticr1),
8661023
PK1: (pk1, 1, Input<Floating>, exticr1),

src/lib.rs

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

73-
#[cfg(feature = "device-selected")]
73+
#[cfg(feature = "dma-support")]
7474
pub mod dma;
7575

7676
#[cfg(feature = "device-selected")]
@@ -85,7 +85,7 @@ pub mod rcc;
8585
#[cfg(feature = "device-selected")]
8686
pub mod serial;
8787

88-
#[cfg(feature = "device-selected")]
88+
#[cfg(feature = "dma-support")]
8989
pub mod spi;
9090

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

0 commit comments

Comments
 (0)