blob: a2e33f33261321a1c1e993dc595b10c48d070d71 [file] [log] [blame]
//! Unsafe synchronous dump-string-to-uart impl and macro for debugging.
use core::fmt;
use core2::io::{Cursor, Write};
// Convenience wrapper since capsules can't use unsafe{}
pub fn send_sync(buf: &[u8], len: usize) {
unsafe {
crate::uart_hal::UART0.transmit_sync(&buf[..len]);
}
}
pub fn vdprintf(args: fmt::Arguments) {
let mut uart_buf = [0u8; 256];
let mut cur = Cursor::new(&mut uart_buf[..]);
if cur.write_fmt(args).is_ok() {
let pos = cur.position();
send_sync(&uart_buf, pos as usize);
}
}
#[macro_export]
macro_rules! dprintf {
($msg:expr) => ({
$crate::dprintf_hal::vdprintf(format_args!($msg))
});
($fmt:expr, $($arg:tt)+) => ({
$crate::dprintf_hal::vdprintf(format_args!($fmt, $($arg)+))
});
}