First commit
This commit is contained in:
9
src/uart.rs
Normal file
9
src/uart.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
const UART_BASE: *mut u8 = 0x10000000 as *mut _;
|
||||
pub fn write_char_uart(c: char) {
|
||||
while unsafe { core::ptr::read_volatile(UART_BASE.byte_add(0x5)) } >> 5 & 1 == 0 {}
|
||||
unsafe { core::ptr::write_volatile(UART_BASE, c as u8) };
|
||||
}
|
||||
|
||||
pub fn write_uart<T: AsRef<str>>(print: T) {
|
||||
print.as_ref().chars().for_each(write_char_uart);
|
||||
}
|
||||
Reference in New Issue
Block a user