mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-18 05:45:19 +01:00
Merge #368
368: Mod over const r=korken89 a=AfoHT Related [RFC](https://github.com/rtic-rs/rfcs/pull/34) Dependent on [rtic-syntax-PR30](https://github.com/rtic-rs/rtic-syntax/pull/30) ~~Currently using my own dev-branch~~ Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
This commit is contained in:
commit
dbf9a7f298
77 changed files with 638 additions and 333 deletions
|
|
@ -11,7 +11,7 @@ use panic_semihosting as _;
|
|||
|
||||
// NOTE: does NOT properly work on QEMU
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
fn init(cx: init::Context) {
|
||||
// omitted: initialization of `CYCCNT`
|
||||
|
|
@ -51,4 +51,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use panic_semihosting as _;
|
|||
|
||||
// `examples/interrupt.rs` rewritten to use `binds`
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
|
|
@ -45,4 +45,4 @@ const APP: () = {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
|
|
@ -44,4 +44,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ use cortex_m_semihosting::hprintln;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
||||
#[init(0)]
|
||||
|
|
@ -66,4 +67,4 @@ const APP: () = {
|
|||
fn SSI0();
|
||||
fn QEI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// Some resources to work with
|
||||
#[init(0)]
|
||||
|
|
@ -44,4 +45,4 @@ const APP: () = {
|
|||
|
||||
hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ use panic_semihosting as _;
|
|||
use rtic::cyccnt::U32Ext;
|
||||
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
nothing: (),
|
||||
}
|
||||
|
|
@ -34,4 +36,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ use panic_semihosting as _;
|
|||
use rtic::{Exclusive, Mutex};
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
|
|
@ -49,7 +50,7 @@ const APP: () = {
|
|||
// second argument has type `Exclusive<u32>`
|
||||
advance(STATE, Exclusive(c.resources.shared));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// the second parameter is generic: it can be any type that implements the `Mutex` trait
|
||||
fn advance(state: &mut u32, mut shared: impl Mutex<T = u32>) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
// Pends the UART0 interrupt but its handler won't run until *after*
|
||||
|
|
@ -49,4 +49,4 @@ const APP: () = {
|
|||
)
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use cortex_m_semihosting::{debug, hprintln};
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
hprintln!("init").unwrap();
|
||||
|
|
@ -30,4 +30,4 @@ const APP: () = {
|
|||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use cortex_m_semihosting::{debug, hprintln};
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, peripherals = true)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(cx: init::Context) {
|
||||
static mut X: u32 = 0;
|
||||
|
|
@ -31,4 +31,4 @@ const APP: () = {
|
|||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,8 +15,13 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
use heapless::{
|
||||
consts::*,
|
||||
spsc::{Consumer, Producer},
|
||||
};
|
||||
// Late resources
|
||||
#[resources]
|
||||
struct Resources {
|
||||
p: Producer<'static, u32, U4>,
|
||||
c: Consumer<'static, u32, U4>,
|
||||
|
|
@ -49,4 +54,4 @@ const APP: () = {
|
|||
fn uart0(c: uart0::Context) {
|
||||
c.resources.p.enqueue(42).unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
|
|
@ -59,4 +60,4 @@ const APP: () = {
|
|||
fn gpioc(_: gpioc::Context) {
|
||||
hprintln!("C").unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use cortex_m_semihosting::{debug, hprintln};
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
fn init(c: init::Context) {
|
||||
c.spawn.foo(/* no message */).unwrap();
|
||||
|
|
@ -49,4 +49,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ pub struct NotSend {
|
|||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
use super::NotSend;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(None)]
|
||||
shared: Option<NotSend>,
|
||||
|
|
@ -60,4 +63,4 @@ const APP: () = {
|
|||
fn SSI0();
|
||||
fn QEI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,11 @@ pub struct NotSync {
|
|||
}
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
use super::NotSync;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(NotSync { _0: PhantomData })]
|
||||
shared: NotSync,
|
||||
|
|
@ -42,4 +46,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
key: u32,
|
||||
}
|
||||
|
|
@ -35,4 +36,4 @@ const APP: () = {
|
|||
fn uart1(cx: uart1::Context) {
|
||||
hprintln!("UART1(key = {:#x})", cx.resources.key).unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ const PERIOD: u32 = 8_000_000;
|
|||
|
||||
// NOTE: does NOT work on QEMU!
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
|
||||
#[init(schedule = [foo])]
|
||||
fn init(cx: init::Context) {
|
||||
// omitted: initialization of `CYCCNT`
|
||||
|
|
@ -35,4 +36,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ use cortex_m_semihosting::debug;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn main(_: main::Context) {
|
||||
fn taskmain(_: taskmain::Context) {
|
||||
assert!(cortex_m::Peripherals::take().is_none());
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,12 @@ use rtic::app;
|
|||
pool!(P: [u8; 128]);
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
use crate::Box;
|
||||
|
||||
// Import the memory pool into scope
|
||||
use super::P;
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
static mut MEMORY: [u8; 512] = [0; 512];
|
||||
|
|
@ -66,4 +71,4 @@ const APP: () = {
|
|||
fn SSI0();
|
||||
fn QEI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use panic_semihosting as _;
|
|||
use rtic::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
rtic::pend(Interrupt::GPIOA);
|
||||
|
|
@ -34,4 +34,4 @@ const APP: () = {
|
|||
rtic::pend(Interrupt::GPIOB);
|
||||
hprintln!(" GPIOC - end").unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use cortex_m_semihosting::{debug, hprintln};
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(spawn = [bar])]
|
||||
fn init(c: init::Context) {
|
||||
c.spawn.bar().unwrap();
|
||||
|
|
@ -38,4 +38,4 @@ const APP: () = {
|
|||
#[link_section = ".data.UART1"]
|
||||
fn UART1();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
61
examples/resource-user-struct.rs
Normal file
61
examples/resource-user-struct.rs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
//! examples/resource.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A resource
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
// Should not collide with the struct above
|
||||
#[allow(dead_code)]
|
||||
struct Resources2 {
|
||||
// A resource
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
}
|
||||
|
||||
// `shared` cannot be accessed from this context
|
||||
#[idle]
|
||||
fn idle(_cx: idle::Context) -> ! {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
// error: no `resources` field in `idle::Context`
|
||||
// _cx.resources.shared += 1;
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
#[task(binds = UART0, resources = [shared])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
let shared: &mut u32 = cx.resources.shared;
|
||||
*shared += 1;
|
||||
|
||||
hprintln!("UART0: shared = {}", shared).unwrap();
|
||||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
#[task(binds = UART1, resources = [shared])]
|
||||
fn uart1(cx: uart1::Context) {
|
||||
*cx.resources.shared += 1;
|
||||
|
||||
hprintln!("UART1: shared = {}", cx.resources.shared).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,8 @@ use lm3s6965::Interrupt;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A resource
|
||||
#[init(0)]
|
||||
|
|
@ -52,4 +53,4 @@ const APP: () = {
|
|||
|
||||
hprintln!("UART1: shared = {}", cx.resources.shared).unwrap();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use rtic::cyccnt::{Instant, U32Ext as _};
|
|||
|
||||
// NOTE: does NOT work on QEMU!
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(schedule = [foo, bar])]
|
||||
fn init(mut cx: init::Context) {
|
||||
// Initialize (enable) the monotonic timer (CYCCNT)
|
||||
|
|
@ -50,4 +50,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ use rtic::app;
|
|||
pub struct MustBeSend;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
use super::MustBeSend;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(None)]
|
||||
shared: Option<MustBeSend>,
|
||||
|
|
@ -37,4 +40,4 @@ const APP: () = {
|
|||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ use panic_semihosting as _; // panic handler
|
|||
use rtic::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {};
|
||||
mod app {}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
use panic_halt as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {}
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ const APP: () = {
|
|||
fn bar(c: bar::Context) {
|
||||
bar_trampoline(c)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn foo_trampoline(_: foo::Context) {}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,17 @@
|
|||
use panic_halt as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A resource
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
|
||||
// A conditionally compiled resource behind feature_x
|
||||
#[cfg(feature = "feature_x")]
|
||||
x: u32,
|
||||
|
||||
dummy: (),
|
||||
dummy: (), // dummy such that we have at least one late resource
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> init::LateResources {
|
||||
init::LateResources {
|
||||
|
|
@ -35,4 +33,4 @@ const APP: () = {
|
|||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
use panic_halt as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
|
|
@ -52,4 +53,4 @@ const APP: () = {
|
|||
fn SSI0();
|
||||
fn QEI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ use cortex_m_semihosting::debug;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {
|
||||
rtic::pend(lm3s6965::Interrupt::UART0)
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
fn main(_: main::Context) {
|
||||
fn taskmain(_: taskmain::Context) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ use cortex_m_semihosting::debug;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) {}
|
||||
|
||||
#[idle]
|
||||
fn main(_: main::Context) -> ! {
|
||||
fn taskmain(_: taskmain::Context) -> ! {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,9 @@ use cortex_m_semihosting::debug;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init]
|
||||
fn main(_: main::Context) {
|
||||
fn taskmain(_: taskmain::Context) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ pub struct NotSend {
|
|||
}
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
use super::NotSend;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
x: NotSend,
|
||||
#[init(None)]
|
||||
|
|
@ -35,4 +38,4 @@ const APP: () = {
|
|||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
use panic_halt as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
o1: u32, // init
|
||||
|
|
@ -86,4 +87,4 @@ const APP: () = {
|
|||
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
||||
let _: &mut u32 = c.resources.s2;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use panic_halt as _;
|
|||
use rtic::cyccnt::{Instant, U32Ext as _};
|
||||
|
||||
#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(schedule = [foo, bar, baz])]
|
||||
fn init(c: init::Context) {
|
||||
let _: Result<(), ()> = c.schedule.foo(c.start + 10.cycles());
|
||||
|
|
@ -61,4 +61,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
use panic_halt as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(spawn = [foo, bar, baz])]
|
||||
fn init(c: init::Context) {
|
||||
let _: Result<(), ()> = c.spawn.foo();
|
||||
|
|
@ -60,4 +60,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,14 +7,14 @@ use cortex_m_semihosting::debug;
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [main])]
|
||||
mod app {
|
||||
#[init(spawn = [taskmain])]
|
||||
fn init(cx: init::Context) {
|
||||
cx.spawn.main().ok();
|
||||
cx.spawn.taskmain().ok();
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn main(_: main::Context) {
|
||||
fn taskmain(_: taskmain::Context) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -24,4 +24,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use cortex_m_semihosting::{debug, hprintln};
|
|||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[init(spawn = [foo])]
|
||||
fn init(c: init::Context) {
|
||||
c.spawn.foo().unwrap();
|
||||
|
|
@ -52,4 +52,4 @@ const APP: () = {
|
|||
fn SSI0();
|
||||
fn QEI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@ use panic_semihosting as _;
|
|||
use rtic::cyccnt;
|
||||
|
||||
#[rtic::app(device = lm3s6965, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)]
|
||||
const APP: () = {
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
|
|
@ -60,4 +61,4 @@ const APP: () = {
|
|||
extern "C" {
|
||||
fn SSI0();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue