uart: impl fmt::Write

multiprocessing
Astro 2019-05-07 16:45:31 +02:00
parent ca9b10dce8
commit 275f297309
2 changed files with 15 additions and 4 deletions

View File

@ -4,6 +4,8 @@
//[feature(global_asm)] //[feature(global_asm)]
#![feature(naked_functions)] #![feature(naked_functions)]
use core::fmt::Write;
use panic_abort as _; use panic_abort as _;
use r0::zero_bss; use r0::zero_bss;
@ -44,8 +46,6 @@ pub unsafe extern "C" fn _boot_cores() -> ! {
} }
fn main() { fn main() {
let uart = Uart::uart0(); let mut uart = Uart::uart0();
for b in "Hello World\r\n".bytes() { writeln!(uart, "Hello World\r").unwrap();
uart.write_byte(b);
}
} }

View File

@ -1,5 +1,7 @@
#![allow(unused)] #![allow(unused)]
use core::fmt;
mod regs; mod regs;
pub use regs::RegisterBlock; pub use regs::RegisterBlock;
@ -32,3 +34,12 @@ impl Uart {
self.regs.write_byte(v); self.regs.write_byte(v);
} }
} }
impl fmt::Write for Uart {
fn write_str(&mut self, s: &str) -> Result<(), fmt::Error> {
for b in s.bytes() {
self.write_byte(b);
}
Ok(())
}
}