Skip to content

Commit f655a95

Browse files
committed
Cherry pick LPUART implementation only, fix DMA tx request numbers, fix some warnings.
1 parent 80a83bc commit f655a95

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/serial.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ macro_rules! hal {
203203
$usartXen:ident,
204204
$usartXrst:ident,
205205
$pclkX:ident,
206-
tx: ($dmacst:ident, $tx_chan:path),
206+
tx: ($dmacst:ident, $dmareq: literal, $tx_chan:path),
207207
rx: ($dmacsr:ident, $rx_chan:path),
208208
$is_full_uart:ident,
209209
),
@@ -654,13 +654,12 @@ macro_rules! hal {
654654

655655
/// Checks to see if the USART peripheral has detected an receiver timeout and
656656
/// clears the flag
657-
pub fn is_receiver_timeout(&mut self, clear: bool) -> bool {
658-
let isr = unsafe { &(*pac::$USARTX::ptr()).isr.read() };
659-
let icr = unsafe { &(*pac::$USARTX::ptr()).icr };
660-
657+
pub fn is_receiver_timeout(&mut self, _clear: bool) -> bool {
661658
potentially_uncompilable!($is_full_uart, {
659+
let isr = unsafe { &(*pac::$USARTX::ptr()).isr.read() };
660+
let icr = unsafe { &(*pac::$USARTX::ptr()).icr };
662661
if isr.rtof().bit_is_set() {
663-
if clear {
662+
if _clear {
664663
icr.write(|w| w.rtocf().set_bit() );
665664
}
666665
true
@@ -719,7 +718,7 @@ macro_rules! hal {
719718

720719
// Tell DMA to request from serial
721720
channel.cselr().modify(|_, w| {
722-
w.$dmacst().bits(0b0010) // TODO: Fix this, not valid for DMA2
721+
w.$dmacst().bits($dmareq)
723722
});
724723

725724
channel.ccr().modify(|_, w| unsafe {
@@ -747,8 +746,8 @@ macro_rules! hal {
747746
}
748747

749748
hal! {
750-
USART1: (usart1, APB2, usart1en, usart1rst, pclk2, tx: (c4s, dma1::C4), rx: (c5s, dma1::C5), true,),
751-
USART2: (usart2, APB1R1, usart2en, usart2rst, pclk1, tx: (c7s, dma1::C7), rx: (c6s, dma1::C6), true,),
749+
USART1: (usart1, APB2, usart1en, usart1rst, pclk2, tx: (c4s, 0b0010, dma1::C4), rx: (c5s, dma1::C5), true,),
750+
USART2: (usart2, APB1R1, usart2en, usart2rst, pclk1, tx: (c7s, 0b0010, dma1::C7), rx: (c6s, dma1::C6), true,),
752751
}
753752

754753
#[cfg(any(
@@ -758,22 +757,22 @@ hal! {
758757
feature = "stm32l4x6",
759758
))]
760759
hal! {
761-
USART3: (usart3, APB1R1, usart3en, usart3rst, pclk1, tx: (c2s, dma1::C2), rx: (c3s, dma1::C3), true,),
760+
USART3: (usart3, APB1R1, usart3en, usart3rst, pclk1, tx: (c2s, 0b0010, dma1::C2), rx: (c3s, dma1::C3), true,),
762761
}
763762

764763
#[cfg(any(feature = "stm32l4x5", feature = "stm32l4x6",))]
765764
hal! {
766-
UART4: (uart4, APB1R1, uart4en, uart4rst, pclk1, tx: (c3s, dma2::C3), rx: (c5s, dma2::C5), true,),
765+
UART4: (uart4, APB1R1, uart4en, uart4rst, pclk1, tx: (c3s, 0b0010, dma2::C3), rx: (c5s, dma2::C5), true,),
767766
}
768767

769768
#[cfg(any(feature = "stm32l4x5", feature = "stm32l4x6",))]
770769
hal! {
771-
UART5: (uart5, APB1R1, uart5en, uart5rst, pclk1, tx: (c1s, dma2::C1), rx: (c2s, dma2::C2), true,),
770+
UART5: (uart5, APB1R1, uart5en, uart5rst, pclk1, tx: (c1s, 0b0010, dma2::C1), rx: (c2s, dma2::C2), true,),
772771
}
773772

774773
#[cfg(feature = "stm32l4x6")]
775774
hal! {
776-
LPUART1: (lpuart1, APB1R2, lpuart1en, lpuart1rst, pclk1, tx: (c6s, dma2::C6), rx: (c7s, dma2::C7), false,),
775+
LPUART1: (lpuart1, APB1R2, lpuart1en, lpuart1rst, pclk1, tx: (c6s, 0b0100, dma2::C6), rx: (c7s, dma2::C7), false,),
777776
}
778777

779778
impl<USART, PINS> fmt::Write for Serial<USART, PINS>

0 commit comments

Comments
 (0)