mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
convert kernel debug to utra
This commit is contained in:
parent
67c49ddbce
commit
62b625ec60
1 changed files with 19 additions and 22 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
|
use utralib::generated::*;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))]
|
#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))]
|
||||||
pub mod debug_print_hardware {
|
pub mod debug_print_hardware {
|
||||||
|
|
@ -48,38 +50,33 @@ pub struct Uart {
|
||||||
impl Uart {
|
impl Uart {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn enable_rx(self) {
|
pub fn enable_rx(self) {
|
||||||
unsafe {
|
let mut uart_csr = CSR::new(self.base as *mut u32);
|
||||||
self.base
|
uart_csr.wfo(utra::uart::EV_ENABLE_ENABLE, uart_csr.rf(utra::uart::EV_ENABLE_ENABLE) | 2);
|
||||||
.add(5)
|
|
||||||
.write_volatile(self.base.add(5).read_volatile() | 2)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn putc(&self, c: u8) {
|
pub fn putc(&self, c: u8) {
|
||||||
unsafe {
|
let mut uart_csr = CSR::new(self.base as *mut u32);
|
||||||
// Wait until TXFULL is `0`
|
// Wait until TXFULL is `0`
|
||||||
while self.base.add(1).read_volatile() != 0 {
|
while uart_csr.r(utra::uart::TXFULL) != 0 {
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
self.base.add(0).write_volatile(c as usize)
|
uart_csr.wfo(utra::uart::RXTX_RXTX, c as u32);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn getc(&self) -> Option<u8> {
|
pub fn getc(&self) -> Option<u8> {
|
||||||
unsafe {
|
let mut uart_csr = CSR::new(self.base as *mut u32);
|
||||||
// If EV_PENDING_RX is 1, return the pending character.
|
// If EV_PENDING_RX is 1, return the pending character.
|
||||||
// Otherwise, return None.
|
// Otherwise, return None.
|
||||||
match self.base.add(4).read_volatile() & 2 {
|
match uart_csr.r(utra::uart::EV_PENDING) & 2 {
|
||||||
0 => None,
|
0 => None,
|
||||||
ack => {
|
ack => {
|
||||||
let c = Some(self.base.add(0).read_volatile() as u8);
|
let c = Some(uart_csr.r(utra::uart::RXTX) as u8);
|
||||||
self.base.add(4).write_volatile(ack);
|
uart_csr.wo(utra::uart::EV_PENDING, ack);
|
||||||
c
|
c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))]
|
#[cfg(all(not(test), any(feature = "debug-print", feature = "print-panics")))]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue