Merge pull request #2859 from bsodmike/add_trace_logging_for_uart

Add trace logging for USART
This commit is contained in:
Dario Nieuwenhuis 2024-04-26 20:22:22 +00:00 committed by GitHub
commit b7479e36e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1270,8 +1270,14 @@ fn configure(
let (mul, brr_min, brr_max) = match kind { let (mul, brr_min, brr_max) = match kind {
#[cfg(any(usart_v3, usart_v4))] #[cfg(any(usart_v3, usart_v4))]
Kind::Lpuart => (256, 0x300, 0x10_0000), Kind::Lpuart => {
Kind::Uart => (1, 0x10, 0x1_0000), trace!("USART: Kind::Lpuart");
(256, 0x300, 0x10_0000)
}
Kind::Uart => {
trace!("USART: Kind::Uart");
(1, 0x10, 0x1_0000)
}
}; };
fn calculate_brr(baud: u32, pclk: u32, presc: u32, mul: u32) -> u32 { fn calculate_brr(baud: u32, pclk: u32, presc: u32, mul: u32) -> u32 {
@ -1374,21 +1380,35 @@ fn configure(
// configure word size // configure word size
// if using odd or even parity it must be configured to 9bits // if using odd or even parity it must be configured to 9bits
w.set_m0(if config.parity != Parity::ParityNone { w.set_m0(if config.parity != Parity::ParityNone {
trace!("USART: m0: vals::M0::BIT9");
vals::M0::BIT9 vals::M0::BIT9
} else { } else {
trace!("USART: m0: vals::M0::BIT8");
vals::M0::BIT8 vals::M0::BIT8
}); });
// configure parity // configure parity
w.set_pce(config.parity != Parity::ParityNone); w.set_pce(config.parity != Parity::ParityNone);
w.set_ps(match config.parity { w.set_ps(match config.parity {
Parity::ParityOdd => vals::Ps::ODD, Parity::ParityOdd => {
Parity::ParityEven => vals::Ps::EVEN, trace!("USART: set_ps: vals::Ps::ODD");
_ => vals::Ps::EVEN, vals::Ps::ODD
}
Parity::ParityEven => {
trace!("USART: set_ps: vals::Ps::EVEN");
vals::Ps::EVEN
}
_ => {
trace!("USART: set_ps: vals::Ps::EVEN");
vals::Ps::EVEN
}
}); });
#[cfg(not(usart_v1))] #[cfg(not(usart_v1))]
w.set_over8(vals::Over8::from_bits(over8 as _)); w.set_over8(vals::Over8::from_bits(over8 as _));
#[cfg(usart_v4)] #[cfg(usart_v4)]
w.set_fifoen(true); {
trace!("USART: set_fifoen: true (usart_v4)");
w.set_fifoen(true);
}
}); });
Ok(()) Ok(())