Skip to content

Commit 2a19a4d

Browse files
committed
split USART and UART impls
1 parent 277c7fa commit 2a19a4d

File tree

11 files changed

+935
-711
lines changed

11 files changed

+935
-711
lines changed

CHANGELOG.md

Lines changed: 1 addition & 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+
- Split USART and UART implementations
1011
- Add `lapce` editor settings [#601]
1112
- Use `enum`s for alternate peripheral pins [#594]
1213
- Added missing U(S)ART DMA traits for HAL serial types [#593]

src/dma/traits.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use super::*;
2+
#[cfg(feature = "uart4")]
3+
use crate::uart;
24
use crate::{
35
adc::Adc,
46
i2c,
@@ -500,9 +502,9 @@ address!((pac::SPI4, dr, u8),);
500502
feature = "gpio-f469",
501503
))]
502504
dma_map!(
503-
(Stream0<DMA1>, 4, pac::UART5 | serial::Rx<pac::UART5>, PeripheralToMemory), //UART5_RX
504-
(Stream2<DMA1>, 4, pac::UART4 | serial::Rx<pac::UART4>, PeripheralToMemory), //UART4_RX
505-
(Stream4<DMA1>, 4, pac::UART4 | serial::Tx<pac::UART4>, MemoryToPeripheral), //UART4_TX
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
506508
//(Stream6<DMA1>, 7, pac::DAC2, MemoryToPeripheral), //DAC2
507509
);
508510

@@ -618,7 +620,7 @@ address!(
618620
feature = "gpio-f469",
619621
))]
620622
dma_map!(
621-
(Stream7<DMA1>, 4, pac::UART5 | serial::Tx<pac::UART5>, MemoryToPeripheral), //UART5_TX
623+
(Stream7<DMA1>, 4, pac::UART5 | uart::Tx<pac::UART5>, MemoryToPeripheral), //UART5_TX
622624
(Stream0<DMA2>, 2, pac::ADC3 | Adc<pac::ADC3>, PeripheralToMemory), //ADC3
623625
(Stream1<DMA2>, 2, pac::ADC3 | Adc<pac::ADC3>, PeripheralToMemory), //ADC3
624626
(Stream2<DMA2>, 1, pac::ADC2 | Adc<pac::ADC2>, PeripheralToMemory), //ADC2
@@ -760,24 +762,24 @@ address!((pac::QUADSPI, dr, u32),);
760762

761763
#[cfg(any(feature = "gpio-f413", feature = "gpio-f427", feature = "gpio-f469",))]
762764
dma_map!(
763-
(Stream0<DMA1>, 5, pac::UART8 | serial::Tx<pac::UART8>, MemoryToPeripheral), //UART8_TX
764-
(Stream1<DMA1>, 5, pac::UART7 | serial::Tx<pac::UART7>, MemoryToPeripheral), //UART7_TX
765-
(Stream3<DMA1>, 5, pac::UART7 | serial::Rx<pac::UART7>, PeripheralToMemory), //UART7_RX
766-
(Stream6<DMA1>, 5, pac::UART8 | serial::Rx<pac::UART8>, PeripheralToMemory), //UART8_RX
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
767769
);
768770

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

772774
#[cfg(feature = "gpio-f413")]
773775
dma_map!(
774-
(Stream7<DMA1>, 8, pac::UART5 | serial::Tx<pac::UART5>, MemoryToPeripheral), //UART5_TX
775-
(Stream0<DMA2>, 1, pac::UART9 | serial::Tx<pac::UART9>, MemoryToPeripheral), //UART9_TX
776-
(Stream0<DMA2>, 5, pac::UART10 | serial::Rx<pac::UART10>, PeripheralToMemory), //UART10_RX
777-
(Stream3<DMA2>, 9, pac::UART10 | serial::Rx<pac::UART10>, PeripheralToMemory), //UART10_RX:DMA_CHANNEL_9
778-
(Stream5<DMA2>, 9, pac::UART10 | serial::Tx<pac::UART10>, MemoryToPeripheral), //UART10_TX
779-
(Stream7<DMA2>, 0, pac::UART9 | serial::Rx<pac::UART9>, PeripheralToMemory), //UART9_RX
780-
(Stream7<DMA2>, 6, pac::UART10 | serial::Tx<pac::UART10>, MemoryToPeripheral), //UART10_TX:DMA_CHANNEL_6
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
781783
//(pac::DMA2, Stream6, 2, IN<pac::AES>, MemoryToPeripheral), //AES_IN
782784
//(pac::DMA2, Stream5, 2, OUT<pac::AES>, PeripheralToMemory), //AES_OUT
783785
);

src/fmpi2c.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ pub enum FmpMode {
4848

4949
impl FmpMode {
5050
pub fn standard(frequency: Hertz) -> Self {
51-
Self::Standard {
52-
frequency: frequency.into(),
53-
}
51+
Self::Standard { frequency }
5452
}
5553

5654
pub fn fast(frequency: Hertz) -> Self {

src/fmpi2c/hal_1.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ mod blocking {
5151
todo!()
5252
}
5353

54-
fn transaction<'a>(
54+
fn transaction(
5555
&mut self,
5656
_addr: u8,
57-
_operations: &mut [Operation<'a>],
57+
_operations: &mut [Operation<'_>],
5858
) -> Result<(), Self::Error> {
5959
todo!()
6060
}

src/gpio/alt.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,11 @@ pub mod usart1 {
12601260
PB3<7>,
12611261
],
12621262
}
1263+
1264+
impl crate::serial::CommonPins for crate::pac::USART1 {
1265+
type RxPin = Rx;
1266+
type TxPin = Tx;
1267+
}
12631268
}
12641269

12651270
pub mod usart2 {
@@ -1298,6 +1303,11 @@ pub mod usart2 {
12981303
PD6<7>,
12991304
],
13001305
}
1306+
1307+
impl crate::serial::CommonPins for crate::pac::USART2 {
1308+
type RxPin = Rx;
1309+
type TxPin = Tx;
1310+
}
13011311
}
13021312

13031313
#[cfg(feature = "usart3")]
@@ -1360,6 +1370,11 @@ pub mod usart3 {
13601370
PD9<7>,
13611371
],
13621372
}
1373+
1374+
impl crate::serial::CommonPins for crate::pac::USART3 {
1375+
type RxPin = Rx;
1376+
type TxPin = Tx;
1377+
}
13631378
}
13641379

13651380
pub mod usart6 {
@@ -1397,6 +1412,11 @@ pub mod usart6 {
13971412
PG9<8>,
13981413
],
13991414
}
1415+
1416+
impl crate::serial::CommonPins for crate::pac::USART6 {
1417+
type RxPin = Rx;
1418+
type TxPin = Tx;
1419+
}
14001420
}
14011421

14021422
#[cfg(feature = "uart4")]
@@ -1446,6 +1466,11 @@ pub mod uart4 {
14461466
PC11<8>,
14471467
],
14481468
}
1469+
1470+
impl crate::serial::CommonPins for crate::pac::UART4 {
1471+
type RxPin = Rx;
1472+
type TxPin = Tx;
1473+
}
14491474
}
14501475

14511476
#[cfg(feature = "uart5")]
@@ -1485,6 +1510,11 @@ pub mod uart5 {
14851510
PB12<11>,
14861511
],
14871512
}
1513+
1514+
impl crate::serial::CommonPins for crate::pac::UART5 {
1515+
type RxPin = Rx;
1516+
type TxPin = Tx;
1517+
}
14881518
}
14891519

14901520
#[cfg(feature = "uart7")]
@@ -1552,6 +1582,11 @@ pub mod uart7 {
15521582
PB3<8>,
15531583
],
15541584
}
1585+
1586+
impl crate::serial::CommonPins for crate::pac::UART7 {
1587+
type RxPin = Rx;
1588+
type TxPin = Tx;
1589+
}
15551590
}
15561591

15571592
#[cfg(feature = "uart8")]
@@ -1593,6 +1628,11 @@ pub mod uart8 {
15931628
PF8<8>,
15941629
],
15951630
}
1631+
1632+
impl crate::serial::CommonPins for crate::pac::UART8 {
1633+
type RxPin = Rx;
1634+
type TxPin = Tx;
1635+
}
15961636
}
15971637

15981638
#[cfg(feature = "uart9")]
@@ -1603,6 +1643,11 @@ pub mod uart9 {
16031643
<Tx> for no:NoPin, [PD15<11>, PG1<11>,],
16041644
<Rx> for no:NoPin, [PD14<11>, PG0<11>,],
16051645
}
1646+
1647+
impl crate::serial::CommonPins for crate::pac::UART9 {
1648+
type RxPin = Rx;
1649+
type TxPin = Tx;
1650+
}
16061651
}
16071652

16081653
#[cfg(feature = "uart10")]
@@ -1613,6 +1658,11 @@ pub mod uart10 {
16131658
<Tx> for no:NoPin, [PE3<11>, PG12<11>,],
16141659
<Rx> for no:NoPin, [PE2<11>, PG11<11>,],
16151660
}
1661+
1662+
impl crate::serial::CommonPins for crate::pac::UART10 {
1663+
type RxPin = Rx;
1664+
type TxPin = Tx;
1665+
}
16161666
}
16171667

16181668
#[cfg(feature = "sdio")]

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ pub mod time;
172172
#[cfg(feature = "device-selected")]
173173
pub mod timer;
174174
#[cfg(feature = "device-selected")]
175+
#[cfg(feature = "uart4")]
176+
pub mod uart;
177+
#[cfg(feature = "device-selected")]
175178
pub mod watchdog;
176179

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

src/prelude.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,5 @@ pub use crate::timer::PwmExt as _stm32f4xx_hal_timer_PwmExt;
8686
pub use crate::timer::SysMonoTimerExt as _stm32f4xx_hal_timer_SysMonoTimerExt;
8787
pub use crate::timer::SysTimerExt as _stm32f4xx_hal_timer_SysCounterExt;
8888
pub use crate::timer::TimerExt as _stm32f4xx_hal_timer_TimerExt;
89+
#[cfg(feature = "uart4")]
90+
pub use crate::uart::SerialExt as _stm32f4xx_hal_uart_SerialExt;

0 commit comments

Comments
 (0)