redboard_artemis_atp/
io.rs
1use core::fmt::Write;
6use core::panic::PanicInfo;
7use core::ptr::addr_of;
8use core::ptr::addr_of_mut;
9
10use crate::CHIP;
11use crate::PROCESSES;
12use crate::PROCESS_PRINTER;
13use kernel::debug;
14use kernel::debug::IoWrite;
15use kernel::hil::led;
16
17pub struct Writer {}
19
20pub static mut WRITER: Writer = Writer {};
22
23impl Write for Writer {
24 fn write_str(&mut self, s: &str) -> ::core::fmt::Result {
25 self.write(s.as_bytes());
26 Ok(())
27 }
28}
29
30impl IoWrite for Writer {
31 fn write(&mut self, buf: &[u8]) -> usize {
32 let uart = apollo3::uart::Uart::new_uart_0(); uart.transmit_sync(buf);
34 buf.len()
35 }
36}
37
38#[panic_handler]
40pub unsafe fn panic_fmt(info: &PanicInfo) -> ! {
41 let led_pin = &mut apollo3::gpio::GpioPin::new(
43 kernel::utilities::StaticRef::new(
44 apollo3::gpio::GPIO_BASE_RAW as *const apollo3::gpio::GpioRegisters,
45 ),
46 apollo3::gpio::Pin::Pin19,
47 );
48 let led = &mut led::LedLow::new(led_pin);
49 let writer = &mut *addr_of_mut!(WRITER);
50
51 debug::panic(
52 &mut [led],
53 writer,
54 info,
55 &cortexm4::support::nop,
56 &*addr_of!(PROCESSES),
57 &*addr_of!(CHIP),
58 &*addr_of!(PROCESS_PRINTER),
59 )
60}