mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-04 13:38:28 +00:00
34 lines
700 B
Rust
34 lines
700 B
Rust
|
use ufmt;
|
||
|
|
||
|
#[cfg(feature = "micropython")]
|
||
|
use crate::micropython;
|
||
|
|
||
|
pub struct DebugConsole;
|
||
|
|
||
|
impl ufmt::uWrite for DebugConsole {
|
||
|
type Error = core::convert::Infallible;
|
||
|
|
||
|
fn write_str(&mut self, s: &str) -> Result<(), Self::Error> {
|
||
|
#[cfg(feature = "micropython")]
|
||
|
micropython::print::print(s);
|
||
|
|
||
|
// TODO: add alternative if micropython is not available
|
||
|
|
||
|
Ok(())
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[macro_export]
|
||
|
macro_rules! dbg_println {
|
||
|
($($args:tt)*) => {
|
||
|
ufmt::uwriteln!($crate::debug::DebugConsole, $($args)*).ok();
|
||
|
};
|
||
|
}
|
||
|
|
||
|
#[macro_export]
|
||
|
macro_rules! dbg_print {
|
||
|
($($args:tt)*) => {
|
||
|
ufmt::uwrite!($crate::debug::DebugConsole, $($args)*).ok();
|
||
|
};
|
||
|
}
|