42 lines
1.1 KiB
Rust
42 lines
1.1 KiB
Rust
use core::panic::PanicInfo;
|
|
use core::fmt::Write;
|
|
|
|
use crate::console::Console;
|
|
use nano5g::lcd::{LCD, Display};
|
|
use s5l87xx::Peripherals;
|
|
|
|
#[panic_handler]
|
|
fn panic(info: &PanicInfo) -> ! {
|
|
let periphs = unsafe { Peripherals::steal() };
|
|
let lcd = LCD::new(periphs.LCD);
|
|
let mut display = Display::new(lcd);
|
|
|
|
let mut console = Console::<{240/6}, {320/14}>::new();
|
|
|
|
console.write_str("Panic!\n");
|
|
console.blit(&mut display);
|
|
display.flush();
|
|
|
|
if let Some(s) = info.payload().downcast_ref::<&str>() {
|
|
core::fmt::write(&mut console, format_args!(
|
|
"Payload: {:?}\n", s,
|
|
));
|
|
} else if let Some(a) = info.message() {
|
|
console.write_str("Message: ");
|
|
core::fmt::write(&mut console, *a);
|
|
console.write_str("\n");
|
|
}
|
|
console.blit(&mut display);
|
|
display.flush();
|
|
|
|
if let Some(location) = info.location() {
|
|
core::fmt::write(&mut console, format_args!("In {}:{}\n", location.file(), location.line()));
|
|
} else {
|
|
console.write_str("No location information.\n");
|
|
}
|
|
console.blit(&mut display);
|
|
display.flush();
|
|
|
|
loop {}
|
|
}
|