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

Merge pull request #13 from skyzh/patch-1

Add data flush in uart put function
This commit is contained in:
Stephen Marz 2020-02-22 08:58:52 -05:00 committed by GitHub
commit a36db7e8aa
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);
}
}