Skip to content

Commit

Permalink
Merge pull request #1809 from tock/arty-e21-updates
Browse files Browse the repository at this point in the history
arty-e21 updates
  • Loading branch information
bradjc committed Apr 30, 2020
2 parents cd43a31 + 699c2c3 commit 9c52825
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
18 changes: 10 additions & 8 deletions boards/arty_e21/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,22 @@ use rv32i;
use crate::CHIP;
use crate::PROCESSES;

struct Writer;
struct Writer {}

static mut WRITER: Writer = Writer {};

impl Write for Writer {
fn write_str(&mut self, s: &str) -> ::core::fmt::Result {
debug!("{}", s);
self.write(s.as_bytes());
Ok(())
}
}

impl IoWrite for Writer {
fn write(&mut self, buf: &[u8]) {
let _ = self.write_str(unsafe { str::from_utf8_unchecked(buf) });
unsafe {
arty_e21_chip::uart::UART0.transmit_sync(buf);
}
}
}

Expand All @@ -34,15 +36,15 @@ impl IoWrite for Writer {
#[panic_handler]
pub unsafe extern "C" fn panic_fmt(pi: &PanicInfo) -> ! {
// turn off the non panic leds, just in case
let led_green = &arty_e21_chip::gpio::PORT[19];
let led_green = &arty_e21_chip::gpio::PORT[1];
gpio::Pin::make_output(led_green);
gpio::Pin::set(led_green);
gpio::Pin::clear(led_green);

let led_blue = &arty_e21_chip::gpio::PORT[21];
let led_blue = &arty_e21_chip::gpio::PORT[0];
gpio::Pin::make_output(led_blue);
gpio::Pin::set(led_blue);
gpio::Pin::clear(led_blue);

let led_red = &mut led::LedLow::new(&mut arty_e21_chip::gpio::PORT[22]);
let led_red = &mut led::LedHigh::new(&mut arty_e21_chip::gpio::PORT[2]);
let writer = &mut WRITER;
debug::panic(
&mut [led_red],
Expand Down
8 changes: 4 additions & 4 deletions boards/arty_e21/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ pub unsafe fn reset_handler() {

// Configure kernel debug gpios as early as possible
kernel::debug::assign_gpios(
Some(&arty_e21_chip::gpio::PORT[0]), // Red
Some(&arty_e21_chip::gpio::PORT[1]),
Some(&arty_e21_chip::gpio::PORT[0]), // Blue
Some(&arty_e21_chip::gpio::PORT[1]), // Green
Some(&arty_e21_chip::gpio::PORT[8]),
);

Expand Down Expand Up @@ -155,7 +155,7 @@ pub unsafe fn reset_handler() {
[
(
// Red
&arty_e21_chip::gpio::PORT[0],
&arty_e21_chip::gpio::PORT[2],
kernel::hil::gpio::ActivationMode::ActiveHigh
),
(
Expand All @@ -165,7 +165,7 @@ pub unsafe fn reset_handler() {
),
(
// Blue
&arty_e21_chip::gpio::PORT[2],
&arty_e21_chip::gpio::PORT[0],
kernel::hil::gpio::ActivationMode::ActiveHigh
),
]
Expand Down
6 changes: 3 additions & 3 deletions chips/arty_e21_chip/src/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ impl kernel::Chip for ArtyExx {
match interrupt {
interrupts::MTIP => timer::MACHINETIMER.handle_interrupt(),

interrupts::GPIO0 => gpio::PORT[3].handle_interrupt(),
interrupts::GPIO1 => gpio::PORT[3].handle_interrupt(),
interrupts::GPIO2 => gpio::PORT[3].handle_interrupt(),
interrupts::GPIO0 => gpio::PORT[0].handle_interrupt(),
interrupts::GPIO1 => gpio::PORT[1].handle_interrupt(),
interrupts::GPIO2 => gpio::PORT[2].handle_interrupt(),
interrupts::GPIO3 => gpio::PORT[3].handle_interrupt(),
interrupts::GPIO4 => gpio::PORT[4].handle_interrupt(),
interrupts::GPIO5 => gpio::PORT[5].handle_interrupt(),
Expand Down

0 comments on commit 9c52825

Please sign in to comment.