blob: 7aafeeff3e235b637a26a9267d5a930b7715ba97 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
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);
}
}
}
|