From c63669488a8dd647d3377890e8be23176aed0638 Mon Sep 17 00:00:00 2001 From: Christian Krenslehner Date: Tue, 1 Apr 2025 13:10:10 +0200 Subject: fix(doc): fix typo in file names to match with docs --- .../examples/static-recources-in-divergent.rs | 67 ---------------------- .../lm3s6965/examples/static-recources-in-init.rs | 60 ------------------- .../examples/static-resources-in-divergent.rs | 67 ++++++++++++++++++++++ .../lm3s6965/examples/static-resources-in-init.rs | 60 +++++++++++++++++++ 4 files changed, 127 insertions(+), 127 deletions(-) delete mode 100644 examples/lm3s6965/examples/static-recources-in-divergent.rs delete mode 100644 examples/lm3s6965/examples/static-recources-in-init.rs create mode 100644 examples/lm3s6965/examples/static-resources-in-divergent.rs create mode 100644 examples/lm3s6965/examples/static-resources-in-init.rs (limited to 'examples') diff --git a/examples/lm3s6965/examples/static-recources-in-divergent.rs b/examples/lm3s6965/examples/static-recources-in-divergent.rs deleted file mode 100644 index af8e982..0000000 --- a/examples/lm3s6965/examples/static-recources-in-divergent.rs +++ /dev/null @@ -1,67 +0,0 @@ -//! examples/static-resources-in-divergent.rs - -#![no_main] -#![no_std] -#![deny(warnings)] -#![deny(unsafe_code)] -#![deny(missing_docs)] - -use panic_semihosting as _; -use rtic_monotonics::systick::prelude::*; -systick_monotonic!(Mono, 100); - -#[rtic::app(device = lm3s6965, dispatchers = [UART0])] -mod app { - use super::*; - - use cortex_m_semihosting::{debug, hprintln}; - use rtic_sync::channel::{Channel, Receiver}; - - #[shared] - struct Shared {} - - #[local] - struct Local {} - - #[init] - fn init(cx: init::Context) -> (Shared, Local) { - Mono::start(cx.core.SYST, 12_000_000); - - divergent::spawn().ok(); - - (Shared {}, Local {}) - } - - #[task(local = [q: Channel = Channel::new()], priority = 1)] - async fn divergent(cx: divergent::Context) -> ! { - // `q` has `'static` lifetime. You can put references to it in `static` variables, - // structs with references to `q` do not need a generic lifetime parameter, etc. - - let (mut tx, rx) = cx.local.q.split(); - let mut state = 0; - - bar::spawn(rx).unwrap(); - - loop { - tx.send(state).await.unwrap(); - state += 1; - Mono::delay(100.millis()).await; - } - } - - #[task(priority = 1)] - async fn bar(_cx: bar::Context, mut rx: Receiver<'static, u32, 5>) -> ! { - loop { - // Lock-free access to the same underlying queue! - if let Some(data) = rx.recv().await.ok() { - hprintln!("received message: {}", data); - - if data == 3 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } else { - Mono::delay(100.millis()).await; - } - } - } - } -} diff --git a/examples/lm3s6965/examples/static-recources-in-init.rs b/examples/lm3s6965/examples/static-recources-in-init.rs deleted file mode 100644 index 419ea97..0000000 --- a/examples/lm3s6965/examples/static-recources-in-init.rs +++ /dev/null @@ -1,60 +0,0 @@ -//! examples/static-resources-in-init.rs - -#![no_main] -#![no_std] -#![deny(warnings)] -#![deny(unsafe_code)] -#![deny(missing_docs)] - -use panic_semihosting as _; - -#[rtic::app(device = lm3s6965, dispatchers = [UART0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use heapless::spsc::{Consumer, Producer, Queue}; - - #[shared] - struct Shared {} - - #[local] - struct Local { - p: Producer<'static, u32, 5>, - c: Consumer<'static, u32, 5>, - } - - #[init(local = [q: Queue = Queue::new()])] - fn init(cx: init::Context) -> (Shared, Local) { - // q has 'static life-time so after the split and return of `init` - // it will continue to exist and be allocated - let (p, c) = cx.local.q.split(); - - foo::spawn().unwrap(); - - (Shared {}, Local { p, c }) - } - - #[idle(local = [c])] - fn idle(c: idle::Context) -> ! { - loop { - // Lock-free access to the same underlying queue! - if let Some(data) = c.local.c.dequeue() { - hprintln!("received message: {}", data); - - // Run foo until data - if data == 3 { - debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator - } else { - foo::spawn().unwrap(); - } - } - } - } - - #[task(local = [p, state: u32 = 0], priority = 1)] - async fn foo(c: foo::Context) { - *c.local.state += 1; - - // Lock-free access to the same underlying queue! - c.local.p.enqueue(*c.local.state).unwrap(); - } -} diff --git a/examples/lm3s6965/examples/static-resources-in-divergent.rs b/examples/lm3s6965/examples/static-resources-in-divergent.rs new file mode 100644 index 0000000..af8e982 --- /dev/null +++ b/examples/lm3s6965/examples/static-resources-in-divergent.rs @@ -0,0 +1,67 @@ +//! examples/static-resources-in-divergent.rs + +#![no_main] +#![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] + +use panic_semihosting as _; +use rtic_monotonics::systick::prelude::*; +systick_monotonic!(Mono, 100); + +#[rtic::app(device = lm3s6965, dispatchers = [UART0])] +mod app { + use super::*; + + use cortex_m_semihosting::{debug, hprintln}; + use rtic_sync::channel::{Channel, Receiver}; + + #[shared] + struct Shared {} + + #[local] + struct Local {} + + #[init] + fn init(cx: init::Context) -> (Shared, Local) { + Mono::start(cx.core.SYST, 12_000_000); + + divergent::spawn().ok(); + + (Shared {}, Local {}) + } + + #[task(local = [q: Channel = Channel::new()], priority = 1)] + async fn divergent(cx: divergent::Context) -> ! { + // `q` has `'static` lifetime. You can put references to it in `static` variables, + // structs with references to `q` do not need a generic lifetime parameter, etc. + + let (mut tx, rx) = cx.local.q.split(); + let mut state = 0; + + bar::spawn(rx).unwrap(); + + loop { + tx.send(state).await.unwrap(); + state += 1; + Mono::delay(100.millis()).await; + } + } + + #[task(priority = 1)] + async fn bar(_cx: bar::Context, mut rx: Receiver<'static, u32, 5>) -> ! { + loop { + // Lock-free access to the same underlying queue! + if let Some(data) = rx.recv().await.ok() { + hprintln!("received message: {}", data); + + if data == 3 { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } else { + Mono::delay(100.millis()).await; + } + } + } + } +} diff --git a/examples/lm3s6965/examples/static-resources-in-init.rs b/examples/lm3s6965/examples/static-resources-in-init.rs new file mode 100644 index 0000000..419ea97 --- /dev/null +++ b/examples/lm3s6965/examples/static-resources-in-init.rs @@ -0,0 +1,60 @@ +//! examples/static-resources-in-init.rs + +#![no_main] +#![no_std] +#![deny(warnings)] +#![deny(unsafe_code)] +#![deny(missing_docs)] + +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965, dispatchers = [UART0])] +mod app { + use cortex_m_semihosting::{debug, hprintln}; + use heapless::spsc::{Consumer, Producer, Queue}; + + #[shared] + struct Shared {} + + #[local] + struct Local { + p: Producer<'static, u32, 5>, + c: Consumer<'static, u32, 5>, + } + + #[init(local = [q: Queue = Queue::new()])] + fn init(cx: init::Context) -> (Shared, Local) { + // q has 'static life-time so after the split and return of `init` + // it will continue to exist and be allocated + let (p, c) = cx.local.q.split(); + + foo::spawn().unwrap(); + + (Shared {}, Local { p, c }) + } + + #[idle(local = [c])] + fn idle(c: idle::Context) -> ! { + loop { + // Lock-free access to the same underlying queue! + if let Some(data) = c.local.c.dequeue() { + hprintln!("received message: {}", data); + + // Run foo until data + if data == 3 { + debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator + } else { + foo::spawn().unwrap(); + } + } + } + } + + #[task(local = [p, state: u32 = 0], priority = 1)] + async fn foo(c: foo::Context) { + *c.local.state += 1; + + // Lock-free access to the same underlying queue! + c.local.p.enqueue(*c.local.state).unwrap(); + } +} -- cgit v1.2.3