Skip to content

Commit 130c31c

Browse files
Jonathan Pallant (42 Technology)Yatekii
authored andcommitted
Add structure for nRF9160. hal-common changes TBC.
1 parent 6592f36 commit 130c31c

File tree

11 files changed

+171
-3
lines changed

11 files changed

+171
-3
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ members = [
44
"boards/adafruit-nrf52-bluefruit-le",
55
"boards/nRF52-DK",
66
"boards/nRF52840-DK",
7+
"boards/nRF9160-DK",
78
"nrf52810-hal",
89
"nrf52832-hal",
910
"nrf52840-hal",
11+
"nrf9160-hal",
1012
"examples/rtfm-demo",
1113
"examples/spi-demo",
1214
"examples/twi-ssd1306",

boards/nRF9160-DK/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "nRF9160-DK"
3+
version = "0.1.0"
4+
authors = ["Jonathan Pallant (42 Technology) <[email protected]>"]
5+
edition = "2018"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]

boards/nRF9160-DK/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[cfg(test)]
2+
mod tests {
3+
#[test]
4+
fn it_works() {
5+
assert_eq!(2 + 2, 4);
6+
}
7+
}

examples/twi-ssd1306/Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[package]
22
name = "twi-ssd1306"
33
version = "0.1.0"
4-
authors = ["James Waples <[email protected]>", "Ruben Paz <[email protected]>"]
4+
authors = [
5+
"James Waples <[email protected]>",
6+
"Ruben Paz <[email protected]>",
7+
"Jonathan Pallant <[email protected]>"
8+
]
59
edition = "2018"
610

711
[dependencies]
@@ -24,7 +28,13 @@ version = "0.8.0"
2428
path = "../../nrf52840-hal"
2529
optional = true
2630

31+
[dependencies.nrf9160-hal]
32+
version = "0.1.0"
33+
path = "../../nrf9160-hal"
34+
optional = true
35+
2736
[features]
2837
52832 = ["nrf52832-hal"]
2938
52840 = ["nrf52840-hal"]
39+
9160 = ["nrf9160-hal"]
3040
default = ["52832"]

nrf52-hal-common/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ version = "0.8.0"
4242
optional = true
4343
version = "0.8.0"
4444

45+
[dependencies.nrf9160-pac]
46+
optional = true
47+
version = "0.1.1"
48+
package = "nrf91"
49+
4550
[dependencies.embedded-hal]
4651
features = ["unproven"]
4752
version = "0.2.1"
@@ -52,3 +57,4 @@ default = ["52832"]
5257
52810 = ["nrf52810-pac"]
5358
52832 = ["nrf52832-pac"]
5459
52840 = ["nrf52840-pac"]
60+
9160 = ["nrf9160-pac"]

nrf52-hal-common/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ pub use nrf52832_pac as target;
1111
#[cfg(feature = "52840")]
1212
pub use nrf52840_pac as target;
1313

