1use crate::pac;
18
19use crate::serial::uart_impls::RegisterBlockUart;
20
21pub use crate::serial::{config, Error, Event, Instance, NoRx, NoTx, Rx, RxISR, Serial, Tx, TxISR};
22pub use config::Config;
23
24macro_rules! halUart {
25 ($UART:ty, $Serial:ident, $Rx:ident, $Tx:ident) => {
26 pub type $Serial<WORD = u8> = Serial<$UART, WORD>;
27 pub type $Tx<WORD = u8> = Tx<$UART, WORD>;
28 pub type $Rx<WORD = u8> = Rx<$UART, WORD>;
29
30 impl Instance for $UART {
31 fn set_stopbits(&self, bits: config::StopBits) {
32 use crate::pac::uart4::cr2::STOP;
33 use config::StopBits;
34
35 self.cr2().write(|w| {
40 w.stop().variant(match bits {
41 StopBits::STOP0P5 => STOP::Stop1,
42 StopBits::STOP1 => STOP::Stop1,
43 StopBits::STOP1P5 => STOP::Stop2,
44 StopBits::STOP2 => STOP::Stop2,
45 })
46 });
47 }
48 }
49
50 impl crate::Ptr for $UART {
51 type RB = RegisterBlockUart;
52
53 fn ptr() -> *const Self::RB {
54 Self::ptr()
55 }
56 }
57
58 impl crate::Steal for $UART {
59 unsafe fn steal() -> Self {
60 Self::steal()
61 }
62 }
63 };
64}
65
66#[cfg(feature = "uart4")]
67halUart! { pac::UART4, Serial4, Rx4, Tx4 }
68#[cfg(feature = "uart5")]
69halUart! { pac::UART5, Serial5, Rx5, Tx5 }
70#[cfg(feature = "uart7")]
71halUart! { pac::UART7, Serial7, Rx7, Tx7 }
72#[cfg(feature = "uart8")]
73halUart! { pac::UART8, Serial8, Rx8, Tx8 }
74#[cfg(feature = "uart9")]
75halUart! { pac::UART9, Serial9, Rx9, Tx9 }
76#[cfg(feature = "uart10")]
77halUart! { pac::UART10, Serial10, Rx10, Tx10 }