Skip to content

Commit 09948e7

Browse files
authored
Merge pull request #37 from riscv-rust/ehv1
Update `embedded-hal` dependencies
2 parents 4f705c8 + 9ff56af commit 09948e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2088
-3391
lines changed

.cargo/config.toml

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
[target.'cfg(all(target_arch = "riscv32", target_os = "none"))']
2+
runner = "qemu-system-riscv32 -machine sifive_e,revb=true -nographic -semihosting-config enable=on,target=native -kernel" # Uncomment for QEMU
3+
# runner = "riscv64-unknown-elf-gdb -q -x hifive1-examples/gdb_init" # Uncomment for hardware (no semihosting)
4+
# runner = "riscv64-unknown-elf-gdb -q -x hifive1-examples/gdb_init_sh" # Uncomment for hardware (semihosting)
25
rustflags = [
6+
# "-C", "link-arg=-Thifive1-link.x",
37
"--cfg", "portable_atomic_target_feature=\"zaamo\"",
48
]
59

.github/workflows/clippy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Run clippy (direct mode)
3232
run: cargo clippy --features board-${{ matrix.board }} -- $CLIPPY_PARAMS
3333
- name: Run clippy (vectored mode)
34-
run: cargo clippy --features virq,board-${{ matrix.board }} -- $CLIPPY_PARAMS
34+
run: cargo clippy --features v-trap,board-${{ matrix.board }} -- $CLIPPY_PARAMS
3535

3636
# Job to check that all the lint checks succeeded
3737
clippy-check:

.github/workflows/e310x-hal.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
build-riscv:
1212
strategy:
1313
matrix:
14-
# All generated code should be running on stable now, MRSV is 1.72.0
15-
toolchain: [ stable, nightly, 1.72.0 ]
14+
# All generated code should be running on stable now, MRSV is 1.76.0
15+
toolchain: [ stable, nightly, 1.76.0 ]
1616
include:
1717
# Nightly is only for reference and allowed to fail
1818
- toolchain: nightly

.github/workflows/e310x.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
build-riscv:
1212
strategy:
1313
matrix:
14-
# All generated code should be running on stable now, MRSV is 1.72.0
15-
toolchain: [ stable, nightly, 1.72.0 ]
14+
# All generated code should be running on stable now, MRSV is 1.76.0
15+
toolchain: [ stable, nightly, 1.76.0 ]
1616
include:
1717
# Nightly is only for reference and allowed to fail
1818
- toolchain: nightly

.github/workflows/hifive1.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
build-riscv:
1212
strategy:
1313
matrix:
14-
# All generated code should be running on stable now, MRSV is 1.72.0
15-
toolchain: [nightly, stable, 1.72.0]
14+
# All generated code should be running on stable now, MRSV is 1.76.0
15+
toolchain: [nightly, stable, 1.76.0]
1616
board: [hifive1, hifive1-revb, redv, lofive, lofive-r1]
1717
include:
1818
# Nightly is only for reference and allowed to fail
@@ -29,7 +29,7 @@ jobs:
2929
- name: Build (direct)
3030
run: cargo build --package hifive1 --features board-${{ matrix.board }}
3131
- name: Build (vectored)
32-
run: cargo build --package hifive1 --features board-${{ matrix.board }},virq
32+
run: cargo build --package hifive1 --features board-${{ matrix.board }},v-trap
3333

3434
# On MacOS and Ubuntu, we at least make sure that the crate builds and links.
3535
# On Windows, linking fails when the rt feature is enabled.
@@ -48,5 +48,5 @@ jobs:
4848
- name: Build (direct)
4949
run: cargo test --package hifive1 --features board-${{ matrix.board }}
5050
- name: Build (vectored)
51-
run: cargo test --package hifive1 --features board-${{ matrix.board }},virq
51+
run: cargo test --package hifive1 --features board-${{ matrix.board }},v-trap
5252

e310x-hal/CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased]
99

1010
### Changed
11+
- Fix `StatefulOutputPin::is_set_high`. It now reads from `output_val`
12+
- UART traits are implemented now from `embedded-hal-nb` 1.0.0
13+
- Update `embedded-hal` to 1.0.0
14+
- Update `riscv` to 0.12.1
15+
- Remove `virq` feature. Now interrupts are handled by `e310x`
1116
- Apply clippy changes
1217
- Use `portable-atomic` with `zaamo` feature to use native `amo*` operations.
1318
- Official target is now `riscv32imc-unknown-none-elf`, as it does not fully support the A extension.
1419
- Update `e310x` dependency and adapt code
15-
- Bump MSRV to 1.72.0 to ensure a correct behavior of portable-atomic
20+
- Bump MSRV to 1.76.0
1621

1722
## [v0.10.0] - 2023-03-28
1823

e310x-hal/Cargo.toml

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
[package]
22
name = "e310x-hal"
3-
version = "0.11.0"
3+
version = "0.12.0"
44
authors = ["David Craven <[email protected]>"]
55
repository = "https://github.com/riscv-rust/e310x"
66
categories = ["embedded", "hardware-support", "no-std"]
77
description = "HAL for the E310x family of microcontrollers."
88
keywords = ["riscv", "e310", "hal"]
99
license = "ISC"
1010
edition = "2021"
11-
rust-version = "1.72"
11+
rust-version = "1.76"
1212

1313
[dependencies]
14-
embedded-hal = { version = "0.2.6", features = ["unproven"] }
14+
embedded-hal = "1.0.0"
15+
embedded-hal-nb = "1.0.0"
16+
embedded-io = "0.6.1"
17+
e310x = { path = "../e310x", version = "0.12.0", features = ["rt", "critical-section"] }
1518
nb = "1.0.0"
16-
riscv = { version = "0.10.1", features = ["critical-section-single-hart"] }
17-
e310x = { path = "../e310x", version = "0.11.0", features = ["rt", "critical-section"] }
1819
portable-atomic = { version = "1.9", default-features = false}
20+
riscv = { version = "0.12.1", features = ["critical-section-single-hart"] }
1921

2022
[features]
2123
g002 = ["e310x/g002"]
22-
virq = []
24+
v-trap = ["e310x/v-trap"]
2325

2426
[package.metadata.docs.rs]
25-
features = ["g002", "virq"]
27+
features = ["g002"]

e310x-hal/src/clock.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Clock configuration
2-
use crate::core::clint::MTIME;
32
use crate::time::Hertz;
4-
use e310x::{Aonclk as AONCLK, Prci as PRCI};
3+
use e310x::{Aonclk as AONCLK, Prci as PRCI, CLINT};
54
use riscv::interrupt;
65
use riscv::register::mcycle;
76

@@ -229,7 +228,7 @@ impl CoreClk {
229228
};
230229

231230
// Calculate the desired vco frequency
232-
let target_vco_freq = pllout_freq * q;
231+
let target_vco_freq: u32 = pllout_freq * q;
233232
assert!((VCO_MIN..=VCO_MAX).contains(&target_vco_freq));
234233

235234
// Calculate PLL F ratio
@@ -291,9 +290,9 @@ impl CoreClk {
291290
// Need to wait 100 us
292291
// RTC is running at 32kHz.
293292
// So wait 4 ticks of RTC.
294-
let mtime = MTIME;
295-
let time = mtime.mtime() + 4;
296-
while mtime.mtime() < time {}
293+
let mtime = CLINT::mtimer().mtime;
294+
let time = mtime.read() + 4;
295+
while mtime.read() < time {}
297296
// Now it is safe to check for PLL Lock
298297
while !prci.pllcfg().read().lock().bit_is_set() {}
299298

@@ -385,19 +384,19 @@ impl Clocks {
385384

386385
/// Measure the coreclk frequency by counting the number of aonclk ticks.
387386
fn _measure_coreclk(&self, min_ticks: u64) -> Hertz {
388-
let mtime = MTIME;
387+
let mtime = CLINT::mtimer().mtime;
389388
interrupt::free(|| {
390389
// Don't start measuring until we see an mtime tick
391-
while mtime.mtime() == mtime.mtime() {}
390+
while mtime.read() == mtime.read() {}
392391

393392
let start_cycle = mcycle::read64();
394-
let start_time = mtime.mtime();
393+
let start_time = mtime.read();
395394

396395
// Wait for min_ticks to pass
397-
while start_time + min_ticks > mtime.mtime() {}
396+
while start_time + min_ticks > mtime.read() {}
398397

399398
let end_cycle = mcycle::read64();
400-
let end_time = mtime.mtime();
399+
let end_time = mtime.read();
401400

402401
let delta_cycle: u64 = end_cycle - start_cycle;
403402
let delta_time: u64 = end_time - start_time;

e310x-hal/src/core/clint.rs

-117
This file was deleted.

e310x-hal/src/core/mod.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
//! E31 core peripherals
22
3-
pub mod clint;
43
pub mod counters;
5-
pub mod plic;
4+
5+
pub use e310x::{CLINT, PLIC};
66

77
/// Core peripherals
88
pub struct CorePeripherals {
9-
/// Core-Local Interruptor
10-
pub clint: clint::Clint,
11-
12-
/// Platform-Level Interrupt Controller
13-
pub plic: plic::Plic,
14-
159
/// Performance counters
1610
pub counters: counters::PerformanceCounters,
1711
}
1812

1913
impl CorePeripherals {
20-
pub(crate) fn new(clint: e310x::Clint, plic: e310x::Plic) -> Self {
14+
pub(crate) fn new() -> Self {
2115
Self {
22-
clint: clint.into(),
23-
plic: plic.into(),
2416
counters: counters::PerformanceCounters::new(),
2517
}
2618
}
@@ -31,7 +23,6 @@ impl CorePeripherals {
3123
///
3224
/// Using this function may break the guarantees of the singleton pattern.
3325
pub unsafe fn steal() -> Self {
34-
let p = e310x::Peripherals::steal();
35-
Self::new(p.clint, p.plic)
26+
Self::new()
3627
}
3728
}

0 commit comments

Comments
 (0)