Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples to RTIC v2 framework #495

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

* Examples use RTIC v2

## [v0.16.0] 2024-03-12

* MSRV increased to Rust 1.66.1 [#473]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ optional = true

[dev-dependencies]
cortex-m-rt = ">=0.6.15,<0.8"
cortex-m-rtic = "1.1"
rtic = { version = "2.1", features = ["thumbv7-backend"] }
log = "0.4.11"
panic-halt = "0.2.0"
panic-rtt-target = { version = "0.1.0", features = ["cortex-m"] }
Expand Down
9 changes: 3 additions & 6 deletions examples/ethernet-rtic-nucleo-h723zg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Demo for Nucleo-H723ZG eval board using the Real Time for the Masses
//! (RTIC) framework.
//! Demo for Nucleo-H723ZG evaluation board using the Real-Time Interrupt-driven
//! Concurrency (RTIC) framework.
//!
//! This demo responds to pings on 192.168.1.99 (IP address hardcoded below)
//!
Expand Down Expand Up @@ -116,9 +116,7 @@ mod app {
}

#[init]
fn init(
mut ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(mut ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
// Initialise power...
let pwr = ctx.device.PWR.constrain();
Expand Down Expand Up @@ -223,7 +221,6 @@ mod app {
lan8742a,
link_led,
},
init::Monotonics(),
)
}

Expand Down
10 changes: 4 additions & 6 deletions examples/ethernet-rtic-stm32h735g-dk.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Demo for STM32H735G-DK eval board using the Real Time for the Masses
//! (RTIC) framework.
//! Demo for STM32H735G-DK eval board using the Real-Time Interrupt-driven
//! Concurrency (RTIC) framework.
//!
//! This demo responds to pings on 192.168.1.99 (IP address hardcoded below)
//!
Expand Down Expand Up @@ -111,9 +111,8 @@ mod app {
}

#[init]
fn init(
mut ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {

fn init(mut ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
// Initialise power...
let pwr = ctx.device.PWR.constrain();
Expand Down Expand Up @@ -217,7 +216,6 @@ mod app {
lan8742a,
link_led,
},
init::Monotonics(),
)
}

Expand Down
9 changes: 3 additions & 6 deletions examples/ethernet-rtic-stm32h747i-disco.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Demo for STM32H747I-DISCO eval board using the Real Time for the Masses
//! (RTIC) framework.
//! Demo for STM32H747I-DISCO eval board using the Real-Time Interrupt-driven
//! Concurrency (RTIC) framework.
//!
//! STM32H747I-DISCO: RMII TXD1 is on PG12
//!
Expand Down Expand Up @@ -118,9 +118,7 @@ mod app {
}

#[init]
fn init(
mut ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(mut ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
// Initialise power...
let pwr = ctx.device.PWR.constrain();
Expand Down Expand Up @@ -227,7 +225,6 @@ mod app {
lan8742a,
link_led,
},
init::Monotonics(),
)
}

Expand Down
7 changes: 3 additions & 4 deletions examples/rtic.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Simple example of the Real-Time Interrupt-driven Concurrency (RTIC)
//! framework. Originally tested on a STM32H735G-DK.
#![deny(warnings)]
#![deny(unsafe_code)]
#![no_std]
Expand All @@ -24,9 +26,7 @@ mod app {
}

#[init]
fn init(
mut ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(mut ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
let pwr = ctx.device.PWR.constrain();
let pwrcfg = example_power!(pwr).freeze();
Expand All @@ -50,7 +50,6 @@ mod app {
button,
led: gpioc.pc3.into_push_pull_output(),
},
init::Monotonics(),
)
}

Expand Down
10 changes: 4 additions & 6 deletions examples/rtic_low_power.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Timers in RTIC with low power mode.
//! Timers using the Real-Time Interrupt-driven Concurrency (RTIC) framework
//! with low power mode.
//!
//! After the end of init the CPU transitions into CStop mode, and D1/D2
//! (aka. CD) transition into DStop mode.
Expand Down Expand Up @@ -49,9 +50,7 @@ mod app {
}

#[init]
fn init(
ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
let mut syscfg = ctx.device.SYSCFG;

Expand Down Expand Up @@ -135,13 +134,12 @@ mod app {
timer2,
timer3,
},
init::Monotonics(),
)
}

// RTIC inserts a default idle loop that calls asm::wfi()

#[task(binds = EXTI15_10, local = [], priority = 1)]
#[task(binds = EXTI15_10, priority = 1)]
fn exti15_10_interrupt(_: exti15_10_interrupt::Context) {
// Once the wakeup is triggered, we loop here forever
}
Expand Down
8 changes: 3 additions & 5 deletions examples/rtic_timers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//! Timers in RTIC. Tests TIM1, TIM2, TIM12, TIM17
//! Timers using the Real-Time Interrupt-driven Concurrency (RTIC)
//! framework. Tests TIM1, TIM2, TIM12, TIM17
#![deny(warnings)]
#![deny(unsafe_code)]
#![no_std]
Expand Down Expand Up @@ -33,9 +34,7 @@ mod app {
}

#[init]
fn init(
ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
let pwr = ctx.device.PWR.constrain();
let pwrcfg = example_power!(pwr).freeze();
Expand Down Expand Up @@ -88,7 +87,6 @@ mod app {
led3: gpioi.pi14.into_push_pull_output(),
led4: gpioi.pi15.into_push_pull_output(),
},
init::Monotonics(),
)
}

