Skip to content

Commit

Permalink
fix example Rust crate
Browse files Browse the repository at this point in the history
  • Loading branch information
onsdagens committed Jun 4, 2024
1 parent 6d4142d commit 8ab6260
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 242 deletions.
14 changes: 6 additions & 8 deletions riscv/riscv_basic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
#riscv-rt = "0.12.2"
hippomenes-core = {path="../../../hippomenes-core/"}
hippomenes-rt = {path="../../../hippomenes-core/hippomenes-rt/"}
rtic = {path="../../../rtic/rtic", features=["riscv-clic-backend"]}
hippomenes-hal = {path="../../../hippomenes-core/hippomenes-hal/"}
#rtic = {git="https://github.com/onsdagens/rtic", branch="hippomenes", features=["riscv-clic-backend"]}
#hippomenes-core = {git="https://github.com/onsdagens/hippomenes-core/"}
#hippomenes-rt = {git="https://github.com/onsdagens/hippomenes-core/"}

hippomenes-core = {git="https://github.com/onsdagens/hippomenes-core"}
hippomenes-rt = {git="https://github.com/onsdagens/hippomenes-core"}
rtic = {git="https://github.com/onsdagens/rtic", branch="hippomenes", features=["riscv-clic-backend"]}


[workspace]
16 changes: 0 additions & 16 deletions riscv/riscv_basic/examples/rtic.rs

This file was deleted.

49 changes: 0 additions & 49 deletions riscv/riscv_basic/src/bare.rs

This file was deleted.

44 changes: 31 additions & 13 deletions riscv/riscv_basic/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,56 @@
#![no_std]
#![no_main]
#![no_std]
use core::panic::PanicInfo;
use hippomenes_rt as _;

#[rtic::app(device = hippomenes_core)]
mod app {
use hippomenes_core::{I0Timestamp, Pin, Pin0};
use hippomenes_hal::UART;
use hippomenes_core::{interrupt1, interrupt2};
#[shared]
struct Shared {
dummy: bool,
r: u8,
l: u8,
}

#[local]
struct Local {}

#[init]
fn init(cx: init::Context) -> (Shared, Local) {
let peripherals = cx.device;
let pin0 = peripherals.gpio.pins().pin0;
let timer = peripherals.timer;
let mut uart = UART::new(pin0, timer, 10_000);
let buffer = [48, 49, 50, 51, 52, 53, 54, 55];
uart.send(buffer);
(Shared { dummy: true }, Local {})
rtic::export::pend(interrupt1::Interrupt1);
rtic::export::pend(interrupt2::Interrupt2);
let r = 9;
let l = 10;
(Shared { r, l }, Local {})
}

#[idle]
fn idle(_: idle::Context) -> ! {
loop {}
}

#[task(binds = Interrupt1, priority = 1, shared = [r,l])]
fn i1(mut cx: i1::Context) {
cx.shared.r.lock(|r| {
cx.shared.l.lock(|l| {
*l = *l + *r;
});
});
}
#[task(binds = Interrupt2, priority = 2, shared=[l])]
fn i2(mut cx: i2::Context) {
cx.shared.l.lock(|l| {
*l += 2;
});
}
#[task(binds = Interrupt3, priority = 3, shared = [r])]
fn i3(mut cx: i3::Context) {
cx.shared.r.lock(|r| {
*r += 1;
});
}
}

#[panic_handler]
fn p(_: &PanicInfo) -> ! {
fn panic(_: &PanicInfo) -> ! {
loop {}
}
34 changes: 0 additions & 34 deletions riscv/riscv_basic/src/main.rs.old

This file was deleted.

56 changes: 0 additions & 56 deletions riscv/riscv_basic/src/main.rs.old2

This file was deleted.

66 changes: 0 additions & 66 deletions riscv/riscv_basic/src/rtic.rs

This file was deleted.

0 comments on commit 8ab6260

Please sign in to comment.