mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
format xous-pio
This commit is contained in:
parent
f00293a3a8
commit
ee2c7ef140
1 changed files with 19 additions and 24 deletions
|
|
@ -1,10 +1,10 @@
|
|||
pub mod adder;
|
||||
pub mod i2c;
|
||||
pub mod nec;
|
||||
pub mod spi;
|
||||
pub mod units;
|
||||
pub mod adder;
|
||||
pub mod nec;
|
||||
|
||||
#[cfg(not(any(target_os="xous", feature="rp2040")))]
|
||||
#[cfg(not(any(target_os = "xous", feature = "rp2040")))]
|
||||
mod duart {
|
||||
pub const UART_DOUT: utralib::Register = utralib::Register::new(0, 0xff);
|
||||
pub const UART_DOUT_DOUT: utralib::Field = utralib::Field::new(8, 0, UART_DOUT);
|
||||
|
|
@ -16,35 +16,32 @@ mod duart {
|
|||
pub const HW_DUART_BASE: usize = 0x4004_2000;
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os="xous", feature="rp2040")))]
|
||||
#[cfg(not(any(target_os = "xous", feature = "rp2040")))]
|
||||
use utralib::CSR;
|
||||
#[cfg(not(any(target_os="xous", feature="rp2040")))]
|
||||
pub struct Uart {
|
||||
}
|
||||
#[cfg(not(any(target_os="xous", feature="rp2040")))]
|
||||
#[cfg(not(any(target_os = "xous", feature = "rp2040")))]
|
||||
pub struct Uart {}
|
||||
#[cfg(not(any(target_os = "xous", feature = "rp2040")))]
|
||||
impl Uart {
|
||||
fn put_digit(&mut self, d: u8) {
|
||||
let nyb = d & 0xF;
|
||||
let c = if nyb < 10 {
|
||||
nyb + 0x30
|
||||
} else {
|
||||
nyb + 0x61 - 10
|
||||
};
|
||||
let c = if nyb < 10 { nyb + 0x30 } else { nyb + 0x61 - 10 };
|
||||
assert!(c >= 0x30, "conversion failed!");
|
||||
self.putc(c);
|
||||
}
|
||||
|
||||
pub fn put_hex(&mut self, c: u8) {
|
||||
self.put_digit(c >> 4);
|
||||
self.put_digit(c & 0xF);
|
||||
}
|
||||
pub fn newline(&mut self) {
|
||||
self.putc(0xd);
|
||||
}
|
||||
|
||||
pub fn newline(&mut self) { self.putc(0xd); }
|
||||
|
||||
pub fn print_hex_word(&mut self, word: u32) {
|
||||
for &byte in word.to_be_bytes().iter() {
|
||||
self.put_hex(byte);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn putc(&self, c: u8) {
|
||||
let base = duart::HW_DUART_BASE as *mut u32;
|
||||
let mut uart = CSR::new(base);
|
||||
|
|
@ -57,7 +54,7 @@ impl Uart {
|
|||
}
|
||||
uart.wfo(duart::UART_DOUT_DOUT, c as u32);
|
||||
|
||||
#[cfg(feature="arty")]
|
||||
#[cfg(feature = "arty")]
|
||||
self.putc_litex(c);
|
||||
}
|
||||
|
||||
|
|
@ -66,23 +63,21 @@ impl Uart {
|
|||
self.putc(c);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os="xous", feature="rp2040")))]
|
||||
pub fn setup_reporting(_rep_adr: *mut u32) {
|
||||
}
|
||||
#[cfg(not(any(target_os = "xous", feature = "rp2040")))]
|
||||
pub fn setup_reporting(_rep_adr: *mut u32) {}
|
||||
|
||||
pub fn report_api(d: u32) {
|
||||
#[cfg(not(any(target_os="xous", feature="rp2040")))]
|
||||
#[cfg(not(any(target_os = "xous", feature = "rp2040")))]
|
||||
{
|
||||
let mut uart = Uart {};
|
||||
uart.print_hex_word(d);
|
||||
uart.newline();
|
||||
}
|
||||
#[cfg(target_os="xous")]
|
||||
#[cfg(target_os = "xous")]
|
||||
log::info!("report: 0x{:x}", d);
|
||||
#[cfg(feature="rp2040")]
|
||||
#[cfg(feature = "rp2040")]
|
||||
defmt::info!("report: 0x{:x}", d);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue