Skip to content

Commit

Permalink
Don't define UARTs as USARTs.
Browse files Browse the repository at this point in the history
Due to svd bugs, some UART peripherals were defined as USARTs.  This
commit relies on PAC changes made in:
stm32-rs/stm32-rs#754
  • Loading branch information
tim-seoss committed Jul 5, 2022
1 parent 1d51da6 commit fa7f43b
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,10 @@ impl<USART: Instance, PINS, WORD> Serial<USART, PINS, WORD> {
#[cfg(any(
feature = "stm32f405",
feature = "stm32f407",
feature = "stm32f413",
feature = "stm32f415",
feature = "stm32f417",
feature = "stm32f423",
feature = "stm32f427",
feature = "stm32f429",
feature = "stm32f437",
Expand All @@ -685,8 +687,10 @@ use crate::pac::uart4 as uart_base;
#[cfg(not(any(
feature = "stm32f405",
feature = "stm32f407",
feature = "stm32f413",
feature = "stm32f415",
feature = "stm32f417",
feature = "stm32f423",
feature = "stm32f427",
feature = "stm32f429",
feature = "stm32f437",
Expand Down Expand Up @@ -733,7 +737,6 @@ macro_rules! halUsart {
};
}

// TODO: fix stm32f413 UARTs
#[cfg(any(
feature = "uart4",
feature = "uart5",
Expand All @@ -742,7 +745,6 @@ macro_rules! halUsart {
feature = "uart9",
feature = "uart10"
))]
#[cfg(not(any(feature = "stm32f413", feature = "stm32f423",)))]
macro_rules! halUart {
($USART:ty, $Serial:ident, $Tx:ident, $Rx:ident) => {
pub type $Serial<PINS, WORD = u8> = Serial<$USART, PINS, WORD>;
Expand Down Expand Up @@ -777,29 +779,18 @@ halUsart! { pac::USART6, Serial6, Rx6, Tx6 }

#[cfg(feature = "usart3")]
halUsart! { pac::USART3, Serial3, Rx3, Tx3 }

#[cfg(feature = "uart4")]
#[cfg(not(any(feature = "stm32f413", feature = "stm32f423")))]
halUart! { pac::UART4, Serial4, Rx4, Tx4 }
#[cfg(feature = "uart5")]
#[cfg(not(any(feature = "stm32f413", feature = "stm32f423")))]
halUart! { pac::UART5, Serial5, Rx5, Tx5 }

#[cfg(feature = "uart4")]
#[cfg(any(feature = "stm32f413", feature = "stm32f423"))]
halUsart! { pac::UART4, Serial4, Rx4, Tx4 }
#[cfg(feature = "uart5")]
#[cfg(any(feature = "stm32f413", feature = "stm32f423"))]
halUsart! { pac::UART5, Serial5, Rx5, Tx5 }

#[cfg(feature = "uart7")]
halUsart! { pac::UART7, Serial7, Rx7, Tx7 }
halUart! { pac::UART7, Serial7, Rx7, Tx7 }
#[cfg(feature = "uart8")]
halUsart! { pac::UART8, Serial8, Rx8, Tx8 }
halUart! { pac::UART8, Serial8, Rx8, Tx8 }
#[cfg(feature = "uart9")]
halUsart! { pac::UART9, Serial9, Rx9, Tx9 }
halUart! { pac::UART9, Serial9, Rx9, Tx9 }
#[cfg(feature = "uart10")]
halUsart! { pac::UART10, Serial10, Rx10, Tx10 }
halUart! { pac::UART10, Serial10, Rx10, Tx10 }

impl<USART: Instance, PINS> fmt::Write for Serial<USART, PINS> {
fn write_str(&mut self, s: &str) -> fmt::Result {
Expand Down

0 comments on commit fa7f43b

Please sign in to comment.