mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
add println_d! macro to bao1x-hal
this allows forcing prints to go to the duart this is useful for debugging early boot issues
This commit is contained in:
parent
e5790d76a3
commit
5195d46d7b
1 changed files with 53 additions and 0 deletions
|
|
@ -139,3 +139,56 @@ macro_rules! println
|
||||||
$crate::print!(concat!($fmt, "\r\n"), $($args)+)
|
$crate::print!(concat!($fmt, "\r\n"), $($args)+)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==== DUART-only debug print ====
|
||||||
|
// Used for forcing the use of DUART in debugging
|
||||||
|
pub struct Duart {}
|
||||||
|
|
||||||
|
impl Duart {
|
||||||
|
/// Print a character
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
let base = utra::duart::HW_DUART_BASE as *mut u32;
|
||||||
|
let mut uart = CSR::new(base);
|
||||||
|
if uart.rf(utra::duart::SFR_CR_SFR_CR) == 0 {
|
||||||
|
uart.wfo(utra::duart::SFR_CR_SFR_CR, 1);
|
||||||
|
}
|
||||||
|
while uart.r(utra::duart::SFR_SR) != 0 {}
|
||||||
|
uart.wo(utra::duart::SFR_TXD, c as u32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Write for Duart {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
for c in s.bytes() {
|
||||||
|
self.putc(c);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
/// Hardware debug print module
|
||||||
|
pub mod debug_print_duart {
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! print_d
|
||||||
|
{
|
||||||
|
($($args:tt)+) => ({
|
||||||
|
use core::fmt::Write;
|
||||||
|
let _ = write!(crate::debug::Duart {}, $($args)+);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! println_d
|
||||||
|
{
|
||||||
|
() => ({
|
||||||
|
$crate::print_d!("\r\n")
|
||||||
|
});
|
||||||
|
($fmt:expr) => ({
|
||||||
|
$crate::print_d!(concat!($fmt, "\r\n"))
|
||||||
|
});
|
||||||
|
($fmt:expr, $($args:tt)+) => ({
|
||||||
|
$crate::print_d!(concat!($fmt, "\r\n"), $($args)+)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue