mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
add debug pretty-printing to test
This commit is contained in:
parent
ac95f9a6df
commit
ccc342d9f3
1 changed files with 49 additions and 0 deletions
49
libs/xous-bio/src/bio_tests/debug.rs
Normal file
49
libs/xous-bio/src/bio_tests/debug.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
use utralib::generated::*;
|
||||||
|
pub struct Uart {
|
||||||
|
// pub base: *mut u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Uart {
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
let base = utra::duart::HW_DUART_BASE as *mut u32;
|
||||||
|
let mut uart = CSR::new(base);
|
||||||
|
while uart.r(utra::duart::SFR_SR) != 0 {}
|
||||||
|
uart.wo(utra::duart::SFR_TXD, c as u32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use core::fmt::{Error, Write};
|
||||||
|
impl Write for Uart {
|
||||||
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
for c in s.bytes() {
|
||||||
|
self.putc(c);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
pub mod debug_print_hardware {
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! print
|
||||||
|
{
|
||||||
|
($($args:tt)+) => ({
|
||||||
|
use core::fmt::Write;
|
||||||
|
let _ = write!(crate::bio_tests::debug::Uart {}, $($args)+);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! println
|
||||||
|
{
|
||||||
|
() => ({
|
||||||
|
$crate::print!("\r\n")
|
||||||
|
});
|
||||||
|
($fmt:expr) => ({
|
||||||
|
$crate::print!(concat!($fmt, "\r\n"))
|
||||||
|
});
|
||||||
|
($fmt:expr, $($args:tt)+) => ({
|
||||||
|
$crate::print!(concat!($fmt, "\r\n"), $($args)+)
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue