Skip to content

Commit 5a4432e

Browse files
authored
Merge pull request #22 from almindor/redv
add SparkFun RED-V board support
2 parents 997743b + 7a66069 commit 5a4432e

File tree

10 files changed

+314
-81
lines changed

10 files changed

+314
-81
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ nb = "0.1.2"
1818
[features]
1919
board-hifive1 = []
2020
board-hifive1-revb = ["e310x-hal/g002"]
21+
board-redv = ["e310x-hal/g002"]
2122
board-lofive = []
2223
board-lofive-r1 = ["e310x-hal/g002"]
2324

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
> Board support crate for HiFive1 and LoFive boards
88
9+
## Supported Boards
10+
11+
`hifive1` - use feature `board-hifive1`
12+
`hifive1-revb` - use feature `board-hifive1-revb`
13+
`redv` - use feature `board-redv`
14+
`lofive` - use feature `board-lofive`
15+
`lofive-r1` - use feature `board-lofive-r1`
16+
917
## [Documentation](https://docs.rs/crate/hifive1)
1018

1119
## License

build.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
use std::{env, fs};
21
use std::path::PathBuf;
2+
use std::{env, fs};
33

44
fn main() {
55
// Put the memory definitions somewhere the linker can find it
66
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
77
println!("cargo:rustc-link-search={}", out_dir.display());
88

9-
let boards: Vec<_> = env::vars().filter_map(|(key, _value)| {
10-
if key.starts_with("CARGO_FEATURE_BOARD") {
11-
Some(key[20..].to_ascii_lowercase()) // Strip 'CARGO_FEATURE_BOARD_'
12-
} else {
13-
None
14-
}
15-
}).collect();
9+
let boards: Vec<_> = env::vars()
10+
.filter_map(|(key, _value)| {
11+
if key.starts_with("CARGO_FEATURE_BOARD") {
12+
Some(key[20..].to_ascii_lowercase()) // Strip 'CARGO_FEATURE_BOARD_'
13+
} else {
14+
None
15+
}
16+
})
17+
.collect();
1618

1719
if boards.is_empty() {
1820
panic!("No board features selected");
@@ -28,7 +30,7 @@ fn main() {
2830
fs::copy("memory-hifive1.x", out_dir.join("hifive1-memory.x")).unwrap();
2931
println!("cargo:rerun-if-changed=memory-hifive1.x");
3032
}
31-
"hifive1_revb" => {
33+
"hifive1_revb" | "redv" => {
3234
fs::copy("memory-hifive1-revb.x", out_dir.join("hifive1-memory.x")).unwrap();
3335
println!("cargo:rerun-if-changed=memory-hifive1-revb.x");
3436
}

ci/script.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ set -euxo pipefail
44

55
cargo check --target $TARGET --features 'board-hifive1'
66
cargo check --target $TARGET --features 'board-hifive1-revb'
7+
cargo check --target $TARGET --features 'board-redv'
78
cargo check --target $TARGET --features 'board-lofive'
89
cargo check --target $TARGET --features 'board-lofive-r1'

src/clock.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
//! Board-specific clock configuration
22
33
use e310x_hal::{
4-
e310x::{PRCI, AONCLK},
5-
clock::{Clocks, PrciExt, AonExt},
4+
clock::{AonExt, Clocks, PrciExt},
5+
e310x::{AONCLK, PRCI},
66
time::Hertz,
77
};
88

9-
#[cfg(any(feature = "board-hifive1", feature = "board-hifive1-revb"))]
9+
#[cfg(any(
10+
feature = "board-hifive1",
11+
feature = "board-hifive1-revb",
12+
feature = "board-redv"
13+
))]
1014
/// Configures clock generation system.
1115
///
1216
/// For HiFive1 and HiFive1 Rev B boards external oscillators are enabled for
1317
/// both high-frequency and low-frequency clocks.
1418
pub fn configure(prci: PRCI, aonclk: AONCLK, target_coreclk: Hertz) -> Clocks {
1519
let coreclk = prci.constrain();
16-
let coreclk = coreclk.use_external(Hertz(16_000_000)).coreclk(target_coreclk);
20+
let coreclk = coreclk
21+
.use_external(Hertz(16_000_000))
22+
.coreclk(target_coreclk);
1723

1824
let aonclk = aonclk.constrain();
1925
let aonclk = aonclk.use_external(Hertz(32_768));
@@ -28,7 +34,9 @@ pub fn configure(prci: PRCI, aonclk: AONCLK, target_coreclk: Hertz) -> Clocks {
2834
/// high-frequency clock. For low-frequency clock internal oscillator is used.
2935
pub fn configure(prci: PRCI, aonclk: AONCLK, target_coreclk: Hertz) -> Clocks {
3036
let coreclk = prci.constrain();
31-
let coreclk = coreclk.use_external(Hertz(16_000_000)).coreclk(target_coreclk);
37+
let coreclk = coreclk
38+
.use_external(Hertz(16_000_000))
39+
.coreclk(target_coreclk);
3240

3341
let aonclk = aonclk.constrain();
3442

src/flash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! On-board SPI Flash
22
3-
use e310x_hal::e310x::QSPI0;
43
use e310x_hal::clock::Clocks;
4+
use e310x_hal::e310x::QSPI0;
55

66
/// Configure SPI Flash interface to maximum supported speed
77
#[inline(always)]

0 commit comments

Comments
 (0)