Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 1c63f6e

Browse files
committed
Fixed example to work with new PLIC structure and linker changes.
1 parent 80582c1 commit 1c63f6e

File tree

7 files changed

+16
-23
lines changed

7 files changed

+16
-23
lines changed

.cargo/config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[target.riscv32imac-unknown-none-elf]
2-
runner = "../../Toolchains/sifive/bin/riscv64-unknown-elf-gdb -q -x gdb_init"
2+
runner = "/home/steew/things/dev/bin/riscv-sifive/bin/riscv64-unknown-elf-gdb -q -x gdb_init"
33
rustflags = [
44
"-C", "link-arg=-Thifive1-link.x",
55
]

Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ edition = "2018"
1111

1212
[dependencies]
1313
e310x-hal = {git = "https://github.com/greenlsi/e310x-hal"}
14+
e310x = {git = "https://github.com/greenlsi/e310x", features = ["v-extern"]}
1415
embedded-hal = "0.2.5"
1516
riscv = "0.6.0"
16-
riscv-rt = "0.10.0"
17+
riscv-rt = "0.11.0"
1718
nb = "1.0.0"
1819
panic-halt = "0.2.0"
1920

@@ -23,11 +24,11 @@ board-hifive1-revb = ["e310x-hal/g002"]
2324
board-redv = ["e310x-hal/g002"]
2425
board-lofive = []
2526
board-lofive-r1 = ["e310x-hal/g002"]
26-
virq = ["e310x-hal/virq"]
27+
v-extern = ["e310x/v-extern"]
2728

2829
[[example]]
2930
name = "virq"
30-
required-features = ["virq"]
31+
required-features = ["v-extern"]
3132

3233
[package.metadata.docs.rs]
3334
features = ['board-hifive1-revb']

examples/virq.rs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This can be applied for all the 52 interrupts declared in e310x/interrupts.rs.
1414

1515
extern crate panic_halt;
1616

17-
use hifive1::{hal::core::plic::Priority, hal::prelude::*, hal::DeviceResources, pin, sprintln};
17+
use hifive1::{ hal::prelude::*, hal::DeviceResources, pin, sprintln};
1818

1919
use riscv::register::mstatus;
2020
use riscv_rt::entry;
@@ -65,18 +65,11 @@ fn main() -> ! {
6565
/* Unsafe block */
6666
unsafe {
6767
/* Get raw PLIC pointer */
68-
let rplic = &*hifive1::hal::e310x::PLIC::ptr();
69-
/* Index 7 is the GPIO0 interrupt source start */
70-
let gpio0_block_start = 7;
71-
for (i, p) in rplic.priority.iter().enumerate() {
72-
/* set priority of our interrupt */
73-
if i == gpio0_block_start + (GPIO_N + 1) {
74-
p.write(|w| w.bits(0xffffffff));
75-
} else {
76-
/* Clear all other priorities */
77-
p.write(|w| w.bits(0));
78-
}
79-
}
68+
//let rplic = &*hifive1::hal::e310x::PLIC::ptr();
69+
hifive1::hal::e310x::PLIC::set_priority(
70+
&mut plic,
71+
hifive1::hal::e310x::Interrupt::GPIO4,
72+
e310x_hal::e310x::Priority::P7);
8073
let gpio_block = &*hifive1::hal::e310x::GPIO0::ptr();
8174
/* Enable GPIO fall interrupts */
8275
gpio_block.fall_ie.write(|w| w.bits(1 << GPIO_N));
@@ -87,8 +80,8 @@ fn main() -> ! {
8780

8881
/* Activate global interrupts (mie bit) */
8982
mstatus::set_mie();
90-
plic.threshold.set(Priority::P1);
91-
plic.mext.enable();
83+
plic.set_threshold(e310x_hal::e310x::Priority::P1);
84+
plic.enable_interrupt(hifive1::hal::e310x::Interrupt::GPIO4);
9285
}
9386
loop {}
9487
}

hifive1-link.x

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
INCLUDE hifive1-memory.x
22
INCLUDE link.x
3-
INCLUDE fe310x-interrupt.x

memory-hifive1-revb.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INCLUDE memory-fe310.x
1+
INCLUDE device.x
22
MEMORY
33
{
44
FLASH : ORIGIN = 0x20000000, LENGTH = 4M

memory-hifive1.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INCLUDE memory-fe310.x
1+
INCLUDE device.x
22
MEMORY
33
{
44
FLASH : ORIGIN = 0x20000000, LENGTH = 16M

memory-lofive-r1.x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
INCLUDE memory-fe310.x
1+
INCLUDE device.x
22
MEMORY
33
{
44
FLASH : ORIGIN = 0x20000000, LENGTH = 16M

0 commit comments

Comments
 (0)