-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove ufmt dependency and test on hardware
- Loading branch information
Showing
4 changed files
with
127 additions
and
118 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use core::panic::PanicInfo; | ||
use heapless::String; | ||
use litex_pac as pac; | ||
use litex_hal::prelude::*; | ||
use litex_hal::uart::UartError; | ||
use ufmt; | ||
|
||
litex_hal::uart! { | ||
Uart: pac::UART, | ||
} | ||
|
||
static mut UART_WRITER: Option<Uart> = None; | ||
|
||
#[panic_handler] | ||
fn panic(_: &PanicInfo) -> ! { | ||
info!("PANIC"); | ||
loop {} | ||
} | ||
|
||
pub fn _logger_write(bytes: &[u8]) { | ||
unsafe { | ||
if let Some(writer) = &mut UART_WRITER { | ||
writer.bwrite_all(bytes).ok(); | ||
} | ||
} | ||
} | ||
|
||
pub fn init(uart: pac::UART) { | ||
unsafe { | ||
UART_WRITER = Some(Uart::new(uart)); | ||
if let Some(writer) = &mut UART_WRITER { | ||
writer | ||
.bwrite_all(b"UART logger up!\n") | ||
.ok(); | ||
} | ||
} | ||
} | ||
|
||
macro_rules! info { | ||
() => { | ||
_logger_write(b"\n"); | ||
}; | ||
($($arg:tt)*) => {{ | ||
let mut s: String<256> = String::new(); | ||
ufmt::uwrite!(&mut s, $($arg)*).ok(); | ||
_logger_write(&s.into_bytes()); | ||
_logger_write(b"\n"); | ||
}}; | ||
} | ||
|
||
pub(crate) use info; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters