Skip to content

Commit 36afe42

Browse files
committed
DMASet autoimpl
1 parent 5a39f12 commit 36afe42

File tree

7 files changed

+122
-83
lines changed

7 files changed

+122
-83
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 & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use super::*;
22
#[cfg(feature = "uart4")]
33
use crate::uart;
44
use crate::{
5-
adc::Adc,
6-
i2c,
75
pac::{self, DMA1, DMA2},
8-
serial, spi, timer,
6+
timer,
97
};
108
use core::ops::Deref;
119

@@ -269,15 +267,12 @@ pub trait Channel {}
269267
pub unsafe trait DMASet<STREAM, const CHANNEL: u8, DIRECTION> {}
270268

271269
macro_rules! dma_map {
272-
($(($Stream:ty, $C:literal, $Peripheral:ty $(|$Peripheral2:ty)?, $Dir:ty $(|$Dir2:ty)?)),+ $(,)*) => {
270+
($(($Stream:ty, $C:literal, $Peripheral:ty, $Dir:ty $(|$Dir2:ty)?)),+ $(,)*) => {
273271
$(
274272
unsafe impl DMASet<$Stream, $C, $Dir> for $Peripheral {}
275273
$(
276274
unsafe impl DMASet<$Stream, $C, $Dir2> for $Peripheral {}
277275
)?
278-
$(
279-
unsafe impl DMASet<$Stream, $C, $Dir> for $Peripheral2 {}
280-
)?
281276
)+
282277
};
283278
}
@@ -306,11 +301,11 @@ dma_map!(
306301
(Stream6<DMA1>, 3, timer::CCR4<pac::TIM2>, MemoryToPeripheral | PeripheralToMemory), //TIM2_CH4
307302
(Stream7<DMA1>, 2, timer::CCR3<pac::TIM4>, MemoryToPeripheral | PeripheralToMemory), //TIM4_CH3
308303
(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
304+
(Stream0<DMA1>, 0, pac::SPI3, PeripheralToMemory), //SPI3_RX
305+
(Stream2<DMA1>, 0, pac::SPI3, PeripheralToMemory), //SPI3_RX
306+
(Stream4<DMA1>, 3, pac::I2C3, MemoryToPeripheral), //I2C3_TX
307+
(Stream5<DMA1>, 0, pac::SPI3, MemoryToPeripheral), //SPI3_TX
308+
(Stream7<DMA1>, 0, pac::SPI3, MemoryToPeripheral), //SPI3_TX
314309
);
315310

316311
#[cfg(any(
@@ -366,26 +361,26 @@ dma_map!(
366361
(Stream6<DMA2>, 0, timer::CCR2<pac::TIM1>, MemoryToPeripheral | PeripheralToMemory), //TIM1_CH2
367362
(Stream6<DMA2>, 0, timer::CCR3<pac::TIM1>, MemoryToPeripheral | PeripheralToMemory), //TIM1_CH3
368363
(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
364+
(Stream0<DMA1>, 1, pac::I2C1, PeripheralToMemory), //I2C1_RX
365+
(Stream2<DMA1>, 7, pac::I2C2, PeripheralToMemory), //I2C2_RX
366+
(Stream3<DMA1>, 0, pac::SPI2, PeripheralToMemory), //SPI2_RX
367+
(Stream3<DMA1>, 7, pac::I2C2, PeripheralToMemory), //I2C2_RX
368+
(Stream4<DMA1>, 0, pac::SPI2, MemoryToPeripheral), // SPI2_TX
369+
(Stream5<DMA1>, 1, pac::I2C1, PeripheralToMemory), //I2C1_RX
370+
(Stream5<DMA1>, 4, pac::USART2, PeripheralToMemory), //USART2_RX
371+
(Stream6<DMA1>, 4, pac::USART2, MemoryToPeripheral), //USART2_TX
372+
(Stream7<DMA1>, 7, pac::I2C2, MemoryToPeripheral), //I2C2_TX
373+
(Stream0<DMA2>, 0, pac::ADC1, PeripheralToMemory),
374+
(Stream0<DMA2>, 3, pac::SPI1, PeripheralToMemory), //SPI1_RX
375+
(Stream1<DMA2>, 5, pac::USART6, PeripheralToMemory), //USART6_RX
376+
(Stream2<DMA2>, 3, pac::SPI1, PeripheralToMemory), //SPI1_RX
377+
(Stream2<DMA2>, 4, pac::USART1, PeripheralToMemory), //USART1_RX
378+
(Stream2<DMA2>, 5, pac::USART6, PeripheralToMemory), //USART6_RX
384379
(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
380+
(Stream5<DMA2>, 4, pac::USART1, PeripheralToMemory), //USART1_RX
381+
(Stream6<DMA2>, 5, pac::USART6, MemoryToPeripheral), //USART6_TX
382+
(Stream7<DMA2>, 4, pac::USART1, MemoryToPeripheral), //USART1_TX
383+
(Stream7<DMA2>, 5, pac::USART6, MemoryToPeripheral), //USART6_TX
389384
(Stream0<DMA2>, 0, MemoryToMemory<u8>, MemoryToMemory<u8>),
390385
(Stream1<DMA2>, 0, MemoryToMemory<u8>, MemoryToMemory<u8>),
391386
(Stream2<DMA2>, 0, MemoryToMemory<u8>, MemoryToMemory<u8>),
@@ -431,8 +426,8 @@ address!(
431426
feature = "gpio-f446",
432427
))]
433428
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
429+
(Stream1<DMA1>, 1, pac::I2C3, PeripheralToMemory), //I2C3_RX
430+
(Stream2<DMA1>, 3, pac::I2C3, PeripheralToMemory), //I2C3_RX:DMA_CHANNEL_3
436431
);
437432

438433
#[cfg(any(feature = "gpio-f401", feature = "gpio-f411",))]
@@ -450,7 +445,7 @@ dma_map!(
450445
feature = "gpio-f413",
451446
))]
452447
dma_map!(
453-
(Stream5<DMA1>, 6, pac::I2C3 | i2c::Tx<pac::I2C3>, MemoryToPeripheral), //I2C3_TX:DMA_CHANNEL_6);
448+
(Stream5<DMA1>, 6, pac::I2C3, MemoryToPeripheral), //I2C3_TX:DMA_CHANNEL_6);
454449
);
455450

456451
#[cfg(any(
@@ -461,10 +456,10 @@ dma_map!(
461456
feature = "gpio-f469",
462457
))]
463458
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
459+
(Stream6<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX
460+
(Stream7<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX
461+
(Stream3<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX
462+
(Stream5<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX
468463
);
469464

470465
#[cfg(any(
@@ -477,10 +472,10 @@ dma_map!(
477472
feature = "gpio-f469",
478473
))]
479474
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
475+
(Stream0<DMA2>, 4, pac::SPI4, PeripheralToMemory), //SPI4_RX
476+
(Stream1<DMA2>, 4, pac::SPI4, MemoryToPeripheral), //SPI4_TX
477+
(Stream3<DMA2>, 5, pac::SPI4, PeripheralToMemory), //SPI4_RX:DMA_CHANNEL_5
478+
(Stream4<DMA2>, 5, pac::SPI4, MemoryToPeripheral), //SPI4_TX:DMA_CHANNEL_5
484479
);
485480

486481
#[cfg(any(
@@ -502,9 +497,9 @@ address!((pac::SPI4, dr, u8),);
502497
feature = "gpio-f469",
503498
))]
504499
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
500+
(Stream0<DMA1>, 4, pac::UART5, PeripheralToMemory), //UART5_RX
501+
(Stream2<DMA1>, 4, pac::UART4, PeripheralToMemory), //UART4_RX
502+
(Stream4<DMA1>, 4, pac::UART4, MemoryToPeripheral), //UART4_TX
508503
//(Stream6<DMA1>, 7, pac::DAC2, MemoryToPeripheral), //DAC2
509504
);
510505

@@ -545,9 +540,9 @@ dma_map!(
545540
(Stream4<DMA2>, 7, timer::CCR3<pac::TIM8>, MemoryToPeripheral | PeripheralToMemory), //TIM8_CH3
546541
(Stream7<DMA2>, 7, timer::CCR4<pac::TIM8>, MemoryToPeripheral | PeripheralToMemory), //TIM8_CH4
547542
(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
543+
(Stream1<DMA1>, 4, pac::USART3, PeripheralToMemory), //USART3_RX
544+
(Stream3<DMA1>, 4, pac::USART3, MemoryToPeripheral), //USART3_TX
545+
(Stream4<DMA1>, 7, pac::USART3, MemoryToPeripheral), //USART3_TX:DMA_CHANNEL_7
551546
);
552547

553548
#[cfg(any(
@@ -579,7 +574,7 @@ dma_map!(
579574

580575
#[cfg(any(feature = "gpio-f417", feature = "gpio-f427", feature = "gpio-f469",))]
581576
dma_map!(
582-
(Stream2<DMA1>, 3, pac::I2C3 | i2c::Rx<pac::I2C3>, PeripheralToMemory), //I2C3_RX
577+
(Stream2<DMA1>, 3, pac::I2C3, PeripheralToMemory), //I2C3_RX
583578
(Stream5<DMA2>, 2, pac::CRYP, PeripheralToMemory), //CRYP_OUT
584579
(Stream6<DMA2>, 2, pac::CRYP, MemoryToPeripheral), //CRYP_IN
585580
(Stream7<DMA2>, 2, pac::HASH, MemoryToPeripheral), //HASH_IN
@@ -620,11 +615,11 @@ address!(
620615
feature = "gpio-f469",
621616
))]
622617
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
618+
(Stream7<DMA1>, 4, pac::UART5, MemoryToPeripheral), //UART5_TX
619+
(Stream0<DMA2>, 2, pac::ADC3, PeripheralToMemory), //ADC3
620+
(Stream1<DMA2>, 2, pac::ADC3, PeripheralToMemory), //ADC3
621+
(Stream2<DMA2>, 1, pac::ADC2, PeripheralToMemory), //ADC2
622+
(Stream3<DMA2>, 1, pac::ADC2, PeripheralToMemory), //ADC2
628623
(Stream1<DMA2>, 1, pac::DCMI, PeripheralToMemory), //DCMI
629624
(Stream7<DMA2>, 1, pac::DCMI, PeripheralToMemory), //DCMI
630625
);
@@ -671,14 +666,14 @@ address!(
671666
feature = "gpio-f413",
672667
))]
673668
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
669+
(Stream1<DMA1>, 0, pac::I2C1, MemoryToPeripheral), //I2C1_TX
670+
(Stream6<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1
671+
(Stream7<DMA1>, 1, pac::I2C1, MemoryToPeripheral), //I2C1_TX:DMA_CHANNEL_1
672+
(Stream7<DMA1>, 6, pac::USART2, PeripheralToMemory), //USART2_RX:DMA_CHANNEL_6
673+
(Stream2<DMA2>, 2, pac::SPI1, MemoryToPeripheral), //SPI1_TX
674+
(Stream3<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3
675+
(Stream5<DMA2>, 3, pac::SPI1, MemoryToPeripheral), //SPI1_TX:DMA_CHANNEL_3
676+
(Stream5<DMA2>, 5, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_5
682677
);
683678

684679
#[cfg(any(
@@ -690,10 +685,10 @@ dma_map!(
690685
feature = "gpio-f469",
691686
))]
692687
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
688+
(Stream3<DMA2>, 2, pac::SPI5, PeripheralToMemory), //SPI5_RX
689+
(Stream4<DMA2>, 2, pac::SPI5, MemoryToPeripheral), //SPI5_TX
690+
(Stream5<DMA2>, 7, pac::SPI5, PeripheralToMemory), //SPI5_RX:DMA_CHANNEL_7
691+
(Stream6<DMA2>, 7, pac::SPI5, MemoryToPeripheral), //SPI5_TX:DMA_CHANNEL_7
697692
);
698693

699694
#[cfg(any(
@@ -708,7 +703,7 @@ address!((pac::SPI5, dr, u8),);
708703

709704
#[cfg(any(feature = "gpio-f411", feature = "gpio-f412", feature = "gpio-f413",))]
710705
dma_map!(
711-
(Stream4<DMA2>, 4, pac::SPI4 | spi::Rx<pac::SPI4>, PeripheralToMemory), //SPI4_RX
706+
(Stream4<DMA2>, 4, pac::SPI4, PeripheralToMemory), //SPI4_RX
712707
);
713708

714709
/* TODO: DFSDM support
@@ -762,24 +757,24 @@ address!((pac::QUADSPI, dr, u32),);
762757

763758
#[cfg(any(feature = "gpio-f413", feature = "gpio-f427", feature = "gpio-f469",))]
764759
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
760+
(Stream0<DMA1>, 5, pac::UART8, MemoryToPeripheral), //UART8_TX
761+
(Stream1<DMA1>, 5, pac::UART7, MemoryToPeripheral), //UART7_TX
762+
(Stream3<DMA1>, 5, pac::UART7, PeripheralToMemory), //UART7_RX
763+
(Stream6<DMA1>, 5, pac::UART8, PeripheralToMemory), //UART8_RX
769764
);
770765

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

774769
#[cfg(feature = "gpio-f413")]
775770
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
771+
(Stream7<DMA1>, 8, pac::UART5, MemoryToPeripheral), //UART5_TX
772+
(Stream0<DMA2>, 1, pac::UART9, MemoryToPeripheral), //UART9_TX
773+
(Stream0<DMA2>, 5, pac::UART10, PeripheralToMemory), //UART10_RX
774+
(Stream3<DMA2>, 9, pac::UART10, PeripheralToMemory), //UART10_RX:DMA_CHANNEL_9
775+
(Stream5<DMA2>, 9, pac::UART10, MemoryToPeripheral), //UART10_TX
776+
(Stream7<DMA2>, 0, pac::UART9, PeripheralToMemory), //UART9_RX
777+
(Stream7<DMA2>, 6, pac::UART10, MemoryToPeripheral), //UART10_TX:DMA_CHANNEL_6
783778
//(pac::DMA2, Stream6, 2, IN<pac::AES>, MemoryToPeripheral), //AES_IN
784779
//(pac::DMA2, Stream5, 2, OUT<pac::AES>, PeripheralToMemory), //AES_OUT
785780
);
@@ -819,8 +814,8 @@ address!(
819814

820815
#[cfg(any(feature = "gpio-f427", feature = "gpio-f469",))]
821816
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
817+
(Stream5<DMA2>, 1, pac::SPI6, MemoryToPeripheral), //SPI6_TX
818+
(Stream6<DMA2>, 1, pac::SPI6, PeripheralToMemory), //SPI6_RX
824819
);
825820

826821
#[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)