Skip to content

Commit

Permalink
Add nRF52840 RTIC example project
Browse files Browse the repository at this point in the history
  • Loading branch information
dalegaard committed Feb 8, 2024
1 parent 8e4c8c5 commit 71874a6
Show file tree
Hide file tree
Showing 11 changed files with 477 additions and 10 deletions.
12 changes: 2 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
[workspace]

members = [
"anchor",
"anchor_codegen",
"anchor_macro",
"testjig"
]
members = ["anchor", "anchor_codegen", "anchor_macro", "testjig"]

exclude = [
"rp2040_demo",
"esp32c3_demo",
]
exclude = ["rp2040_demo", "esp32c3_demo", "nrf52840_rtic_demo"]
22 changes: 22 additions & 0 deletions nrf52840_rtic_demo/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "probe-rs run --chip nRF52840_xxAA"
rustflags = [
"-C",
"linker=flip-link",
"-C",
"link-arg=-Tlink.x",
"-C",
"link-arg=-Tdefmt.x",
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
# See https://github.com/rust-embedded/cortex-m-quickstart/pull/95
"-C",
"link-arg=--nmagic",
]

[build]
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)

[alias]
rb = "run --bin"
rrb = "run --release --bin"
bbr = "build --release --bin"
2 changes: 2 additions & 0 deletions nrf52840_rtic_demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
Cargo.lock
75 changes: 75 additions & 0 deletions nrf52840_rtic_demo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[package]
name = "test-app"
edition = "2021"
version = "0.1.0"

[dependencies]
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
defmt = { version = "0.3", features = ["encoding-rzcobs"] }
defmt-brtt = { version = "0.1", default-features = false, features = ["rtt"] }
panic-probe = { version = "0.3", features = ["print-defmt"] }
rtic = { version = "2.0.0", features = ["thumbv7-backend"] }
nrf52840-hal = "0.16"
rtic-monotonics = { version = "1.0.0", features = [
"cortex-m-systick",
"nrf52840",
] }
embassy-usb = { version = "0.1.0", features = ["defmt"] }
embassy-nrf = { version = "0.1.0", features = ["nrf52840"] }
embassy-futures = { version = "0.1.1", features = ["defmt"] }
anchor = { git = "https://github.com/Annex-engineering/anchor.git" }
rtic-sync = { version = "1.2.0", features = ["embedded-hal"] }
embedded-hal-async = "1.0.0"
bbqueue = "0.5.1"
embassy-sync = "0.5.0"
heapless = "0.8.0"
fugit = { version = "0.3.7", features = ["defmt"] }

[build-dependencies]
anchor_codegen = { git = "https://github.com/Annex-engineering/anchor.git" }

# cargo build/run
[profile.dev]
codegen-units = 1
debug = 2
debug-assertions = true # <-
incremental = false
opt-level = "s" # <-
overflow-checks = true # <-

# cargo test
[profile.test]
codegen-units = 1
debug = 2
debug-assertions = true # <-
incremental = false
opt-level = "s" # <-
overflow-checks = true # <-

# cargo build/run --release
[profile.release]
codegen-units = 1
debug = 2
debug-assertions = false # <-
incremental = false
lto = 'fat'
opt-level = "s" # <-
overflow-checks = false # <-

# cargo test --release
[profile.bench]
codegen-units = 1
debug = 2
debug-assertions = false # <-
incremental = false
lto = 'fat'
opt-level = "s" # <-
overflow-checks = false # <-

# uncomment this to switch from the crates.io version of defmt to its git version
# check app-template's README for instructions
# [patch.crates-io]
# defmt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version supported by probe-rs (see changelog)" }
# defmt-rtt = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version supported by probe-rs (see changelog)" }
# defmt-test = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version supported by probe-rs (see changelog)" }
# panic-probe = { git = "https://github.com/knurling-rs/defmt", rev = "use defmt version supported by probe-rs (see changelog)" }
7 changes: 7 additions & 0 deletions nrf52840_rtic_demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Anchor nRF52840 RTIC demo

This project contains a small example of integrating Anchor in an nRF52840 based
project. This example was tested on the nRF52840-DK development kit board, but should
work on other nRF52840 based boards too.

The project uses RTIC and shows one possible way of integrating Anchor in to such a project.
7 changes: 7 additions & 0 deletions nrf52840_rtic_demo/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn main() {
anchor_codegen::ConfigBuilder::new()
.entry("src/bin/minimal.rs")
.set_version("rticjig 0.1")
.set_build_versions("rust: someversion")
.build()
}
23 changes: 23 additions & 0 deletions nrf52840_rtic_demo/memory.x
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* Linker script for the nRF52 - WITHOUT SOFT DEVICE */
MEMORY
{
/* NOTE K = KiBi = 1024 bytes */
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
RAM : ORIGIN = 0x20000000, LENGTH = 256K
}

/* This is where the call stack will be allocated. */
/* The stack is of the full descending type. */
/* You may want to use this variable to locate the call stack and static
variables in different memory regions. Below is shown the default value */
/* _stack_start = ORIGIN(RAM) + LENGTH(RAM); */

/* You can use this symbol to customize the location of the .text section */
/* If omitted the .text section will be placed right after the .vector_table
section */
/* This is required only on microcontrollers that store some configuration right
after the vector table */
/* _stext = ORIGIN(FLASH) + 0x400; */

/* Size of the heap (in bytes) */
/* _heap_size = 1024; */
3 changes: 3 additions & 0 deletions nrf52840_rtic_demo/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly"
components = [ "rust-src", "rustfmt", "llvm-tools-preview" ]
Loading

0 comments on commit 71874a6

Please sign in to comment.