Make UART pins Rx/Tx/etc in addition to USART.

This commit is contained in:
Bob McWhirter
2021-07-01 11:26:56 -04:00
parent 54ada5bae1
commit 0920c0cb1d
4 changed files with 129 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#![macro_use]
#[cfg_attr(usart_v1, path = "v1.rs")]
#[cfg_attr(usart_v2, path = "v2.rs")]
//#[cfg_attr(usart_v1, path = "v1.rs")]
//#[cfg_attr(usart_v2, path = "v2.rs")]
#[cfg_attr(usart_v3, path = "v3.rs")]
mod _version;
use crate::peripherals;
@ -140,6 +140,9 @@ macro_rules! impl_pin {
}
crate::pac::peripheral_pins!(
// USART
($inst:ident, usart, USART, $pin:ident, TX, $af:expr) => {
impl_pin!($inst, $pin, TxPin, $af);
};
@ -159,4 +162,26 @@ crate::pac::peripheral_pins!(
($inst:ident, usart, USART, $pin:ident, CK, $af:expr) => {
impl_pin!($inst, $pin, CkPin, $af);
};
// UART
($inst:ident, uart, UART, $pin:ident, TX, $af:expr) => {
impl_pin!($inst, $pin, TxPin, $af);
};
($inst:ident, uart, UART, $pin:ident, RX, $af:expr) => {
impl_pin!($inst, $pin, RxPin, $af);
};
($inst:ident, uart, UART, $pin:ident, CTS, $af:expr) => {
impl_pin!($inst, $pin, CtsPin, $af);
};
($inst:ident, uart, UART, $pin:ident, RTS, $af:expr) => {
impl_pin!($inst, $pin, RtsPin, $af);
};
($inst:ident, uart, UART, $pin:ident, CK, $af:expr) => {
impl_pin!($inst, $pin, CkPin, $af);
};
);

View File

@ -22,7 +22,7 @@ impl<'d, T: Instance> Uart<'d, T> {
unborrow!(inner, rx, tx);
// Uncomment once we find all of the H7's UART clocks.
//T::enable();
T::enable();
let pclk_freq = T::frequency();
// TODO: better calculation, including error checking and OVER8 if possible.
@ -65,7 +65,7 @@ impl<'d, T: Instance> Uart<'d, T> {
});
}
let r = self.inner.regs();
let dst = r.dr().ptr() as *mut u8;
let dst = r.tdr().ptr() as *mut u8;
ch.transfer(buffer, dst).await;
Ok(())
}