From e87501f14d1cc7289e918a3e2503809f52cd37f5 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 14 Sep 2025 02:10:10 +0800 Subject: [PATCH] move debug lib in bdma so we can gate it on/off more easily --- libs/xous-bio-bdma/Cargo.toml | 1 + libs/xous-bio-bdma/src/bio_tests/mod.rs | 1 - libs/xous-bio-bdma/src/{bio_tests => }/debug.rs | 7 ++++++- libs/xous-bio-bdma/src/lib.rs | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) rename libs/xous-bio-bdma/src/{bio_tests => }/debug.rs (82%) diff --git a/libs/xous-bio-bdma/Cargo.toml b/libs/xous-bio-bdma/Cargo.toml index c3a9c04f6..b59fb4b4e 100644 --- a/libs/xous-bio-bdma/Cargo.toml +++ b/libs/xous-bio-bdma/Cargo.toml @@ -25,6 +25,7 @@ baremetal = [] std = [] arty = [] bio-mul = [] +debug-print = [] tests = [] default = ["tests", "cramium-soc"] diff --git a/libs/xous-bio-bdma/src/bio_tests/mod.rs b/libs/xous-bio-bdma/src/bio_tests/mod.rs index 7420fdb47..f62111a2b 100644 --- a/libs/xous-bio-bdma/src/bio_tests/mod.rs +++ b/libs/xous-bio-bdma/src/bio_tests/mod.rs @@ -1,5 +1,4 @@ pub mod arith; -pub(crate) mod debug; pub mod dma; pub mod i2c; pub mod spi; diff --git a/libs/xous-bio-bdma/src/bio_tests/debug.rs b/libs/xous-bio-bdma/src/debug.rs similarity index 82% rename from libs/xous-bio-bdma/src/bio_tests/debug.rs rename to libs/xous-bio-bdma/src/debug.rs index 26930f138..28882614d 100644 --- a/libs/xous-bio-bdma/src/bio_tests/debug.rs +++ b/libs/xous-bio-bdma/src/debug.rs @@ -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)+); }); } } diff --git a/libs/xous-bio-bdma/src/lib.rs b/libs/xous-bio-bdma/src/lib.rs index a51129edb..e41e818b7 100644 --- a/libs/xous-bio-bdma/src/lib.rs +++ b/libs/xous-bio-bdma/src/lib.rs @@ -37,7 +37,7 @@ use utralib::generated::*; #[cfg(feature = "tests")] pub mod bio_tests; - +pub(crate) mod debug; pub mod i2c; #[repr(usize)]