Skip to content

Commit

Permalink
Merge pull request #144 from ferrous-systems/switch-to-rtic-v2
Browse files Browse the repository at this point in the history
Switch to RTIC v2
  • Loading branch information
listochkin authored Dec 5, 2024
2 parents 8a2eb83 + 6dd7ac0 commit 52142b4
Show file tree
Hide file tree
Showing 34 changed files with 406 additions and 463 deletions.
2 changes: 1 addition & 1 deletion exercise-book/src/nrf52-radio-interrupt-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Another way to deal with interrupts is to use a framework like Real-Time Interru

[concurrency]: https://rust-embedded.github.io/book/concurrency/index.html
[RTIC]: https://crates.io/crates/cortex-m-rtic
[book]: https://rtic.rs/1/book/en/
[book]: https://rtic.rs/2/book/en/
2 changes: 1 addition & 1 deletion exercise-book/src/nrf52-radio-parts-embedded-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ The `#![no_main]` language attribute indicates that the program will use a custo

### `#[entry]`

The `#[entry]` macro attribute marks the custom entry point of the program. The entry point must be a divergent function whose return type is the never type `!`. The function is not allowed to return; therefore the program is not allowed to terminate. The macro comes from the [cortex-m-rt crate](https://docs.rs/cortex-m-rt/0.7.3/cortex_m_rt/attr.entry.html) and is not part of the Rust language.
The `#[entry]` macro attribute marks the custom entry point of the program. The entry point must be a divergent function whose return type is the never type `!`. The function is not allowed to return; therefore the program is not allowed to terminate. The macro comes from the [cortex-m-rt crate](https://docs.rs/cortex-m-rt/0.7.5/cortex_m_rt/attr.entry.html) and is not part of the Rust language.
4 changes: 2 additions & 2 deletions exercise-book/src/nrf52-references-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
- If you are looking to write an interrupt handler, look at the [`#[interrupt]` attribute][interrupt]. All interrupts implemented by the nrf52840 hal are listed in [`nrf52840-pac/src/lib.rs`][pac]. It is also recommended that you work through the USB workshop to learn about [RTIC][rtic].

[pac]: https://github.com/nrf-rs/nrf52840-pac/blob/9558a3ed032b2aec7e57c2f42330f1dee0000a04/src/lib.rs#L167
[interrupt]: https://docs.rs/cortex-m-rt/0.7.3/cortex_m_rt/attr.interrupt.html
[rtic]: https://docs.rs/cortex-m-rtic/1.1.4/rtic/
[interrupt]: https://docs.rs/cortex-m-rt/0.7.5/cortex_m_rt/attr.interrupt.html
[rtic]: https://rtic.rs/2/book/en/
[embedded rust]: https://rust-embedded.github.io/book/

## USB Project
Expand Down
2 changes: 1 addition & 1 deletion exercise-book/src/nrf52-usb-advanced-next-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ If you'd like to continue working on your workshop project, we recommend adding

We have covered only a few of the core features of the RTIC framework but the framework has many more features like *software* tasks, tasks that can be spawned by the software; message passing between tasks; and task scheduling, which allows the creation of periodic tasks. We encourage to check the [RTIC book][rtic-book] which describes the features we haven't covered here.

[rtic-book]: https://rtic.rs/0.5/book/en/
[rtic-book]: https://rtic.rs/2/book/en/

## usb-device

Expand Down
24 changes: 19 additions & 5 deletions exercise-book/src/nrf52-usb-rtic-hello.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RTIC hello

RTIC, Real-Time Interrupt-driven Concurrency, is a framework for building evented, time sensitive applications.
RTIC, Real-Time Interrupt-driven Concurrency, is a framework for building event-driven, time-sensitive applications.

✅ Open the [`nrf52-code/usb-app/src/bin/rtic-hello.rs`](../../nrf52-code/usb-app/src/bin/rtic-hello.rs) file.

Expand All @@ -15,6 +15,8 @@ RTIC makes a clearer distinction between the application's initialization phase,
You can use `rustfmt` on `target/rtic-expansion.rs` to make the generated code easier to read. Among other things, the file should contain the following lines. Note that interrupts are disabled during the execution of the `init` function:

```rust ignore
#[doc(hidden)]
#[no_mangle]
unsafe extern "C" fn main() -> ! {
rtic::export::interrupt::disable();
let mut core: rtic::export::Peripherals = rtic::export::Peripherals::steal().into();
Expand All @@ -25,11 +27,23 @@ unsafe extern "C" fn main() -> ! {
{
f();
}
let mut executors_size = 0;
extern "C" {
pub static _stack_start: u32;
pub static __ebss: u32;
}
let stack_start = &_stack_start as *const _ as u32;
let ebss = &__ebss as *const _ as u32;
if stack_start > ebss {
if rtic::export::msp::read() <= ebss {
panic!("Stack overflow after allocating executors");
}
}
__rtic_init_resources(|| {
let (shared_resources, local_resources, mut monotonics) =
init(init::Context::new(core.into()));
let (shared_resources, local_resources) =
init(init::Context::new(core.into(), executors_size));
rtic::export::interrupt::enable();
});
idle(idle::Context::new(&rtic::export::Priority::new(0)))
});
idle(idle::Context::new())
}
```
4 changes: 2 additions & 2 deletions nrf52-code/boards/dk-solution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ name = "dk"
version = "0.0.0"

[dependencies]
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.5"
cortex-m-semihosting = "0.5.0"
defmt = "0.3.8"
defmt-rtt = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions nrf52-code/boards/dk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ name = "dk"
version = "0.0.0"

[dependencies]
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.5"
cortex-m-semihosting = "0.5.0"
defmt = "0.3.8"
defmt-rtt = "0.4"
Expand Down
6 changes: 3 additions & 3 deletions nrf52-code/boards/dongle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ name = "dongle"
version = "0.0.0"

[dependencies]
cortex-m = {version = "0.7.6", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.2"
cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.5"
cortex-m-semihosting = "0.5.0"
critical-section = "1.1.2"
critical-section = "1.2.0"
defmt = "0.3.8"
defmt-rtt = "0.4"
embedded-hal = "1.0"
Expand Down
97 changes: 39 additions & 58 deletions nrf52-code/hal-app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions nrf52-code/hal-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ version = "0.0.0"
description = "Solutions for the nRF52 HAL exercises"

[dependencies]
cortex-m = {version = "0.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7"
cortex-m = {version = "0.7.7", features = ["critical-section-single-core"]}
cortex-m-rt = "0.7.5"
dk = { path = "../boards/dk", features = ["radio"] }
heapless = "0.8"
panic-probe = { version = "0.3", features = ["print-defmt"] }
Expand Down
Loading

0 comments on commit 52142b4

Please sign in to comment.