move debug lib in bdma so we can gate it on/off more easily

This commit is contained in:
bunnie 2025-09-14 02:10:10 +08:00
parent 0391a6aef5
commit e87501f14d
4 changed files with 8 additions and 3 deletions

View file

@ -25,6 +25,7 @@ baremetal = []
std = []
arty = []
bio-mul = []
debug-print = []
tests = []
default = ["tests", "cramium-soc"]

View file

@ -1,5 +1,4 @@
pub mod arith;
pub(crate) mod debug;
pub mod dma;
pub mod i2c;
pub mod spi;

View file

@ -1,15 +1,20 @@
#[cfg(feature = "debug-print")]
use utralib::generated::*;
pub struct Uart {
// pub base: *mut u32,
}
impl Uart {
#[cfg(feature = "debug-print")]
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);
}
#[cfg(not(feature = "debug-print"))]
pub fn putc(&self, _c: u8) {}
}
use core::fmt::{Error, Write};
@ -29,7 +34,7 @@ pub mod debug_print_hardware {
{
($($args:tt)+) => ({
use core::fmt::Write;
let _ = write!(crate::bio_tests::debug::Uart {}, $($args)+);
let _ = write!(crate::debug::Uart {}, $($args)+);
});
}
}

View file

@ -37,7 +37,7 @@ use utralib::generated::*;
#[cfg(feature = "tests")]
pub mod bio_tests;
pub(crate) mod debug;
pub mod i2c;
#[repr(usize)]