Skip to content

Commit be8a84b

Browse files
bors[bot]burrbull
andauthored
Merge #614
614: DMASet autoimpl r=therealprof a=burrbull Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
2 parents 5a39f12 + 42e39b9 commit be8a84b

File tree

7 files changed

+131
-98
lines changed

7 files changed

+131
-98
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Add autoimplementations of `DMASet` [#614]
1011
- Simplify `gpio::Outport` [#611]
1112
- Split SPI master and slave implementations [#609]
1213
- Split USART and UART implementations [#608]
@@ -32,6 +33,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3233
[#608]: https://github.com/stm32-rs/stm32f4xx-hal/pull/608
3334
[#609]: https://github.com/stm32-rs/stm32f4xx-hal/pull/609
3435
[#611]: https://github.com/stm32-rs/stm32f4xx-hal/pull/611
36+
[#614]: https://github.com/stm32-rs/stm32f4xx-hal/pull/614
3537

3638
## [v0.15.0] - 2023-03-13
3739

src/adc.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
Temperature in °C = (110-30) * (adc_sample - VtempCal30::get().read()) / (VtempCal110::get().read()-VtempCal30::get().read()) + 30
99
*/
1010

11-
use crate::dma::traits::{PeriAddress, SafePeripheralRead};
11+
use crate::dma::traits::{DMASet, PeriAddress, SafePeripheralRead};
12+
use crate::dma::PeripheralToMemory;
1213
use crate::rcc::{Enable, Reset};
1314
use crate::{
1415
gpio::{self, Analog},
@@ -1096,6 +1097,11 @@ macro_rules! adc {
10961097
};
10971098
}
10981099

1100+
unsafe impl<ADC, STREAM, const CHANNEL: u8> DMASet<STREAM, CHANNEL, PeripheralToMemory> for Adc<ADC> where
1101+
ADC: DMASet<STREAM, CHANNEL, PeripheralToMemory>
1102+
{
1103+
}
1104+
10991105
adc!(ADC1 => (adc1, ADC_COMMON, 8));
11001106

11011107
#[cfg(feature = "adc2")]

src/dma/traits.rs

Lines changed: 75 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
use super::*;
2-
#[cfg(feature = "uart4")]
3-
use crate::uart;
42
use crate::{
5-
adc::Adc,
6-
i2c,
73
pac::{self, DMA1, DMA2},
8-
serial, spi, timer,
4+
timer,
95
};
106
use core::ops::Deref;
117

@@ -269,15 +265,12 @@ pub trait Channel {}
269265
pub unsafe trait DMASet<STREAM, const CHANNEL: u8, DIRECTION> {}
270266

271267
macro_rules! dma_map {
272-
($(($Stream:ty, $C:literal, $Peripheral:ty $(|$Peripheral2:ty)?, $Dir:ty $(|$Dir2:ty)?)),+ $(,)*) => {
268+
($(($Stream:ty, $C:literal, $Peripheral:ty, $Dir:ty $(|$Dir2:ty)?)),+ $(,)*) => {
273269
$(
274270
unsafe impl DMASet<$Stream, $C, $Dir> for $Peripheral {}
275271
$(
276272
unsafe impl DMASet<$Stream, $C, $Dir2> for $Peripheral {}
277273
)?
278-
$(
279-
unsafe impl DMASet<$Stream, $C, $Dir> for $Peripheral2 {}
280-
)?
281274
)+
282275
};
283276
}
@@ -306,11 +299,11 @@ dma_map!(
306299
(Stream6<DMA1>, 3, timer::CCR4<pac::TIM2>, MemoryToPeripheral | PeripheralToMemory), //TIM2_CH4
307300
(Stream7<DMA1>, 2, timer::CCR3<pac::TIM4>, MemoryToPeripheral | PeripheralToMemory), //TIM4_CH3
308301
(Stream7<DMA1>, 5, timer::CCR3<pac::TIM3>, MemoryToPeripheral | PeripheralToMemory), //TIM3_CH3
309-
(Stream0<DMA1>, 0, pac::SPI3 | spi::Rx<pac::SPI3>, PeripheralToMemory), //SPI3_RX
310-
(Stream2<DMA1>, 0, pac::SPI3 | spi::Rx<pac::SPI3>, PeripheralToMemory), //SPI3_RX
311-
(Stream4<DMA1>, 3, pac::I2C3 | i2c::Tx<pac::I2C3>, MemoryToPeripheral), //I2C3_TX
312-
(Stream5<DMA1>, 0, pac::SPI3 | spi::Tx<pac::SPI3>, MemoryToPeripheral), //SPI3_TX
313-
(Stream7<DMA1>, 0, pac::SPI3 | spi::Tx<pac::SPI3>, MemoryToPeripheral), //SPI3_TX
302+
(Stream0<DMA1>, 0, pac::SPI3, PeripheralToMemory), //SPI3_RX
303+
(Stream2<DMA1>, 0, pac::SPI3, PeripheralToMemory), //SPI3_RX
304+
(Stream4<DMA1>, 3, pac::I2C3, MemoryToPeripheral), //I2C3_TX
305+
(Stream5<DMA1>, 0, pac::SPI3, MemoryToPeripheral), //SPI3_TX
306+
(Stream7<DMA1>, 0, pac::SPI3, MemoryToPeripheral), //SPI3_TX
314307
);
315308

316309
#[cfg(any(
@@ -366,26 +359,26 @@ dma_map!(
366359
(Stream6<DMA2>, 0, timer::CCR2<pac::TIM1>, MemoryToPeripheral | PeripheralToMemory), //TIM1_CH2
367360
(Stream6<DMA2>, 0, timer::CCR3<pac::TIM1>, MemoryToPeripheral | PeripheralToMemory), //TIM1_CH3
368361
(Stream6<DMA2>, 6, timer::CCR3<pac::TIM1>, MemoryToPeripheral | PeripheralToMemory), //TIM1_CH3
369-
(Stream0<DMA1>, 1, pac::I2C1 | i2c::Rx<pac::I2C1>, PeripheralToMemory), //I2C1_RX
370-
(Stream2<DMA1>, 7, pac::I2C2 | i2c::Rx<pac::I2C2>, PeripheralToMemory), //I2C2_RX
371-
(Stream3<DMA1>, 0, pac::SPI2 | spi::Rx<pac::SPI2>, PeripheralToMemory), //SPI2_RX
372-
(Stream3<DMA1>, 7, pac::I2C2 | i2c::Rx<pac::I2C2>, PeripheralToMemory), //I2C2_RX
373-
(Stream4<DMA1>, 0, pac::SPI2 | spi::Tx<pac::SPI2>, MemoryToPeripheral), // SPI2_TX
374-
(Stream5<DMA1>, 1, pac::I2C1 | i2c::Rx<pac::I2C1>, PeripheralToMemory), //I2C1_RX
375-
(Stream5<DMA1>, 4, pac::USART2 | serial::Rx<pac::USART2>, PeripheralToMemory), //USART2_RX
376-
(Stream6<DMA1>, 4, pac::USART2 | serial::Tx<pac::USART2>, MemoryToPeripheral), //USART2_TX
377-
(Stream7<DMA1>, 7, pac::I2C2 | i2c::Tx<pac::I2C2>, MemoryToPeripheral), //I2C2_TX
378-
(Stream0<DMA2>, 0, pac::ADC1 | Adc<pac::ADC1>, PeripheralToMemory),
379-
(Stream0<DMA2>, 3, pac::SPI1 |spi::Rx<pac::SPI1>, PeripheralToMemory), //SPI1_RX
380-
(Stream1<DMA2>, 5, pac::USART6 | serial::Rx<pac::USART6>, PeripheralToMemory), //USART6_RX
381-
(Stream2<DMA2>, 3, pac::SPI1 | spi::Rx<pac::SPI1>, PeripheralToMemory), //SPI1_RX
382-
(Stream2<DMA2>, 4, pac::USART1 | serial::Rx<pac::USART1>, PeripheralToMemory), //USART1_RX
383-
(Stream2<DMA2>, 5, pac::USART6 | serial::Rx<pac::USART6>, PeripheralToMemory), //USART6_RX
362+
(Stream0<DMA1>, 1, pac::I2C1, PeripheralToMemory), //I2C1_RX
363+
(Stream2<DMA1>, 7, pac::I2C2, PeripheralToMemory), //I2C2_RX
364+
(Stream3<DMA1>, 0, pac::SPI2, PeripheralToMemory), //SPI2_RX
365+
(Stream3<DMA1>, 7, pac::I2C2, PeripheralToMemory), //I2C2_RX
366+
(Stream4<DMA1>, 0, pac::SPI2, MemoryToPeripheral), // SPI2_TX
367+
(Stream5<DMA1>, 1, pac::I2C1, PeripheralToMemory), //I2C1_RX
368+
(Stream5<DMA1>, 4, pac::USART2, PeripheralToMemory), //USART2_RX
369+
(Stream6<DMA1>, 4, pac::USART2, MemoryToPeripheral), //USART2_TX
370+
(Stream7<DMA1>, 7, pac::I2C2, MemoryToPeripheral), //I2C2_TX
371+
(Stream0<DMA2>, 0, pac::ADC1, PeripheralToMemory),
372+
(Stream0<DMA2>, 3, pac::SPI1, PeripheralToMemory), //SPI1_RX
373+
(Stream1<DMA2>, 5, pac::USART6, PeripheralToMemory), //USART6_RX
374+
(Stream2<DMA2>, 3, pac::SPI1, PeripheralToMemory), //SPI1_RX
375+
(Stream2<DMA2>, 4, pac::USART1, PeripheralToMemory), //USART1_RX
376+
(Stream2<DMA2>, 5, pac::USART6, PeripheralToMemory), //USART6_RX
384377
(Stream4<DMA2>, 0, pac::ADC1, PeripheralToMemory), //ADC1
385-
(Stream5<DMA2>, 4, pac::USART1 | serial::Rx<pac::USART1>, PeripheralToMemory), //USART1_RX
386-
(Stream6<DMA2>, 5, pac::USART6 | serial::Tx<pac::USART6>, MemoryToPeripheral), //USART6_TX
387-
(Stream7<DMA2>, 4, pac::USART1 | serial::Tx<pac::USART1>, MemoryToPeripheral), //USART1_TX
388-
(Stream7<DMA2>, 5, pac::USART6 | serial::Tx<pac::USART6>, MemoryToPeripheral), //USART6_TX
378+
(Stream5<DMA2>, 4, pac::USART1, PeripheralToMemory), //USART1_RX
379+
(Stream6<DMA2>, 5, pac::USART6, MemoryToPeripheral), //USART6_TX
380+
(Stream7<DMA2>, 4, pac::USART1, MemoryToPeripheral), //USART1_TX
381+
(Stream7<DMA2>, 5, pac::USART6, MemoryToPeripheral), //USART6_TX
389382
(Stream0<DMA2>, 0, MemoryToMemory<u8>, MemoryToMemory<u8>),
390383
(Stream1<DMA2>, 0, MemoryToMemory<u8>, MemoryToMemory<u8>),
391384
(Stream2<DMA2>, 0, MemoryToMemory<u8>, MemoryToMemory<u8>),
@@ -431,8 +424,8 @@ address!(
431424
feature = "gpio-f446",
432425
))]
433426
dma_map!(
434-
(Stream1<DMA1>, 1, pac::I2C3 | i2c::Rx<pac::I2C3>, PeripheralToMemory), //I2C3_RX
435-
(Stream2<DMA1>, 3, pac::I2C3 | i2c::Rx<pac::I2C3>, PeripheralToMemory), //I2C3_RX:DMA_CHANNEL_3
427+
(Stream1<DMA1>, 1, pac::I2C3, PeripheralToMemory), //I2C3_RX
428+
(Stream2<DMA1>, 3, pac::I2C3, PeripheralToMemory), //I2C3_RX:DMA_CHANNEL_3
436429
);
437430

438431
#[cfg(any(feature = "gpio-f401", feature = "gpio-f411",))]
@@ -450,7 +443,7 @@ dma_map!(
450443
feature = "gpio-f413",
451444
))]
452445
dma_map!(
453-
(Stream5<DMA1>, 6, pac::I2C3 | i2c::Tx<pac::I2C3>, MemoryToPeripheral), //I2C3_TX:DMA_CHANNEL_6);
446+
(Stream5<DMA1>, 6, pac::I2C3, MemoryToPeripheral), //I2C3_TX:DMA_CHANNEL_6);
454447
);
455448

456449
#[cfg(any(
@@ -461,10 +454,10 @@ dma_map!(
461454
feature = "gpio-f469",
462455
))]
463456
dma_map!(
464-
(Stream6<DMA1>, 1, pac::I2C1 | i2c::Tx<pac::I2C1>, MemoryToPeripheral), //I2C1_TX
465-
(Stream7<DMA1>, 1, pac::I2C1 | i2c::Tx<pac::I2C1>, MemoryToPeripheral), //I2C1_TX
466-
(Stream3<DMA2>, 3, pac::SPI1 | spi::Tx<pac::SPI1>, MemoryToPeripheral), //SPI1_TX
467-
(Stream5<DMA2>, 3, pac::SPI1 | spi::Tx<pac::SPI1>, MemoryToPeripheral), //SPI1_TX
457+
(Stream6<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX
458+
(Stream7<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX
459+
(Stream3<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX
460+
(Stream5<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX
468461
);
469462

470463
#[cfg(any(
@@ -477,10 +470,10 @@ dma_map!(
477470
feature = "gpio-f469",
478471
))]
479472
dma_map!(
480-
(Stream0<DMA2>, 4, pac::SPI4 | spi::Rx<pac::SPI4>, PeripheralToMemory), //SPI4_RX
481-
(Stream1<DMA2>, 4, pac::SPI4 | spi::Tx<pac::SPI4>, MemoryToPeripheral), //SPI4_TX
482-
(Stream3<DMA2>, 5, pac::SPI4 | spi::Rx<pac::SPI4>, PeripheralToMemory), //SPI4_RX:DMA_CHANNEL_5
483-
(Stream4<DMA2>, 5, pac::SPI4 | spi::Tx<pac::SPI4>, MemoryToPeripheral), //SPI4_TX:DMA_CHANNEL_5
473+
(Stream0<DMA2>, 4, pac::SPI4, PeripheralToMemory), //SPI4_RX
474+
(Stream1<DMA2>, 4, pac::SPI4, MemoryToPeripheral), //SPI4_TX
475+
(Stream3<DMA2>, 5, pac::SPI4, PeripheralToMemory), //SPI4_RX:DMA_CHANNEL_5
476+
(Stream4<DMA2>, 5, pac::SPI4, MemoryToPeripheral), //SPI4_TX:DMA_CHANNEL_5
484477
);
485478

486479
#[cfg(any(
@@ -502,9 +495,9 @@ address!((pac::SPI4, dr, u8),);
502495
feature = "gpio-f469",
503496
))]
504497
dma_map!(
505-
(Stream0<DMA1>, 4, pac::UART5 | uart::Rx<pac::UART5>, PeripheralToMemory), //UART5_RX
506-
(Stream2<DMA1>, 4, pac::UART4 | uart::Rx<pac::UART4>, PeripheralToMemory), //UART4_RX
507-
(Stream4<DMA1>, 4, pac::UART4 | uart::Tx<pac::UART4>, MemoryToPeripheral), //UART4_TX
498+
(Stream0<DMA1>, 4, pac::UART5, PeripheralToMemory), //UART5_RX
499+
(Stream2<DMA1>, 4, pac::UART4, PeripheralToMemory), //UART4_RX
500+
(Stream4<DMA1>, 4, pac::UART4, MemoryToPeripheral), //UART4_TX
508501
//(Stream6<DMA1>, 7, pac::DAC2, MemoryToPeripheral), //DAC2
509502
);
510503

@@ -545,9 +538,9 @@ dma_map!(
545538
(Stream4<DMA2>, 7, timer::CCR3<pac::TIM8>, MemoryToPeripheral | PeripheralToMemory), //TIM8_CH3
546539
(Stream7<DMA2>, 7, timer::CCR4<pac::TIM8>, MemoryToPeripheral | PeripheralToMemory), //TIM8_CH4
547540
(Stream7<DMA2>, 7, timer::DMAR<pac::TIM8>, MemoryToPeripheral | PeripheralToMemory), //TIM8_COM/TRIG
548-
(Stream1<DMA1>, 4, pac::USART3 | serial::Rx<pac::USART3>, PeripheralToMemory), //USART3_RX
549-
(Stream3<DMA1>, 4, pac::USART3 | serial::Tx<pac::USART3>, MemoryToPeripheral), //USART3_TX
550-
(Stream4<DMA1>, 7, pac::USART3 | serial::Tx<pac::USART3>, MemoryToPeripheral), //USART3_TX:DMA_CHANNEL_7
541+
(Stream1<DMA1>, 4, pac::USART3, PeripheralToMemory), //USART3_RX
542+
(Stream3<DMA1>, 4, pac::USART3, MemoryToPeripheral), //USART3_TX
543+
(Stream4<DMA1>, 7, pac::USART3, MemoryToPeripheral), //USART3_TX:DMA_CHANNEL_7
551544
);
552545

553546
#[cfg(any(
@@ -579,7 +572,7 @@ dma_map!(
579572

580573
#[cfg(any(feature = "gpio-f417", feature = "gpio-f427", feature = "gpio-f469",))]
581574
dma_map!(
582-
(Stream2<DMA1>, 3, pac::I2C3 | i2c::Rx<pac::I2C3>, PeripheralToMemory), //I2C3_RX
575+
(Stream2<DMA1>, 3, pac::I2C3, PeripheralToMemory), //I2C3_RX
583576
(Stream5<DMA2>, 2, pac::CRYP, PeripheralToMemory), //CRYP_OUT
584577
(Stream6<DMA2>, 2, pac::CRYP, MemoryToPeripheral), //CRYP_IN
585578
(Stream7<DMA2>, 2, pac::HASH, MemoryToPeripheral), //HASH_IN
@@ -620,11 +613,11 @@ address!(
620613
feature = "gpio-f469",
621614
))]
622615
dma_map!(
623-
(Stream7<DMA1>, 4, pac::UART5 | uart::Tx<pac::UART5>, MemoryToPeripheral), //UART5_TX
624-
(Stream0<DMA2>, 2, pac::ADC3 | Adc<pac::ADC3>, PeripheralToMemory), //ADC3
625-
(Stream1<DMA2>, 2, pac::ADC3 | Adc<pac::ADC3>, PeripheralToMemory), //ADC3
626-
(Stream2<DMA2>, 1, pac::ADC2 | Adc<pac::ADC2>, PeripheralToMemory), //ADC2
627-
(Stream3<DMA2>, 1, pac::ADC2 | Adc<pac::ADC2>, PeripheralToMemory), //ADC2
616+
(Stream7<DMA1>, 4, pac::UART5, MemoryToPeripheral), //UART5_TX
617+
(Stream0<DMA2>, 2, pac::ADC3, PeripheralToMemory), //ADC3
618+
(Stream1<DMA2>, 2, pac::ADC3, PeripheralToMemory), //ADC3
619+
(Stream2<DMA2>, 1, pac::ADC2, PeripheralToMemory), //ADC2
620+
(Stream3<DMA2>, 1, pac::ADC2, PeripheralToMemory), //ADC2
628621
(Stream1<DMA2>, 1, pac::DCMI, PeripheralToMemory), //DCMI
629622
(Stream7<DMA2>, 1, pac::DCMI, PeripheralToMemory), //DCMI
630623
);
@@ -671,14 +664,14 @@ address!(
671664
feature = "gpio-f413",
672665
))]
673666
dma_map!(
674-
(Stream1<DMA1>, 0, pac::I2C1 | i2c::Tx<pac::I2C1>, MemoryToPeripheral), //I2C1_TX
675-
(Stream6<DMA1>, 1, pac::I2C1 | i2c::Tx<pac::I2C1>, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1
676-
(Stream7<DMA1>, 1, pac::I2C1 | i2c::Tx<pac::I2C1>, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1
677-
(Stream7<DMA1>, 6, pac::USART2 | serial::Rx<pac::USART2>, PeripheralToMemory), //USART2_RX:DMA_CHANNEL_6
678-
(Stream2<DMA2>, 2, pac::SPI1 | spi::Tx<pac::SPI1>, MemoryToPeripheral), //SPI1_TX
679-
(Stream3<DMA2>, 3, pac::SPI1 | spi::Tx<pac::SPI1>, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3
680-
(Stream5<DMA2>, 3, pac::SPI1 | spi::Tx<pac::SPI1>, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3
681-
(Stream5<DMA2>, 5, pac::SPI5 | spi::Tx<pac::SPI5>, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_5
667+
(Stream1<DMA1>, 0, pac::I2C1, MemoryToPeripheral), //I2C1_TX
668+
(Stream6<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1
669+
(Stream7<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1
670+
(Stream7<DMA1>, 6, pac::USART2, PeripheralToMemory), //USART2_RX:DMA_CHANNEL_6
671+
(Stream2<DMA2>, 2, pac::SPI1, MemoryToPeripheral), //SPI1_TX
672+
(Stream3<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3
673+
(Stream5<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3
674+
(Stream5<DMA2>, 5, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_5
682675
);
683676

684677
#[cfg(any(
@@ -690,10 +683,10 @@ dma_map!(
690683
feature = "gpio-f469",
691684
))]
692685
dma_map!(
693-
(Stream3<DMA2>, 2, pac::SPI5 | spi::Rx<pac::SPI5>, PeripheralToMemory), //SPI5_RX
694-
(Stream4<DMA2>, 2, pac::SPI5 | spi::Tx<pac::SPI5>, MemoryToPeripheral), //SPI5_TX
695-
(Stream5<DMA2>, 7, pac::SPI5 | spi::Rx<pac::SPI5>, PeripheralToMemory), //SPI5_RX:DMA_CHANNEL_7
696-
(Stream6<DMA2>, 7, pac::SPI5 | spi::Tx<pac::SPI5>, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_7
686+
(Stream3<DMA2>, 2, pac::SPI5, PeripheralToMemory), //SPI5_RX
687+
(Stream4<DMA2>, 2, pac::SPI5, MemoryToPeripheral), //SPI5_TX
688+
(Stream5<DMA2>, 7, pac::SPI5, PeripheralToMemory), //SPI5_RX:DMA_CHANNEL_7
689+
(Stream6<DMA2>, 7, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_7
697690
);
698691

699692
#[cfg(any(
@@ -708,7 +701,7 @@ address!((pac::SPI5, dr, u8),);
708701

709702
#[cfg(any(feature = "gpio-f411", feature = "gpio-f412", feature = "gpio-f413",))]
710703
dma_map!(
711-
(Stream4<DMA2>, 4, pac::SPI4 | spi::Rx<pac::SPI4>, PeripheralToMemory), //SPI4_RX
704+
(Stream4<DMA2>, 4, pac::SPI4, PeripheralToMemory), //SPI4_RX
712705
);
713706

714707
/* TODO: DFSDM support
@@ -762,24 +755,24 @@ address!((pac::QUADSPI, dr, u32),);
762755

763756
#[cfg(any(feature = "gpio-f413", feature = "gpio-f427", feature = "gpio-f469",))]
764757
dma_map!(
765-
(Stream0<DMA1>, 5, pac::UART8 | uart::Tx<pac::UART8>, MemoryToPeripheral), //UART8_TX
766-
(Stream1<DMA1>, 5, pac::UART7 | uart::Tx<pac::UART7>, MemoryToPeripheral), //UART7_TX
767-
(Stream3<DMA1>, 5, pac::UART7 | uart::Rx<pac::UART7>, PeripheralToMemory), //UART7_RX
768-
(Stream6<DMA1>, 5, pac::UART8 | uart::Rx<pac::UART8>, PeripheralToMemory), //UART8_RX
758+
(Stream0<DMA1>, 5, pac::UART8, MemoryToPeripheral), //UART8_TX
759+
(Stream1<DMA1>, 5, pac::UART7, MemoryToPeripheral), //UART7_TX
760+
(Stream3<DMA1>, 5, pac::UART7, PeripheralToMemory), //UART7_RX
761+
(Stream6<DMA1>, 5, pac::UART8, PeripheralToMemory), //UART8_RX
769762
);
770763

771764
#[cfg(any(feature = "gpio-f413", feature = "gpio-f427", feature = "gpio-f469",))]
772765
address!((pac::UART7, dr, u8), (pac::UART8, dr, u8),);
773766

774767
#[cfg(feature = "gpio-f413")]
775768
dma_map!(
776-
(Stream7<DMA1>, 8, pac::UART5 | uart::Tx<pac::UART5>, MemoryToPeripheral), //UART5_TX
777-
(Stream0<DMA2>, 1, pac::UART9 | uart::Tx<pac::UART9>, MemoryToPeripheral), //UART9_TX
778-
(Stream0<DMA2>, 5, pac::UART10 | uart::Rx<pac::UART10>, PeripheralToMemory), //UART10_RX
779-
(Stream3<DMA2>, 9, pac::UART10 | uart::Rx<pac::UART10>, PeripheralToMemory), //UART10_RX:DMA_CHANNEL_9
780-
(Stream5<DMA2>, 9, pac::UART10 | uart::Tx<pac::UART10>, MemoryToPeripheral), //UART10_TX
781-
(Stream7<DMA2>, 0, pac::UART9 | uart::Rx<pac::UART9>, PeripheralToMemory), //UART9_RX
782-
(Stream7<DMA2>, 6, pac::UART10 | uart::Tx<pac::UART10>, MemoryToPeripheral), //UART10_TX:DMA_CHANNEL_6
769+
(Stream7<DMA1>, 8, pac::UART5, MemoryToPeripheral), //UART5_TX
770+
(Stream0<DMA2>, 1, pac::UART9, MemoryToPeripheral), //UART9_TX
771+
(Stream0<DMA2>, 5, pac::UART10, PeripheralToMemory), //UART10_RX
772+
(Stream3<DMA2>, 9, pac::UART10, PeripheralToMemory), //UART10_RX:DMA_CHANNEL_9
773+
(Stream5<DMA2>, 9, pac::UART10, MemoryToPeripheral), //UART10_TX
774+
(Stream7<DMA2>, 0, pac::UART9, PeripheralToMemory), //UART9_RX
775+
(Stream7<DMA2>, 6, pac::UART10, MemoryToPeripheral), //UART10_TX:DMA_CHANNEL_6
783776
//(pac::DMA2, Stream6, 2, IN<pac::AES>, MemoryToPeripheral), //AES_IN
784777
//(pac::DMA2, Stream5, 2, OUT<pac::AES>, PeripheralToMemory), //AES_OUT
785778
);
@@ -819,8 +812,8 @@ address!(
819812

820813
#[cfg(any(feature = "gpio-f427", feature = "gpio-f469",))]
821814
dma_map!(
822-
(Stream5<DMA2>, 1, pac::SPI6 | spi::Tx<pac::SPI6>, MemoryToPeripheral), //SPI6_TX
823-
(Stream6<DMA2>, 1, pac::SPI6 | spi::Rx<pac::SPI6>, PeripheralToMemory), //SPI6_RX
815+
(Stream5<DMA2>, 1, pac::SPI6, MemoryToPeripheral), //SPI6_TX
816+
(Stream6<DMA2>, 1, pac::SPI6, PeripheralToMemory), //SPI6_RX
824817
);
825818

826819
#[cfg(any(feature = "gpio-f427", feature = "gpio-f469",))]

src/i2c.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ mod hal_02;
1414
mod hal_1;
1515

1616
pub mod dma;
17-
pub(crate) use dma::{Rx, Tx};
1817

1918
#[derive(Debug, Eq, PartialEq)]
2019
pub enum DutyCycle {

src/i2c/dma.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,3 +924,13 @@ unsafe impl<I2C: Instance> PeriAddress for Tx<I2C> {
924924

925925
type MemSize = u8;
926926
}
927+
928+
unsafe impl<I2C, STREAM, const CHANNEL: u8> DMASet<STREAM, CHANNEL, PeripheralToMemory> for Rx<I2C> where
929+
I2C: DMASet<STREAM, CHANNEL, PeripheralToMemory>
930+
{
931+
}
932+
933+
unsafe impl<I2C, STREAM, const CHANNEL: u8> DMASet<STREAM, CHANNEL, MemoryToPeripheral> for Tx<I2C> where
934+
I2C: DMASet<STREAM, CHANNEL, MemoryToPeripheral>
935+
{
936+
}

src/serial/uart_impls.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::dma::{traits::DMASet, MemoryToPeripheral, PeripheralToMemory};
2+
13
use super::*;
24

35
impl<UART: CommonPins> Rx<UART, u8> {
@@ -410,6 +412,13 @@ unsafe impl<UART: Instance> PeriAddress for Rx<UART, u8> {
410412
type MemSize = u8;
411413
}
412414

415+
unsafe impl<UART: CommonPins, STREAM, const CHANNEL: u8> DMASet<STREAM, CHANNEL, PeripheralToMemory>
416+
for Rx<UART>
417+
where
418+
UART: DMASet<STREAM, CHANNEL, PeripheralToMemory>,
419+
{
420+
}
421+
413422
unsafe impl<UART: Instance> PeriAddress for Tx<UART, u8> {
414423
#[inline(always)]
415424
fn address(&self) -> u32 {
@@ -418,3 +427,10 @@ unsafe impl<UART: Instance> PeriAddress for Tx<UART, u8> {
418427

419428
type MemSize = u8;
420429
}
430+
431+
unsafe impl<UART: CommonPins, STREAM, const CHANNEL: u8> DMASet<STREAM, CHANNEL, MemoryToPeripheral>
432+
for Tx<UART>
433+
where
434+
UART: DMASet<STREAM, CHANNEL, MemoryToPeripheral>,
435+
{
436+
}

0 commit comments

Comments
 (0)