forked from M-Labs/zynq-rs
uart: impl fmt::Write
This commit is contained in:
parent
ca9b10dce8
commit
275f297309
@ -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();
|
||||
}
|
||||
|
@ -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(())
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user