use core::fmt; use core::fmt::Write; pub fn _print(args: fmt::Arguments) { // Not thread safe but no dependencies let mut stdout = Stdout; fmt::write(&mut stdout, args); } struct Stdout; impl Write for Stdout { fn write_str(&mut self, s: &str) -> fmt::Result { print_string(s); Ok(()) } } pub fn print_string(s: &str) { let uart_base = 0x10000000 as *mut u8; while unsafe { uart_base.add(5).read_volatile() } & 0x20 == 0 {} for c in s.chars() { unsafe { uart_base.write_volatile(c as u8); } } }