1
0
Fork 0

uart: impl fmt::Write

This commit is contained in:
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(naked_functions)]
use core::fmt::Write;
use panic_abort as _;
use r0::zero_bss;
@ -44,8 +46,6 @@ pub unsafe extern "C" fn _boot_cores() -> ! {
}
fn main() {
let uart = Uart::uart0();
for b in "Hello World\r\n".bytes() {
uart.write_byte(b);
}
let mut uart = Uart::uart0();
writeln!(uart, "Hello World\r").unwrap();
}

View File

@ -1,5 +1,7 @@
#![allow(unused)]
use core::fmt;
mod regs;
pub use regs::RegisterBlock;
@ -32,3 +34,12 @@ impl Uart {
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(())
}
}