1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-23 18:06:20 +04:00

Add data flush in uart put function

This commit is contained in:
Alex Chi 2020-02-03 10:33:00 +08:00 committed by GitHub
parent e8e379e557
commit 2474df886c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -101,7 +101,14 @@ impl Uart {
pub fn put(&mut self, c: u8) {
let ptr = self.base_address as *mut u8;
loop {
// Wait until previous data is flushed
if unsafe { ptr.add(5).read_volatile() } & (1 << 5) != 0 {
break;
}
}
unsafe {
// Write data
ptr.add(0).write_volatile(c);
}
}