14+
#[cfg(feature = "9160")]
15+
pub use nrf9160_pac as target;
16+
1417
pub mod clocks;
1518
pub mod delay;
1619
pub mod gpio;
@@ -40,9 +43,9 @@ pub mod target_constants {
4043
pub const SRAM_UPPER: usize = 0x3000_0000;
4144
pub const FORCE_COPY_BUFFER_SIZE: usize = 255;
4245
}
43-
#[cfg(feature = "52840")]
46+
#[cfg(any(feature = "52840", feature="9160"))]
4447
pub mod target_constants {
45-
// NRF52840 16 bits 1..0xFFFF
48+
// NRF52840 and NRF9160 16 bits 1..0xFFFF
4649
pub const EASY_DMA_SIZE: usize = 65535;
4750
// Limits for Easy DMA - it can only read from data ram
4851
pub const SRAM_LOWER: usize = 0x2000_0000;

nrf9160-hal/Cargo.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[package]
2+
name = "nrf9160-hal"
3+
version = "0.1.0"
4+
description = "HAL for nRF9160 system-in-package"
5+
6+
repository = "https://github.com/nrf-rs/nrf52-hal"
7+
authors = [
8+
"Jonathan Pallant (42 Technology) <[email protected]>",
9+
"James Munns <[email protected]>",
10+
"Hanno Braun <[email protected]>",
11+
"John Scarrott <[email protected]>",
12+
"Wez Furlong <[email protected]>",
13+
]
14+
15+
categories = ["embedded", "hardware-support", "no-std"]
16+
keywords = ["arm", "cortex-m", "nrf91", "hal", "nrf9160"]
17+
license = "MIT OR Apache-2.0"
18+
edition = "2018"
19+
20+
[dependencies]
21+
cortex-m = "0.6"
22+
nb = "0.1.1"
23+
nrf9160-pac = { package = "nrf91", version="0.1.1" }
24+
25+
[dependencies.void]
26+
default-features = false
27+
version = "1.0.2"
28+
29+
[dependencies.cast]
30+
default-features = false
31+
version = "0.2.2"
32+
33+
[dependencies.nrf52-hal-common]
34+
path = "../nrf52-hal-common"
35+
default-features = false
36+
features = ["9160"]
37+
version = "0.8.0"
38+
39+
[dependencies.embedded-hal]
40+
features = ["unproven"]
41+
version = "0.2.1"
42+
43+
[features]
44+
doc = []
45+
rt = ["nrf9160-pac/rt"]
46+
default = ["rt"]

nrf9160-hal/build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use std::env;
2+
use std::fs::File;
3+
use std::io::Write;
4+
use std::path::PathBuf;
5+
6+
fn main() {
7+
// Put the linker script somewhere the linker can find it
8+
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
9+
File::create(out.join("memory.x"))
10+
.unwrap()
11+
.write_all(include_bytes!("memory.x"))
12+
.unwrap();
13+
println!("cargo:rustc-link-search={}", out.display());
14+
15+
println!("cargo:rerun-if-changed=build.rs");
16+
println!("cargo:rerun-if-changed=memory.x");
17+
}

nrf9160-hal/memory.x

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* Linker script for the nRF9160 in Non-secure mode */
2+
MEMORY
3+
{
4+
/* SECURE_FLASH : ORIGIN = 0x00000000, LENGTH = 256K */
5+
/* NONSECURE_FLASH : ORIGIN = 0x00040000, LENGTH = 768K */
6+
/* SECURE_RAM : ORIGIN = 0x20000000, LENGTH = 64K */
7+
/* LIBBSD_RAM : ORIGIN = 0x20010000, LENGTH = 64K */
8+
/* NONSECURE_RAM : ORIGIN = 0x20020000, LENGTH = 128K */
9+
10+
FLASH : ORIGIN = 0x00040000, LENGTH = 768K
11+
RAM : ORIGIN = 0x20020000, LENGTH = 128K
12+
}
13+
14+
/* This is where the call stack will be allocated. */
15+
/* The stack is of the full descending type. */
16+
/* You may want to use this variable to locate the call stack and static
17+
variables in different memory regions. Below is shown the default value */
18+
/* _stack_start = ORIGIN(RAM) + LENGTH(RAM); */
19+
20+
/* You can use this symbol to customize the location of the .text section */
21+
/* If omitted the .text section will be placed right after the .vector_table
22+
section */
23+
/* This is required only on microcontrollers that store some configuration right
24+
after the vector table */
25+
/* _stext = ORIGIN(FLASH) + 0x400; */
26+
27+
/* Size of the heap (in bytes) */
28+
/* _heap_size = 1024; */

nrf9160-hal/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![no_std]
2+
3+
use embedded_hal as hal;
4+
pub use nrf9160_pac;
5+
pub use nrf52_hal_common::*;
6+
7+
pub mod prelude {
8+
pub use crate::hal::prelude::*;
9+
pub use nrf52_hal_common::prelude::*;
10+
11+
pub use crate::time::U32Ext;
12+
}
13+
14+
pub use crate::clocks::Clocks;
15+
pub use crate::delay::Delay;
16+
pub use crate::saadc::Saadc;
17+
pub use crate::spim::Spim;
18+
pub use crate::timer::Timer;
19+
pub use crate::uarte::Uarte;
20+
pub use crate::temp::Temp;

0 commit comments

Comments
 (0)