Expand Down
10 changes: 2 additions & 8 deletions examples/sai-i2s-passthru.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ mod app {
struct LocalResources {}

#[init]
fn init(
mut ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(mut ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
let pwr = ctx.device.PWR.constrain();
let vos = example_power!(pwr).freeze();
Expand Down Expand Up @@ -113,11 +111,7 @@ mod app {
audio.try_send(0, 0).unwrap();
info!("Startup complete!");

(
SharedResources { audio },
LocalResources {},
init::Monotonics(),
)
(SharedResources { audio }, LocalResources {})
}

#[task(binds = SAI1, shared = [audio] )]
Expand Down
14 changes: 4 additions & 10 deletions examples/spi-dma-rtic.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Demo for STM32H747I-NUCLEO eval board using the Real Time Interrupt-driven Concurrency (RTIC)
//! framework.
//! Demo for STM32H747I-NUCLEO eval board using the Real-Time Interrupt-driven
//! Concurrency (RTIC) framework.
//!
//! This example demonstrates using DMA to write data over a TX-only SPI interface.
#![deny(warnings)]
Expand Down Expand Up @@ -45,9 +45,7 @@ mod app {
#[local]
struct LocalResources {}
#[init]
fn init(
ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();

// Initialise power...
Expand Down Expand Up @@ -129,11 +127,7 @@ mod app {
_,
> = hal::dma::Transfer::init(streams.1, spi, buffer, None, config);

(
SharedResources { cs, transfer },
LocalResources {},
init::Monotonics(),
)
(SharedResources { cs, transfer }, LocalResources {})
}

#[task(binds=DMA1_STR1, shared = [transfer, cs], priority=2)]
Expand Down
5 changes: 1 addition & 4 deletions examples/usb_rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ mod app {
}

#[init]
fn init(
ctx: init::Context,
) -> (SharedResources, LocalResources, init::Monotonics) {
fn init(ctx: init::Context) -> (SharedResources, LocalResources) {
utilities::logger::init();
let pwr = ctx.device.PWR.constrain();
let pwrcfg = example_power!(pwr).freeze();
Expand Down Expand Up @@ -117,7 +115,6 @@ mod app {
usb,
led: led.into_push_pull_output(),
},
init::Monotonics(),
)
}

Expand Down
Loading