diff --git a/hifive1-examples/Cargo.toml b/hifive1-examples/Cargo.toml index 4b18829..97bb37f 100644 --- a/hifive1-examples/Cargo.toml +++ b/hifive1-examples/Cargo.toml @@ -13,24 +13,12 @@ rust-version = "1.72" [workspace] [dependencies] -critical-section = { version = "1.1.3" } -hifive1 = { path = "../hifive1", version = "0.13.0", features = ["board-hifive1-revb"] } # Change to your board -riscv = { version = "0.11.0" } -riscv-rt = { version = "0.12.2", features = ["single-hart"] } +critical-section = { version = "1.2.0" } +hifive1 = { path = "../hifive1", version = "0.14.0", features = ["board-hifive1-revb"] } # Change to your board +riscv = { version = "0.12.1" } +riscv-rt = { version = "0.13.0", features = ["single-hart"] } panic-halt = "0.2.0" -semihosting = { version = "0.1", features = ["stdio", "panic-handler"], optional = true } +semihosting = { version = "0.1", features = ["stdio", "panic-handler"] } [features] -virq = ["hifive1/virq"] - -[[example]] -name = "sh_hello_world" -required-features = ["semihosting"] - -[[example]] -name = "sh_led_blink" -required-features = ["semihosting"] - -[[example]] -name = "sh_rgb_blink" -required-features = ["semihosting"] +v-trap = ["hifive1/v-trap"] diff --git a/hifive1-examples/examples/button_poll.rs b/hifive1-examples/examples/button_poll.rs index 14d7ac8..80698e5 100644 --- a/hifive1-examples/examples/button_poll.rs +++ b/hifive1-examples/examples/button_poll.rs @@ -10,7 +10,7 @@ use hifive1::{ clock, - hal::{delay::Sleep, prelude::*, DeviceResources}, + hal::{e310x::CLINT, prelude::*, DeviceResources}, pin, sprintln, Led, }; extern crate panic_halt; @@ -41,8 +41,7 @@ fn main() -> ! { let mut led = pin.into_inverted_output(); // Get the sleep struct from CLINT - let clint = dr.core_peripherals.clint; - let mut sleep = Sleep::new(clint.mtimecmp, clocks); + let mut sleep = CLINT::delay(); const STEP: u32 = 1000; // 1s loop { diff --git a/hifive1-examples/examples/led_blink.rs b/hifive1-examples/examples/led_blink.rs index 995483f..bfe607e 100644 --- a/hifive1-examples/examples/led_blink.rs +++ b/hifive1-examples/examples/led_blink.rs @@ -6,7 +6,7 @@ use hifive1::{ clock, - hal::{delay::Sleep, prelude::*, DeviceResources}, + hal::{e310x::CLINT, prelude::*, DeviceResources}, pin, sprintln, Led, }; extern crate panic_halt; @@ -34,8 +34,7 @@ fn main() -> ! { let mut led = pin.into_inverted_output(); // Get the sleep struct from CLINT - let clint = dr.core_peripherals.clint; - let mut sleep = Sleep::new(clint.mtimecmp, clocks); + let mut sleep = CLINT::delay(); const STEP: u32 = 1000; // 1s loop { diff --git a/hifive1-examples/examples/led_pwm.rs b/hifive1-examples/examples/led_pwm.rs index 4d09ed6..3392e75 100644 --- a/hifive1-examples/examples/led_pwm.rs +++ b/hifive1-examples/examples/led_pwm.rs @@ -9,7 +9,7 @@ use hifive1::{ clock, - hal::{delay::Sleep, prelude::*, DeviceResources}, + hal::{e310x::CLINT, prelude::*, DeviceResources}, pin, sprintln, }; extern crate panic_halt; @@ -41,8 +41,7 @@ fn main() -> ! { let mut channel = pwm0.channel(pin); // Get the sleep struct from CLINT - let clint = dr.core_peripherals.clint; - let mut sleep = Sleep::new(clint.mtimecmp, clocks); + let mut sleep = CLINT::delay(); const STEP: u32 = 1000; // 1s const DUTY_DELTA: u8 = 32; diff --git a/hifive1-examples/examples/rgb_blink.rs b/hifive1-examples/examples/rgb_blink.rs index dcc938d..dcea2e7 100644 --- a/hifive1-examples/examples/rgb_blink.rs +++ b/hifive1-examples/examples/rgb_blink.rs @@ -6,7 +6,7 @@ use hifive1::{ clock, - hal::{delay::Sleep, prelude::*, DeviceResources}, + hal::{e310x::CLINT, prelude::*, DeviceResources}, pin, pins, sprintln, Led, }; extern crate panic_halt; @@ -36,8 +36,7 @@ fn main() -> ! { let mut ileds: [&mut dyn Led; 3] = [&mut tleds.0, &mut tleds.1, &mut tleds.2]; // Get the sleep struct from CLINT - let clint = dr.core_peripherals.clint; - let mut sleep = Sleep::new(clint.mtimecmp, clocks); + let mut sleep = CLINT::delay(); const STEP: u32 = 1000; // 1s loop { diff --git a/hifive1-examples/examples/sh_hello_world.rs b/hifive1-examples/examples/sh_hello_world.rs index 50e3a08..3721524 100644 --- a/hifive1-examples/examples/sh_hello_world.rs +++ b/hifive1-examples/examples/sh_hello_world.rs @@ -3,6 +3,7 @@ #![no_std] #![no_main] +extern crate hifive1; use semihosting::{println, process::exit}; #[riscv_rt::entry] diff --git a/hifive1-examples/examples/sh_led_blink.rs b/hifive1-examples/examples/sh_led_blink.rs index 5f40957..e0ee160 100644 --- a/hifive1-examples/examples/sh_led_blink.rs +++ b/hifive1-examples/examples/sh_led_blink.rs @@ -6,7 +6,7 @@ use hifive1::{ clock, - hal::{delay::Sleep, prelude::*, DeviceResources}, + hal::{e310x::CLINT, prelude::*, DeviceResources}, pin, Led, }; use semihosting::{println, process::exit}; @@ -25,8 +25,7 @@ fn main() -> ! { let mut led = pin.into_inverted_output(); // Get the sleep struct from CLINT - let clint = dr.core_peripherals.clint; - let mut sleep = Sleep::new(clint.mtimecmp, clocks); + let mut sleep = CLINT::delay(); const N_TOGGLE: usize = 4; const STEP: u32 = 500; // 500 ms diff --git a/hifive1-examples/examples/sh_rgb_blink.rs b/hifive1-examples/examples/sh_rgb_blink.rs index 8532840..78cc761 100644 --- a/hifive1-examples/examples/sh_rgb_blink.rs +++ b/hifive1-examples/examples/sh_rgb_blink.rs @@ -6,7 +6,7 @@ use hifive1::{ clock, - hal::{delay::Sleep, prelude::*, DeviceResources}, + hal::{e310x::CLINT, prelude::*, DeviceResources}, pins, Led, }; use semihosting::{println, process::exit}; @@ -27,8 +27,7 @@ fn main() -> ! { let mut ileds: [&mut dyn Led; 3] = [&mut tleds.0, &mut tleds.1, &mut tleds.2]; // Get the sleep struct from CLINT - let clint = dr.core_peripherals.clint; - let mut sleep = Sleep::new(clint.mtimecmp, clocks); + let mut sleep = CLINT::delay(); const N_TOGGLES: usize = 4; const STEP: u32 = 500; // 500ms diff --git a/hifive1-examples/src/main.rs b/hifive1-examples/src/main.rs index 176b305..a39f54a 100644 --- a/hifive1-examples/src/main.rs +++ b/hifive1-examples/src/main.rs @@ -14,10 +14,7 @@ use hifive1::{ pin, sprintln, }; -#[cfg(not(feature = "semihosting"))] extern crate panic_halt; -#[cfg(feature = "semihosting")] -extern crate semihosting; #[riscv_rt::entry] fn main() -> ! { @@ -39,5 +36,7 @@ fn main() -> ! { sprintln!("Hello, world!"); - loop {} + loop { + riscv::asm::wfi(); + } }