mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 12:12:50 +01:00
Fixing tests
This commit is contained in:
parent
633012190b
commit
98d2af9d73
75 changed files with 591 additions and 1183 deletions
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
|
@ -244,18 +244,15 @@ jobs:
|
|||
resource
|
||||
lock
|
||||
multilock
|
||||
late
|
||||
only-shared-access
|
||||
|
||||
task
|
||||
message
|
||||
capacity
|
||||
|
||||
types
|
||||
not-sync
|
||||
|
||||
generics
|
||||
cfg
|
||||
pool
|
||||
ramfunc
|
||||
|
||||
|
|
|
@ -31,10 +31,6 @@ required-features = ["__v7"]
|
|||
name = "schedule"
|
||||
required-features = ["__v7"]
|
||||
|
||||
[[example]]
|
||||
name = "t-cfg"
|
||||
required-features = ["__v7"]
|
||||
|
||||
[[example]]
|
||||
name = "t-cfg-resources"
|
||||
required-features = ["__min_r1_43"]
|
||||
|
@ -43,10 +39,6 @@ required-features = ["__min_r1_43"]
|
|||
name = "t-schedule"
|
||||
required-features = ["__v7"]
|
||||
|
||||
[[example]]
|
||||
name = "types"
|
||||
required-features = ["__v7"]
|
||||
|
||||
[[example]]
|
||||
name = "double_schedule"
|
||||
required-features = ["__v7"]
|
||||
|
|
|
@ -25,27 +25,32 @@ mod app {
|
|||
use super::BigStruct;
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
big_struct: &'static mut BigStruct,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
let big_struct = unsafe {
|
||||
static mut BIG_STRUCT: MaybeUninit<BigStruct> = MaybeUninit::uninit();
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init(local = [bs: MaybeUninit<BigStruct> = MaybeUninit::uninit()])]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let big_struct = unsafe {
|
||||
// write directly into the static storage
|
||||
BIG_STRUCT.as_mut_ptr().write(BigStruct::new());
|
||||
&mut *BIG_STRUCT.as_mut_ptr()
|
||||
cx.local.bs.as_mut_ptr().write(BigStruct::new());
|
||||
&mut *cx.local.bs.as_mut_ptr()
|
||||
};
|
||||
|
||||
(
|
||||
init::LateResources {
|
||||
Shared {
|
||||
// assign the reference so we can use the resource
|
||||
big_struct,
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(binds = UART0, shared = [big_struct])]
|
||||
fn task(_: task::Context) {}
|
||||
}
|
||||
|
|
|
@ -13,13 +13,19 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
|
||||
hprintln!("init").unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
@ -35,16 +41,14 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
fn foo(_: foo::Context) {
|
||||
static mut TIMES: u32 = 0;
|
||||
|
||||
*TIMES += 1;
|
||||
#[task(binds = UART0, local = [times: u32 = 0])]
|
||||
fn foo(cx: foo::Context) {
|
||||
*cx.local.times += 1;
|
||||
|
||||
hprintln!(
|
||||
"foo called {} time{}",
|
||||
*TIMES,
|
||||
if *TIMES > 1 { "s" } else { "" }
|
||||
*cx.local.times,
|
||||
if *cx.local.times > 1 { "s" } else { "" }
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -12,11 +12,17 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
|
|
|
@ -13,22 +13,32 @@ mod app {
|
|||
#[cfg(debug_assertions)]
|
||||
use cortex_m_semihosting::hprintln;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
||||
#[init(0)]
|
||||
count: u32,
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
unused: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn().unwrap();
|
||||
foo::spawn().unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(
|
||||
Shared {
|
||||
#[cfg(debug_assertions)]
|
||||
count: 0,
|
||||
#[cfg(never)]
|
||||
unused: 1,
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
@ -40,17 +50,17 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(capacity = 2, resources = [count])]
|
||||
#[task(capacity = 2, shared = [count])]
|
||||
fn foo(mut _cx: foo::Context) {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
_cx.resources.count.lock(|count| *count += 1);
|
||||
_cx.shared.count.lock(|count| *count += 1);
|
||||
|
||||
log::spawn(_cx.resources.count.lock(|count| *count)).unwrap();
|
||||
log::spawn(_cx.shared.count.lock(|count| *count)).unwrap();
|
||||
}
|
||||
|
||||
// this wouldn't compile in `release` mode
|
||||
// *_cx.resources.count += 1;
|
||||
// *_cx.shared.count += 1;
|
||||
|
||||
// ..
|
||||
}
|
||||
|
@ -58,17 +68,17 @@ mod app {
|
|||
// The whole task should disappear,
|
||||
// currently still present in the Tasks enum
|
||||
#[cfg(never)]
|
||||
#[task(capacity = 2, resources = [count])]
|
||||
#[task(capacity = 2, shared = [count])]
|
||||
fn foo2(mut _cx: foo2::Context) {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
_cx.resources.count.lock(|count| *count += 10);
|
||||
_cx.shared.count.lock(|count| *count += 10);
|
||||
|
||||
log::spawn(_cx.resources.count.lock(|count| *count)).unwrap();
|
||||
log::spawn(_cx.shared.count.lock(|count| *count)).unwrap();
|
||||
}
|
||||
|
||||
// this wouldn't compile in `release` mode
|
||||
// *_cx.resources.count += 1;
|
||||
// *_cx.shared.count += 1;
|
||||
|
||||
// ..
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
//! examples/cfg.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
|
||||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
#[cfg(debug_assertions)]
|
||||
use cortex_m_semihosting::hprintln;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[cfg(debug_assertions)] // <- `true` when using the `dev` profile
|
||||
#[init(0)]
|
||||
count: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
foo::spawn().unwrap();
|
||||
foo::spawn().unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(capacity = 2, resources = [count])]
|
||||
fn foo(mut _cx: foo::Context) {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
_cx.resources.count.lock(|count| *count += 1);
|
||||
|
||||
log::spawn(_cx.resources.count.lock(|count| *count)).unwrap();
|
||||
}
|
||||
|
||||
// this wouldn't compile in `release` mode
|
||||
// *_cx.resources.count += 1;
|
||||
|
||||
// ..
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
#[task(capacity = 2)]
|
||||
fn log(_: log::Context, n: u32) {
|
||||
hprintln!(
|
||||
"foo has been called {} time{}",
|
||||
n,
|
||||
if n == 1 { "" } else { "s" }
|
||||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
|
@ -12,39 +12,39 @@ mod app {
|
|||
use cortex_m_semihosting::hprintln;
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
// Some resources to work with
|
||||
#[init(0)]
|
||||
a: u32,
|
||||
#[init(0)]
|
||||
b: u32,
|
||||
#[init(0)]
|
||||
c: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared { a: 0, b: 0, c: 0 }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
// Direct destructure
|
||||
#[task(binds = UART0, resources = [&a, &b, &c])]
|
||||
#[task(binds = UART0, shared = [&a, &b, &c])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
let a = cx.resources.a;
|
||||
let b = cx.resources.b;
|
||||
let c = cx.resources.c;
|
||||
let a = cx.shared.a;
|
||||
let b = cx.shared.b;
|
||||
let c = cx.shared.c;
|
||||
|
||||
hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap();
|
||||
}
|
||||
|
||||
// De-structure-ing syntax
|
||||
#[task(binds = UART1, resources = [&a, &b, &c])]
|
||||
#[task(binds = UART1, shared = [&a, &b, &c])]
|
||||
fn uart1(cx: uart1::Context) {
|
||||
let uart1::Resources { a, b, c } = cx.resources;
|
||||
let uart1::SharedResources { a, b, c } = cx.shared;
|
||||
|
||||
hprintln!("UART0: a = {}, b = {}, c = {}", a, b, c).unwrap();
|
||||
}
|
||||
|
|
|
@ -15,8 +15,14 @@ mod app {
|
|||
#[monotonic(binds = SysTick, default = true)]
|
||||
type MyMono = DwtSystick<8_000_000>; // 8 MHz
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
task1::spawn().ok();
|
||||
|
||||
let mut dcb = cx.core.DCB;
|
||||
|
@ -25,7 +31,7 @@ mod app {
|
|||
|
||||
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||
|
||||
(init::LateResources {}, init::Monotonics(mono))
|
||||
(Shared {}, Local {}, init::Monotonics(mono))
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -19,13 +19,19 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
|
||||
hprintln!("init").unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -21,11 +21,17 @@ fn foo(_c: app::foo::Context, x: i32, y: u32) {
|
|||
mod app {
|
||||
use crate::foo;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_c: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn(1, 2).unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
extern "Rust" {
|
||||
|
|
|
@ -14,42 +14,40 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
#[shared]
|
||||
struct Shared {
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared { shared: 0 }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [shared])]
|
||||
#[task(binds = UART0, shared = [shared], local = [state: u32 = 0])]
|
||||
fn uart0(c: uart0::Context) {
|
||||
static mut STATE: u32 = 0;
|
||||
hprintln!("UART0(STATE = {})", *c.local.state).unwrap();
|
||||
|
||||
hprintln!("UART0(STATE = {})", *STATE).unwrap();
|
||||
|
||||
// second argument has type `resources::shared`
|
||||
super::advance(STATE, c.resources.shared);
|
||||
// second argument has type `shared::shared`
|
||||
super::advance(c.local.state, c.shared.shared);
|
||||
|
||||
rtic::pend(Interrupt::UART1);
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#[task(binds = UART1, priority = 2, resources = [shared])]
|
||||
#[task(binds = UART1, priority = 2, shared = [shared], local = [state: u32 = 0])]
|
||||
fn uart1(c: uart1::Context) {
|
||||
static mut STATE: u32 = 0;
|
||||
hprintln!("UART1(STATE = {})", *c.local.state).unwrap();
|
||||
|
||||
hprintln!("UART1(STATE = {})", *STATE).unwrap();
|
||||
|
||||
// second argument has type `resources::shared`
|
||||
super::advance(STATE, c.resources.shared);
|
||||
// second argument has type `shared::shared`
|
||||
super::advance(c.local.state, c.shared.shared);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,15 +12,21 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
// Pends the UART0 interrupt but its handler won't run until *after*
|
||||
// `init` returns because interrupts are disabled
|
||||
rtic::pend(Interrupt::UART0); // equivalent to NVIC::pend
|
||||
|
||||
hprintln!("init").unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
@ -38,17 +44,15 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
fn uart0(_: uart0::Context) {
|
||||
static mut TIMES: u32 = 0;
|
||||
|
||||
#[task(binds = UART0, local = [times: u32 = 0])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
// Safe access to local `static mut` variable
|
||||
*TIMES += 1;
|
||||
*cx.local.times += 1;
|
||||
|
||||
hprintln!(
|
||||
"UART0 called {} time{}",
|
||||
*TIMES,
|
||||
if *TIMES > 1 { "s" } else { "" }
|
||||
*cx.local.times,
|
||||
if *cx.local.times > 1 { "s" } else { "" }
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -11,19 +11,23 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
hprintln!("init").unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
static mut X: u32 = 0;
|
||||
|
||||
// Safe access to local `static mut` variable
|
||||
let _x: &'static mut u32 = X;
|
||||
#[idle(local = [x: u32 = 0])]
|
||||
fn idle(cx: idle::Context) -> ! {
|
||||
// Locals in idle have lifetime 'static
|
||||
let _x: &'static mut u32 = cx.local.x;
|
||||
|
||||
hprintln!("idle").unwrap();
|
||||
|
||||
|
|
|
@ -11,18 +11,22 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
static mut X: u32 = 0;
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init(local = [x: u32 = 0])]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
// Cortex-M peripherals
|
||||
let _core: cortex_m::Peripherals = cx.core;
|
||||
|
||||
// Device specific peripherals
|
||||
let _device: lm3s6965::Peripherals = cx.device;
|
||||
|
||||
// Safe access to local `static mut` variable
|
||||
let _x: &'static mut u32 = X;
|
||||
// Locals in `init` have 'static lifetime
|
||||
let _x: &'static mut u32 = cx.local.x;
|
||||
|
||||
// Access to the critical section token,
|
||||
// to indicate that this is a critical seciton
|
||||
|
@ -32,6 +36,6 @@ mod app {
|
|||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,26 +12,28 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
#[shared]
|
||||
struct Shared {
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::GPIOA);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared { shared: 0 }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
// when omitted priority is assumed to be `1`
|
||||
#[task(binds = GPIOA, resources = [shared])]
|
||||
#[task(binds = GPIOA, shared = [shared])]
|
||||
fn gpioa(mut c: gpioa::Context) {
|
||||
hprintln!("A").unwrap();
|
||||
|
||||
// the lower priority task requires a critical section to access the data
|
||||
c.resources.shared.lock(|shared| {
|
||||
c.shared.shared.lock(|shared| {
|
||||
// data can only be modified within this critical section (closure)
|
||||
*shared += 1;
|
||||
|
||||
|
@ -51,10 +53,10 @@ mod app {
|
|||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#[task(binds = GPIOB, priority = 2, resources = [shared])]
|
||||
#[task(binds = GPIOB, priority = 2, shared = [shared])]
|
||||
fn gpiob(mut c: gpiob::Context) {
|
||||
// the higher priority task does still need a critical section
|
||||
let shared = c.resources.shared.lock(|shared| {
|
||||
let shared = c.shared.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
|
||||
*shared
|
||||
|
|
|
@ -11,21 +11,25 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn(/* no message */).unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn foo(_: foo::Context) {
|
||||
static mut COUNT: u32 = 0;
|
||||
|
||||
#[task(local = [count: u32 = 0])]
|
||||
fn foo(cx: foo::Context) {
|
||||
hprintln!("foo").unwrap();
|
||||
|
||||
bar::spawn(*COUNT).unwrap();
|
||||
*COUNT += 1;
|
||||
bar::spawn(*cx.local.count).unwrap();
|
||||
*cx.local.count += 1;
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -14,29 +14,37 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
#[shared]
|
||||
struct Shared {
|
||||
shared1: u32,
|
||||
#[init(0)]
|
||||
shared2: u32,
|
||||
#[init(0)]
|
||||
shared3: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::GPIOA);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(
|
||||
Shared {
|
||||
shared1: 0,
|
||||
shared2: 0,
|
||||
shared3: 0,
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
// when omitted priority is assumed to be `1`
|
||||
#[task(binds = GPIOA, resources = [shared1, shared2, shared3])]
|
||||
#[task(binds = GPIOA, shared = [shared1, shared2, shared3])]
|
||||
fn locks(c: locks::Context) {
|
||||
let mut s1 = c.resources.shared1;
|
||||
let mut s2 = c.resources.shared2;
|
||||
let mut s3 = c.resources.shared3;
|
||||
let mut s1 = c.shared.shared1;
|
||||
let mut s2 = c.shared.shared2;
|
||||
let mut s3 = c.shared.shared3;
|
||||
|
||||
hprintln!("Multiple single locks").unwrap();
|
||||
s1.lock(|s1| {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! `examples/not-sync.rs`
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
// #![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
@ -12,32 +12,42 @@ pub struct NotSync {
|
|||
_0: PhantomData<*const ()>,
|
||||
}
|
||||
|
||||
unsafe impl Send for NotSync {}
|
||||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||
mod app {
|
||||
use super::NotSync;
|
||||
use core::marker::PhantomData;
|
||||
use cortex_m_semihosting::debug;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(NotSync { _0: PhantomData })]
|
||||
#[shared]
|
||||
struct Shared {
|
||||
shared: NotSync,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(
|
||||
Shared {
|
||||
shared: NotSync { _0: PhantomData },
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[task(resources = [&shared])]
|
||||
#[task(shared = [&shared])]
|
||||
fn foo(c: foo::Context) {
|
||||
let _: &NotSync = c.resources.shared;
|
||||
let _: &NotSync = c.shared.shared;
|
||||
}
|
||||
|
||||
#[task(resources = [&shared])]
|
||||
#[task(shared = [&shared])]
|
||||
fn bar(c: bar::Context) {
|
||||
let _: &NotSync = c.resources.shared;
|
||||
let _: &NotSync = c.shared.shared;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,29 +12,32 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
key: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
|
||||
(init::LateResources { key: 0xdeadbeef }, init::Monotonics())
|
||||
(Shared { key: 0xdeadbeef }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [&key])]
|
||||
#[task(binds = UART0, shared = [&key])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
let key: &u32 = cx.resources.key;
|
||||
let key: &u32 = cx.shared.key;
|
||||
hprintln!("UART0(key = {:#x})", key).unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#[task(binds = UART1, priority = 2, resources = [&key])]
|
||||
#[task(binds = UART1, priority = 2, shared = [&key])]
|
||||
fn uart1(cx: uart1::Context) {
|
||||
hprintln!("UART1(key = {:#x})", cx.resources.key).unwrap();
|
||||
hprintln!("UART1(key = {:#x})", cx.shared.key).unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,8 +16,14 @@ mod app {
|
|||
#[monotonic(binds = SysTick, default = true)]
|
||||
type MyMono = DwtSystick<8_000_000>; // 8 MHz
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let mut dcb = cx.core.DCB;
|
||||
let dwt = cx.core.DWT;
|
||||
let systick = cx.core.SYST;
|
||||
|
@ -26,7 +32,7 @@ mod app {
|
|||
|
||||
foo::spawn_after(Seconds(1_u32)).unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics(mono))
|
||||
(Shared {}, Local {}, init::Monotonics(mono))
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -9,11 +9,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
assert!(cortex_m::Peripherals::take().is_none());
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,16 +24,20 @@ mod app {
|
|||
// Import the memory pool into scope
|
||||
use super::P;
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
static mut MEMORY: [u8; 512] = [0; 512];
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init(local = [memory: [u8; 512] = [0; 512]])]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
// Increase the capacity of the memory pool by ~4
|
||||
P::grow(MEMORY);
|
||||
P::grow(cx.local.memory);
|
||||
|
||||
rtic::pend(Interrupt::I2C0);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task(binds = I2C0, priority = 2)]
|
||||
|
|
|
@ -11,11 +11,17 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::GPIOA);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task(binds = GPIOA, priority = 1)]
|
||||
|
|
|
@ -18,11 +18,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn().unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
|
|
|
@ -12,26 +12,28 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
// A resource
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
// Should not collide with the struct above
|
||||
#[allow(dead_code)]
|
||||
struct Resources2 {
|
||||
struct Shared2 {
|
||||
// A resource
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared { shared: 0 }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
// `shared` cannot be accessed from this context
|
||||
|
@ -39,16 +41,16 @@ mod app {
|
|||
fn idle(_cx: idle::Context) -> ! {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
// error: no `resources` field in `idle::Context`
|
||||
// _cx.resources.shared += 1;
|
||||
// error: no `shared` field in `idle::Context`
|
||||
// _cx.shared.shared += 1;
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
#[task(binds = UART0, resources = [shared])]
|
||||
#[task(binds = UART0, shared = [shared])]
|
||||
fn uart0(mut cx: uart0::Context) {
|
||||
let shared = cx.resources.shared.lock(|shared| {
|
||||
let shared = cx.shared.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
*shared
|
||||
});
|
||||
|
@ -57,9 +59,9 @@ mod app {
|
|||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
#[task(binds = UART1, resources = [shared])]
|
||||
#[task(binds = UART1, shared = [shared])]
|
||||
fn uart1(mut cx: uart1::Context) {
|
||||
let shared = cx.resources.shared.lock(|shared| {
|
||||
let shared = cx.shared.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
*shared
|
||||
});
|
||||
|
|
|
@ -12,19 +12,20 @@ mod app {
|
|||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A resource
|
||||
#[init(0)]
|
||||
#[shared]
|
||||
struct Shared {
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared { shared: 0 }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
// `shared` cannot be accessed from this context
|
||||
|
@ -32,8 +33,8 @@ mod app {
|
|||
fn idle(_cx: idle::Context) -> ! {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
// error: no `resources` field in `idle::Context`
|
||||
// _cx.resources.shared += 1;
|
||||
// error: no `shared` field in `idle::Context`
|
||||
// _cx.shared.shared += 1;
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
|
@ -42,9 +43,9 @@ mod app {
|
|||
|
||||
// `shared` can be accessed from this context
|
||||
// defaults to priority 1
|
||||
#[task(binds = UART0, resources = [shared])]
|
||||
#[task(binds = UART0, shared = [shared])]
|
||||
fn uart0(mut cx: uart0::Context) {
|
||||
let shared = cx.resources.shared.lock(|shared| {
|
||||
let shared = cx.shared.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
*shared
|
||||
});
|
||||
|
@ -54,9 +55,9 @@ mod app {
|
|||
|
||||
// `shared` can be accessed from this context
|
||||
// explicitly set to priority 2
|
||||
#[task(binds = UART1, resources = [shared], priority = 2)]
|
||||
#[task(binds = UART1, shared = [shared], priority = 2)]
|
||||
fn uart1(mut cx: uart1::Context) {
|
||||
let shared = cx.resources.shared.lock(|shared| {
|
||||
let shared = cx.shared.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
*shared
|
||||
});
|
||||
|
|
|
@ -19,8 +19,14 @@ mod app {
|
|||
#[monotonic(binds = SysTick, default = true)]
|
||||
type MyMono = DwtSystick<MONO_HZ>;
|
||||
|
||||
#[init()]
|
||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let mut dcb = cx.core.DCB;
|
||||
let dwt = cx.core.DWT;
|
||||
let systick = cx.core.SYST;
|
||||
|
@ -35,7 +41,7 @@ mod app {
|
|||
// Schedule `bar` to run 2 seconds in the future
|
||||
bar::spawn_after(Seconds(2_u32)).ok();
|
||||
|
||||
(init::LateResources {}, init::Monotonics(mono))
|
||||
(Shared {}, Local {}, init::Monotonics(mono))
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -17,27 +17,27 @@ mod app {
|
|||
};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
// Late resources
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
p: Producer<'static, u32, U4>,
|
||||
c: Consumer<'static, u32, U4>,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
static mut Q: Queue<u32, U4> = Queue(i::Queue::new());
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
let (p, c) = Q.split();
|
||||
#[init(local = [q: Queue<u32, U4> = Queue(i::Queue::new())])]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let (p, c) = cx.local.q.split();
|
||||
|
||||
// Initialization of late resources
|
||||
(init::LateResources { p, c }, init::Monotonics())
|
||||
// Initialization of shared resources
|
||||
(Shared { p, c }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle(resources = [c])]
|
||||
#[idle(shared = [c])]
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
loop {
|
||||
if let Some(byte) = c.resources.c.lock(|c| c.dequeue()) {
|
||||
if let Some(byte) = c.shared.c.lock(|c| c.dequeue()) {
|
||||
hprintln!("received message: {}", byte).unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
@ -47,8 +47,8 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [p])]
|
||||
#[task(binds = UART0, shared = [p])]
|
||||
fn uart0(mut c: uart0::Context) {
|
||||
c.resources.p.lock(|p| p.enqueue(42).unwrap());
|
||||
c.shared.p.lock(|p| p.enqueue(42).unwrap());
|
||||
}
|
||||
}
|
|
@ -7,4 +7,15 @@ use panic_semihosting as _; // panic handler
|
|||
use rtic::app;
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
mod app {}
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,11 +11,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_c: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn(1, 2).unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task()]
|
||||
|
|
|
@ -11,11 +11,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_c: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn(1, 2).unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -18,27 +18,26 @@ mod app {
|
|||
};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
// Late resources
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
p: Producer<'static, u32, U4>,
|
||||
c: Consumer<'static, u32, U4>,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
static mut Q: Queue<u32, U4> = Queue(i::Queue::new());
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
let (p, c) = Q.split();
|
||||
#[init(local = [q: Queue<u32, U4> = Queue(i::Queue::new())])]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let (p, c) = cx.local.q.split();
|
||||
|
||||
// Initialization of late resources
|
||||
(init::LateResources { p, c }, init::Monotonics())
|
||||
(Shared { p, c }, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle(resources = [c])]
|
||||
#[idle(shared = [c])]
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
loop {
|
||||
if let Some(byte) = c.resources.c.lock(|c| c.dequeue()) {
|
||||
if let Some(byte) = c.shared.c.lock(|c| c.dequeue()) {
|
||||
hprintln!("received message: {}", byte).unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
@ -48,10 +47,9 @@ mod app {
|
|||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [p])]
|
||||
#[task(binds = UART0, shared = [p], local = [kalle: u32 = 0])]
|
||||
fn uart0(mut c: uart0::Context) {
|
||||
static mut KALLE: u32 = 0;
|
||||
*KALLE += 1;
|
||||
c.resources.p.lock(|p| p.enqueue(42).unwrap());
|
||||
*c.local.kalle += 1;
|
||||
c.shared.p.lock(|p| p.enqueue(42).unwrap());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,15 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
// Cortex-M exception
|
||||
|
|
|
@ -7,25 +7,24 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A resource
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
#[shared]
|
||||
struct Shared {
|
||||
// A conditionally compiled resource behind feature_x
|
||||
#[cfg(feature = "feature_x")]
|
||||
x: u32,
|
||||
dummy: (), // dummy such that we have at least one late resource
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(
|
||||
init::LateResources {
|
||||
// The feature needs to be applied everywhere x is defined or used
|
||||
Shared {
|
||||
#[cfg(feature = "feature_x")]
|
||||
x: 0,
|
||||
dummy: (), // dummy such that we have at least one late resource
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
//! [compile-pass] check that `#[cfg]` attributes are respected
|
||||
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
foo: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(resources = [foo])]
|
||||
fn foo(_: foo::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
}
|
||||
|
||||
#[task(priority = 3, resources = [foo])]
|
||||
fn bar(_: bar::Context) {
|
||||
#[cfg(never)]
|
||||
static mut BAR: u32 = 0;
|
||||
}
|
||||
|
||||
#[cfg(never)]
|
||||
#[task]
|
||||
fn quux(_: quux::Context) {}
|
||||
}
|
|
@ -9,11 +9,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
rtic::pend(lm3s6965::Interrupt::UART0);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
|
|
|
@ -9,9 +9,15 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -9,10 +9,16 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! [compile-pass] late resources don't need to be `Send` if they are owned by `idle`
|
||||
//! [compile-pass] shared resources don't need to be `Send` if they are owned by `idle`
|
||||
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
@ -16,24 +16,28 @@ mod app {
|
|||
use super::NotSend;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[shared]
|
||||
struct Shared {
|
||||
x: NotSend,
|
||||
#[init(None)]
|
||||
y: Option<NotSend>,
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(
|
||||
init::LateResources {
|
||||
Shared {
|
||||
x: NotSend { _0: PhantomData },
|
||||
y: None,
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[idle(resources = [x, y])]
|
||||
#[idle(shared = [x, y])]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! [compile-pass] Check code generation of resources
|
||||
//! [compile-pass] Check code generation of shared resources
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
|
@ -9,73 +9,77 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
o1: u32, // init
|
||||
#[init(0)]
|
||||
#[shared]
|
||||
struct Shared {
|
||||
o2: u32, // idle
|
||||
#[init(0)]
|
||||
o3: u32, // EXTI0
|
||||
#[init(0)]
|
||||
o4: u32, // idle
|
||||
#[init(0)]
|
||||
o5: u32, // EXTI1
|
||||
#[init(0)]
|
||||
o6: u32, // init
|
||||
#[init(0)]
|
||||
s1: u32, // idle & uart0
|
||||
#[init(0)]
|
||||
s2: u32, // uart0 & uart1
|
||||
#[init(0)]
|
||||
s3: u32, // idle & uart0
|
||||
}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(
|
||||
Shared {
|
||||
o2: 0,
|
||||
o3: 0,
|
||||
o4: 0,
|
||||
o5: 0,
|
||||
s1: 0,
|
||||
s2: 0,
|
||||
s3: 0,
|
||||
},
|
||||
Local {},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
#[idle(resources = [o2, &o4, s1, &s3])]
|
||||
#[idle(shared = [o2, &o4, s1, &s3])]
|
||||
fn idle(mut c: idle::Context) -> ! {
|
||||
// owned by `idle` == `&'static mut`
|
||||
let _: resources::o2 = c.resources.o2;
|
||||
let _: shared_resources::o2 = c.shared.o2;
|
||||
|
||||
// owned by `idle` == `&'static` if read-only
|
||||
let _: &u32 = c.resources.o4;
|
||||
let _: &u32 = c.shared.o4;
|
||||
|
||||
// shared with `idle` == `Mutex`
|
||||
c.resources.s1.lock(|_| {});
|
||||
c.shared.s1.lock(|_| {});
|
||||
|
||||
// `&` if read-only
|
||||
let _: &u32 = c.resources.s3;
|
||||
let _: &u32 = c.shared.s3;
|
||||
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [o3, s1, s2, &s3])]
|
||||
#[task(binds = UART0, shared = [o3, s1, s2, &s3])]
|
||||
fn uart0(c: uart0::Context) {
|
||||
// owned by interrupt == `&mut`
|
||||
let _: resources::o3 = c.resources.o3;
|
||||
let _: shared_resources::o3 = c.shared.o3;
|
||||
|
||||
// no `Mutex` proxy when access from highest priority task
|
||||
let _: resources::s1 = c.resources.s1;
|
||||
let _: shared_resources::s1 = c.shared.s1;
|
||||
|
||||
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
||||
let _: resources::s2 = c.resources.s2;
|
||||
let _: shared_resources::s2 = c.shared.s2;
|
||||
|
||||
// `&` if read-only
|
||||
let _: &u32 = c.resources.s3;
|
||||
let _: &u32 = c.shared.s3;
|
||||
}
|
||||
|
||||
#[task(binds = UART1, resources = [s2, &o5])]
|
||||
#[task(binds = UART1, shared = [s2, &o5])]
|
||||
fn uart1(c: uart1::Context) {
|
||||
// owned by interrupt == `&` if read-only
|
||||
let _: &u32 = c.resources.o5;
|
||||
let _: &u32 = c.shared.o5;
|
||||
|
||||
// no `Mutex` proxy when co-owned by cooperative (same priority) tasks
|
||||
let _: resources::s2 = c.resources.s2;
|
||||
let _: shared_resources::s2 = c.shared.s2;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
//! [compile-pass] Check `schedule` code generation
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(c: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
let _c: cortex_m::Peripherals = c.core;
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn some_task(_: some_task::Context) {}
|
||||
}
|
|
@ -15,8 +15,14 @@ mod app {
|
|||
#[monotonic(binds = SysTick, default = true)]
|
||||
type MyMono = DwtSystick<8_000_000>; // 8 MHz
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let mut dcb = cx.core.DCB;
|
||||
let dwt = cx.core.DWT;
|
||||
let systick = cx.core.SYST;
|
||||
|
@ -114,7 +120,7 @@ mod app {
|
|||
let handle: Result<baz::SpawnHandle, (u32, u32)> = baz::spawn_after(Seconds(1_u32), 0, 1);
|
||||
let _: Result<(u32, u32), ()> = handle.unwrap().cancel();
|
||||
|
||||
(init::LateResources {}, init::Monotonics(mono))
|
||||
(Shared {}, Local {}, init::Monotonics(mono))
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -9,13 +9,19 @@ use panic_semihosting as _;
|
|||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
let _: Result<(), ()> = foo::spawn();
|
||||
let _: Result<(), u32> = bar::spawn(0);
|
||||
let _: Result<(), (u32, u32)> = baz::spawn(0, 1);
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
|
|
@ -9,11 +9,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
taskmain::spawn().ok();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
//! examples/task-local_minimal.rs
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A local (move), late resource
|
||||
#[task_local]
|
||||
l: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
(init::LateResources { l: 42 }, init::Monotonics())
|
||||
}
|
||||
|
||||
// l is task_local
|
||||
#[idle(resources =[l])]
|
||||
fn idle(cx: idle::Context) -> ! {
|
||||
hprintln!("IDLE:l = {}", cx.resources.l).unwrap();
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
//! examples/task-local.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// An early resource
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
|
||||
// A local (move), early resource
|
||||
#[task_local]
|
||||
#[init(1)]
|
||||
l1: u32,
|
||||
|
||||
// An exclusive, early resource
|
||||
#[lock_free]
|
||||
#[init(1)]
|
||||
e1: u32,
|
||||
|
||||
// A local (move), late resource
|
||||
#[task_local]
|
||||
l2: u32,
|
||||
|
||||
// An exclusive, late resource
|
||||
#[lock_free]
|
||||
e2: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
(init::LateResources { e2: 2, l2: 2 }, init::Monotonics())
|
||||
}
|
||||
|
||||
// `shared` cannot be accessed from this context
|
||||
// l1 ok (task_local)
|
||||
// e2 ok (lock_free)
|
||||
#[idle(resources =[l1, e2])]
|
||||
fn idle(cx: idle::Context) -> ! {
|
||||
hprintln!("IDLE:l1 = {}", cx.resources.l1).unwrap();
|
||||
hprintln!("IDLE:e2 = {}", cx.resources.e2).unwrap();
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
// l2 ok (task_local)
|
||||
// e1 ok (lock_free)
|
||||
#[task(priority = 1, binds = UART0, resources = [shared, l2, e1])]
|
||||
fn uart0(mut cx: uart0::Context) {
|
||||
let shared = cx.resources.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
*shared
|
||||
});
|
||||
*cx.resources.e1 += 10;
|
||||
hprintln!("UART0: shared = {}", shared).unwrap();
|
||||
hprintln!("UART0:l2 = {}", cx.resources.l2).unwrap();
|
||||
hprintln!("UART0:e1 = {}", cx.resources.e1).unwrap();
|
||||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
// e1 ok (lock_free)
|
||||
#[task(priority = 1, binds = UART1, resources = [shared, e1])]
|
||||
fn uart1(mut cx: uart1::Context) {
|
||||
let shared = cx.resources.shared.lock(|shared| {
|
||||
*shared += 1;
|
||||
*shared
|
||||
});
|
||||
|
||||
hprintln!("UART1: shared = {}", shared).unwrap();
|
||||
hprintln!("UART1:e1 = {}", cx.resources.e1).unwrap();
|
||||
}
|
||||
}
|
|
@ -11,11 +11,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
foo::spawn().unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -11,11 +11,17 @@ use panic_semihosting as _;
|
|||
mod app {
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
main::spawn().unwrap();
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
(Shared {}, Local {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[task]
|
||||
|
|
|
@ -10,6 +10,17 @@ use rtic::app;
|
|||
mod app {
|
||||
type Test = u32;
|
||||
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn t1(_: t1::Context, _val: Test) {}
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
//! examples/types.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, peripherals = true, dispatchers = [SSI0])]
|
||||
mod app {
|
||||
use cortex_m_semihosting::debug;
|
||||
use dwt_systick_monotonic::DwtSystick;
|
||||
|
||||
#[monotonic(binds = SysTick, default = true)]
|
||||
type MyMono = DwtSystick<8_000_000>; // 8 MHz
|
||||
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
let _: cortex_m::Peripherals = cx.core;
|
||||
let _: lm3s6965::Peripherals = cx.device;
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
let mut dcb = cx.core.DCB;
|
||||
let dwt = cx.core.DWT;
|
||||
let systick = cx.core.SYST;
|
||||
|
||||
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||
|
||||
(init::LateResources {}, init::Monotonics(mono))
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
loop {
|
||||
cortex_m::asm::nop();
|
||||
}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [shared])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
let _: resources::shared = cx.resources.shared;
|
||||
}
|
||||
|
||||
#[task(priority = 2, resources = [shared])]
|
||||
fn foo(cx: foo::Context) {
|
||||
let _: resources::shared = cx.resources.shared;
|
||||
let _: foo::Resources = cx.resources;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,6 @@ mod software_tasks;
|
|||
mod timer_queue;
|
||||
mod util;
|
||||
|
||||
// TODO document the syntax here or in `rtic-syntax`
|
||||
pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||
let mut mod_app = vec![];
|
||||
let mut mains = vec![];
|
||||
|
|
|
@ -76,13 +76,6 @@ pub fn codegen(app: &App, analysis: &Analysis, _extra: &Extra) -> Vec<TokenStrea
|
|||
let inputs = util::mark_internal_ident(&inputs);
|
||||
let (_, tupled, pats, _) = util::regroup_inputs(&task.inputs);
|
||||
|
||||
// TODO Fix me
|
||||
// let locals_new = if task.args.local_resources.is_empty() {
|
||||
// quote!()
|
||||
// } else {
|
||||
// quote!(#name::Locals::new(),)
|
||||
// };
|
||||
|
||||
quote!(
|
||||
#(#cfgs)*
|
||||
#t::#name => {
|
||||
|
|
|
@ -29,13 +29,6 @@ pub fn codegen(
|
|||
let mut user_tasks = vec![];
|
||||
|
||||
for (name, task) in &app.hardware_tasks {
|
||||
// TODO: Fix locals
|
||||
// let locals_new = if task.args.local_resources.is_empty() {
|
||||
// quote!()
|
||||
// } else {
|
||||
// quote!(#name::Locals::new(),)
|
||||
// };
|
||||
|
||||
let symbol = task.args.binds.clone();
|
||||
let priority = task.args.priority;
|
||||
let cfgs = &task.cfgs;
|
||||
|
@ -60,7 +53,6 @@ pub fn codegen(
|
|||
let mut shared_needs_lt = false;
|
||||
let mut local_needs_lt = false;
|
||||
|
||||
// TODO: Fix locals
|
||||
// `${task}Locals`
|
||||
if !task.args.local_resources.is_empty() {
|
||||
let (item, constructor) = local_resources_struct::codegen(
|
||||
|
|
|
@ -31,17 +31,6 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> CodegenResult {
|
|||
|
||||
let mut root_init = vec![];
|
||||
|
||||
// TODO: Fix locals
|
||||
// let mut locals_pat = None;
|
||||
// let mut locals_new = None;
|
||||
// if !init.locals.is_empty() {
|
||||
// let (struct_, pat) = locals::codegen(Context::Init, &init.locals, app);
|
||||
|
||||
// locals_new = Some(quote!(#name::Locals::new()));
|
||||
// locals_pat = Some(pat);
|
||||
// root_init.push(struct_);
|
||||
// }
|
||||
|
||||
let context = &init.context;
|
||||
let attrs = &init.attrs;
|
||||
let stmts = &init.stmts;
|
||||
|
|
|
@ -44,13 +44,16 @@ pub fn codegen(
|
|||
}
|
||||
|
||||
// All declared `local = [NAME: TY = EXPR]` local resources
|
||||
for (name, task_local) in app.declared_local_resources() {
|
||||
for (task_name, resource_name, task_local) in app.declared_local_resources() {
|
||||
let cfgs = &task_local.cfgs;
|
||||
let ty = &task_local.ty;
|
||||
let expr = &task_local.expr;
|
||||
let attrs = &task_local.attrs;
|
||||
|
||||
let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name));
|
||||
let mangled_name = util::mark_internal_ident(&util::declared_static_local_resource_ident(
|
||||
resource_name,
|
||||
&task_name,
|
||||
));
|
||||
|
||||
// For future use
|
||||
// let doc = format!(" RTIC internal: {}:{}", file!(), line!());
|
||||
|
@ -64,13 +67,5 @@ pub fn codegen(
|
|||
));
|
||||
}
|
||||
|
||||
// let mod_resources = if mod_resources.is_empty() {
|
||||
// quote!()
|
||||
// } else {
|
||||
// quote!(mod local_resources {
|
||||
// #(#mod_resources)*
|
||||
// })
|
||||
// };
|
||||
|
||||
(mod_app, TokenStream2::new())
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
Context::SoftwareTask(name) => &app.software_tasks[name].args.local_resources,
|
||||
};
|
||||
|
||||
let task_name = util::get_task_name(ctxt, app);
|
||||
|
||||
let mut fields = vec![];
|
||||
let mut values = vec![];
|
||||
let mut has_cfgs = false;
|
||||
|
@ -41,7 +43,13 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
quote!('a)
|
||||
};
|
||||
|
||||
let mangled_name = util::mark_internal_ident(&util::static_local_resource_ident(name));
|
||||
let mangled_name = if matches!(task_local, TaskLocal::External) {
|
||||
util::mark_internal_ident(&util::static_local_resource_ident(name))
|
||||
} else {
|
||||
util::mark_internal_ident(&util::declared_static_local_resource_ident(
|
||||
name, &task_name,
|
||||
))
|
||||
};
|
||||
|
||||
fields.push(quote!(
|
||||
#(#cfgs)*
|
||||
|
|
|
@ -32,7 +32,7 @@ pub fn codegen(ctxt: Context, needs_lt: &mut bool, app: &App) -> (TokenStream2,
|
|||
None
|
||||
};
|
||||
let ty = &res.ty;
|
||||
let mangled_name = util::mark_internal_ident(&name);
|
||||
let mangled_name = util::mark_internal_ident(&util::static_shared_resource_ident(&name));
|
||||
|
||||
if !res.properties.lock_free {
|
||||
if access.is_shared() {
|
||||
|
|
|
@ -212,6 +212,17 @@ pub fn regroup_inputs(
|
|||
}
|
||||
}
|
||||
|
||||
/// Get the ident for the name of the task
|
||||
pub fn get_task_name(ctxt: Context, app: &App) -> Ident {
|
||||
let s = match ctxt {
|
||||
Context::Init => app.init.name.to_string(),
|
||||
Context::Idle => app.idle.as_ref().unwrap().name.to_string(),
|
||||
Context::HardwareTask(ident) | Context::SoftwareTask(ident) => ident.to_string(),
|
||||
};
|
||||
|
||||
Ident::new(&s, Span::call_site())
|
||||
}
|
||||
|
||||
/// Generates a pre-reexport identifier for the "shared resources" struct
|
||||
pub fn shared_resources_ident(ctxt: Context, app: &App) -> Ident {
|
||||
let mut s = match ctxt {
|
||||
|
@ -276,11 +287,24 @@ pub fn monotonic_ident(name: &str) -> Ident {
|
|||
}
|
||||
|
||||
pub fn static_shared_resource_ident(name: &Ident) -> Ident {
|
||||
Ident::new(&format!("shared_{}", name.to_string()), Span::call_site())
|
||||
Ident::new(
|
||||
&format!("shared_resource_{}", name.to_string()),
|
||||
Span::call_site(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn static_local_resource_ident(name: &Ident) -> Ident {
|
||||
Ident::new(&format!("local_{}", name.to_string()), Span::call_site())
|
||||
Ident::new(
|
||||
&format!("local_resource_{}", name.to_string()),
|
||||
Span::call_site(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
|
||||
Ident::new(
|
||||
&format!("local_{}_{}", task_name.to_string(), name.to_string()),
|
||||
Span::call_site(),
|
||||
)
|
||||
}
|
||||
|
||||
/// The name to get better RT flag errors
|
||||
|
|
|
@ -10,6 +10,17 @@ fn analyze() {
|
|||
quote!(device = pac, dispatchers = [B, A]),
|
||||
quote!(
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task(priority = 1)]
|
||||
fn a(_: a::Context) {}
|
||||
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task(binds = NonMaskableInt)]
|
||||
fn nmi(_: nmi::Context) {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: only exceptions with configurable priority can be used as hardware tasks
|
||||
--> $DIR/exception-invalid.rs:6:8
|
||||
|
|
||||
6 | fn nmi(_: nmi::Context) {}
|
||||
| ^^^
|
||||
--> $DIR/exception-invalid.rs:17:8
|
||||
|
|
||||
17 | fn nmi(_: nmi::Context) {}
|
||||
| ^^^
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn a(_: a::Context) {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: not enough interrupts to dispatch all software tasks (need: 1; given: 0)
|
||||
--> $DIR/extern-interrupt-not-enough.rs:6:8
|
||||
|
|
||||
6 | fn a(_: a::Context) {}
|
||||
| ^
|
||||
--> $DIR/extern-interrupt-not-enough.rs:17:8
|
||||
|
|
||||
17 | fn a(_: a::Context) {}
|
||||
| ^
|
||||
|
|
|
@ -2,6 +2,17 @@
|
|||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [UART0])]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
fn a(_: a::Context) {}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: dispatcher interrupts can't be used as hardware tasks
|
||||
--> $DIR/extern-interrupt-used.rs:5:20
|
||||
|
|
||||
5 | #[task(binds = UART0)]
|
||||
| ^^^^^
|
||||
--> $DIR/extern-interrupt-used.rs:16:20
|
||||
|
|
||||
16 | #[task(binds = UART0)]
|
||||
| ^^^^^
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
//! examples/local-cfg-task-local.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
//#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::hprintln;
|
||||
use lm3s6965::Interrupt;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// A local (move), early resource
|
||||
#[cfg(feature = "feature_l1")]
|
||||
#[task_local]
|
||||
#[init(1)]
|
||||
l1: u32,
|
||||
|
||||
// A local (move), late resource
|
||||
#[task_local]
|
||||
l2: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
(
|
||||
init::LateResources {
|
||||
#[cfg(feature = "feature_l2")]
|
||||
l2: 2,
|
||||
#[cfg(not(feature = "feature_l2"))]
|
||||
l2: 5,
|
||||
},
|
||||
init::Monotonics(),
|
||||
)
|
||||
}
|
||||
|
||||
// l1 ok (task_local)
|
||||
#[idle(resources =[#[cfg(feature = "feature_l1")]l1])]
|
||||
fn idle(_cx: idle::Context) -> ! {
|
||||
#[cfg(feature = "feature_l1")]
|
||||
hprintln!("IDLE:l1 = {}", _cx.resources.l1).unwrap();
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
loop {}
|
||||
}
|
||||
|
||||
// l2 ok (task_local)
|
||||
#[task(priority = 1, binds = UART0, resources = [
|
||||
#[cfg(feature = "feature_l2")]l2,
|
||||
])]
|
||||
fn uart0(_cx: uart0::Context) {
|
||||
#[cfg(feature = "feature_l2")]
|
||||
hprintln!("UART0:l2 = {}", _cx.resources.l2).unwrap();
|
||||
}
|
||||
|
||||
// l2 error, conflicting with uart0 for l2 (task_local)
|
||||
#[task(priority = 1, binds = UART1, resources = [
|
||||
#[cfg(not(feature = "feature_l2"))]l2
|
||||
])]
|
||||
fn uart1(_cx: uart1::Context) {
|
||||
#[cfg(not(feature = "feature_l2"))]
|
||||
hprintln!("UART0:l2 = {}", _cx.resources.l2).unwrap();
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
error: task local resource "l2" is used by multiple tasks
|
||||
--> $DIR/local-cfg-task-local-err.rs:25:9
|
||||
|
|
||||
25 | l2: u32,
|
||||
| ^^
|
||||
|
||||
error: task local resource "l2" is used by task "uart0" with priority 1
|
||||
--> $DIR/local-cfg-task-local-err.rs:54:39
|
||||
|
|
||||
54 | #[cfg(feature = "feature_l2")]l2,
|
||||
| ^^
|
||||
|
||||
error: task local resource "l2" is used by task "uart1" with priority 1
|
||||
--> $DIR/local-cfg-task-local-err.rs:63:44
|
||||
|
|
||||
63 | #[cfg(not(feature = "feature_l2"))]l2
|
||||
| ^^
|
||||
|
||||
warning: unused import: `cortex_m_semihosting::debug`
|
||||
--> $DIR/local-cfg-task-local-err.rs:8:5
|
||||
|
|
||||
8 | use cortex_m_semihosting::debug;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(unused_imports)]` on by default
|
||||
|
||||
warning: unused import: `cortex_m_semihosting::hprintln`
|
||||
--> $DIR/local-cfg-task-local-err.rs:9:5
|
||||
|
|
||||
9 | use cortex_m_semihosting::hprintln;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: unused import: `lm3s6965::Interrupt`
|
||||
--> $DIR/local-cfg-task-local-err.rs:10:5
|
||||
|
|
||||
10 | use lm3s6965::Interrupt;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
|
@ -1,83 +0,0 @@
|
|||
//! examples/local_err.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
// errors here, since we cannot bail compilation or generate stubs
|
||||
// run cargo expand, then you see the root of the problem...
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
// An early resource
|
||||
#[init(0)]
|
||||
shared: u32,
|
||||
|
||||
// A local (move), early resource
|
||||
#[task_local]
|
||||
#[init(1)]
|
||||
l1: u32,
|
||||
|
||||
// An exclusive, early resource
|
||||
#[lock_free]
|
||||
#[init(1)]
|
||||
e1: u32,
|
||||
|
||||
// A local (move), late resource
|
||||
#[task_local]
|
||||
l2: u32,
|
||||
|
||||
// An exclusive, late resource
|
||||
#[lock_free]
|
||||
e2: u32,
|
||||
}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
rtic::pend(Interrupt::UART0);
|
||||
rtic::pend(Interrupt::UART1);
|
||||
(init::LateResources { e2: 2, l2: 2 }, init::Monotonics())
|
||||
}
|
||||
|
||||
// `shared` cannot be accessed from this context
|
||||
// l1 ok
|
||||
// l2 rejeceted (not task_local)
|
||||
// e2 ok
|
||||
#[idle(resources =[l1, l2, e2])]
|
||||
fn idle(cx: idle::Context) -> ! {
|
||||
hprintln!("IDLE:l1 = {}", cx.resources.l1).unwrap();
|
||||
hprintln!("IDLE:e2 = {}", cx.resources.e2).unwrap();
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
loop {}
|
||||
}
|
||||
|
||||
// `shared` can be accessed from this context
|
||||
// l2 rejected (not task_local)
|
||||
// e1 rejected (not lock_free)
|
||||
#[task(priority = 1, binds = UART0, resources = [shared, l2, e1])]
|
||||
fn uart0(cx: uart0::Context) {
|
||||
let shared: &mut u32 = cx.resources.shared;
|
||||
*shared += 1;
|
||||
*cx.resources.e1 += 10;
|
||||
hprintln!("UART0: shared = {}", shared).unwrap();
|
||||
hprintln!("UART0:l2 = {}", cx.resources.l2).unwrap();
|
||||
hprintln!("UART0:e1 = {}", cx.resources.e1).unwrap();
|
||||
}
|
||||
|
||||
// l2 rejected (not task_local)
|
||||
#[task(priority = 2, binds = UART1, resources = [shared, l2, e1])]
|
||||
fn uart1(cx: uart1::Context) {
|
||||
let shared: &mut u32 = cx.resources.shared;
|
||||
*shared += 1;
|
||||
|
||||
hprintln!("UART1: shared = {}", shared).unwrap();
|
||||
hprintln!("UART1:l2 = {}", cx.resources.l2).unwrap();
|
||||
hprintln!("UART1:e1 = {}", cx.resources.e1).unwrap();
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
error: task local resource "l2" is used by multiple tasks
|
||||
--> $DIR/local-err.rs:34:9
|
||||
|
|
||||
34 | l2: u32,
|
||||
| ^^
|
||||
|
||||
error: task local resource "l2" is used by task "idle" with priority 0
|
||||
--> $DIR/local-err.rs:52:28
|
||||
|
|
||||
52 | #[idle(resources =[l1, l2, e2])]
|
||||
| ^^
|
||||
|
||||
error: task local resource "l2" is used by task "uart0" with priority 1
|
||||
--> $DIR/local-err.rs:63:62
|
||||
|
|
||||
63 | #[task(priority = 1, binds = UART0, resources = [shared, l2, e1])]
|
||||
| ^^
|
||||
|
||||
error: task local resource "l2" is used by task "uart1" with priority 2
|
||||
--> $DIR/local-err.rs:74:62
|
||||
|
|
||||
74 | #[task(priority = 2, binds = UART1, resources = [shared, l2, e1])]
|
||||
| ^^
|
||||
|
||||
error: Lock free resource "e1" is used by tasks at different priorities
|
||||
--> $DIR/local-err.rs:30:9
|
||||
|
|
||||
30 | e1: u32,
|
||||
| ^^
|
||||
|
||||
error: Resource "e1" is declared lock free but used by tasks at different priorities
|
||||
--> $DIR/local-err.rs:63:66
|
||||
|
|
||||
63 | #[task(priority = 1, binds = UART0, resources = [shared, l2, e1])]
|
||||
| ^^
|
||||
|
||||
error: Resource "e1" is declared lock free but used by tasks at different priorities
|
||||
--> $DIR/local-err.rs:74:66
|
||||
|
|
||||
74 | #[task(priority = 2, binds = UART1, resources = [shared, l2, e1])]
|
||||
| ^^
|
||||
|
||||
error: unused imports: `debug`, `hprintln`
|
||||
--> $DIR/local-err.rs:10:28
|
||||
|
|
||||
10 | use cortex_m_semihosting::{debug, hprintln};
|
||||
| ^^^^^ ^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/local-err.rs:4:9
|
||||
|
|
||||
4 | #![deny(warnings)]
|
||||
| ^^^^^^^^
|
||||
= note: `#[deny(unused_imports)]` implied by `#[deny(warnings)]`
|
||||
|
||||
error: unused import: `lm3s6965::Interrupt`
|
||||
--> $DIR/local-err.rs:11:5
|
||||
|
|
||||
11 | use lm3s6965::Interrupt;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
|
@ -1,50 +0,0 @@
|
|||
#![no_main]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||
mod app {
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
#[cfg(never)]
|
||||
static mut FOO: u32 = 0;
|
||||
|
||||
FOO;
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle(_: idle::Context) -> ! {
|
||||
#[cfg(never)]
|
||||
static mut FOO: u32 = 0;
|
||||
|
||||
FOO;
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[task(binds = SVCall)]
|
||||
fn svcall(_: svcall::Context) {
|
||||
#[cfg(never)]
|
||||
static mut FOO: u32 = 0;
|
||||
|
||||
FOO;
|
||||
}
|
||||
|
||||
#[task(binds = UART0)]
|
||||
fn uart0(_: uart0::Context) {
|
||||
#[cfg(never)]
|
||||
static mut FOO: u32 = 0;
|
||||
|
||||
FOO;
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn foo(_: foo::Context) {
|
||||
#[cfg(never)]
|
||||
static mut FOO: u32 = 0;
|
||||
|
||||
FOO;
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
error[E0425]: cannot find value `FOO` in this scope
|
||||
--> $DIR/locals-cfg.rs:12:9
|
||||
|
|
||||
12 | FOO;
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find value `FOO` in this scope
|
||||
--> $DIR/locals-cfg.rs:22:9
|
||||
|
|
||||
22 | FOO;
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find value `FOO` in this scope
|
||||
--> $DIR/locals-cfg.rs:32:9
|
||||
|
|
||||
32 | FOO;
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find value `FOO` in this scope
|
||||
--> $DIR/locals-cfg.rs:40:9
|
||||
|
|
||||
40 | FOO;
|
||||
| ^^^ not found in this scope
|
||||
|
||||
error[E0425]: cannot find value `FOO` in this scope
|
||||
--> $DIR/locals-cfg.rs:48:9
|
||||
|
|
||||
48 | FOO;
|
||||
| ^^^ not found in this scope
|
|
@ -1,80 +0,0 @@
|
|||
#![no_main]
|
||||
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[resources]
|
||||
struct Resources {
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
o1: u32, // init
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
o2: u32, // idle
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
o3: u32, // EXTI0
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
o4: u32, // idle
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
o5: u32, // EXTI1
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
o6: u32, // init
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
s1: u32, // idle & EXTI0
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
s2: u32, // EXTI0 & EXTI1
|
||||
|
||||
#[cfg(never)]
|
||||
#[init(0)]
|
||||
s3: u32,
|
||||
}
|
||||
|
||||
#[init(resources = [o1, o4, o5, o6, s3])]
|
||||
fn init(c: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
c.resources.o1;
|
||||
c.resources.o4;
|
||||
c.resources.o5;
|
||||
c.resources.o6;
|
||||
c.resources.s3;
|
||||
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
}
|
||||
|
||||
#[idle(resources = [o2, &o4, s1, &s3])]
|
||||
fn idle(c: idle::Context) -> ! {
|
||||
c.resources.o2;
|
||||
c.resources.o4;
|
||||
c.resources.s1;
|
||||
c.resources.s3;
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[task(binds = UART0, resources = [o3, s1, s2, &s3])]
|
||||
fn uart0(c: uart0::Context) {
|
||||
c.resources.o3;
|
||||
c.resources.s1;
|
||||
c.resources.s2;
|
||||
c.resources.s3;
|
||||
}
|
||||
|
||||
#[task(binds = UART1, resources = [s2, &o5])]
|
||||
fn uart1(c: uart1::Context) {
|
||||
c.resources.s2;
|
||||
c.resources.o5;
|
||||
}
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
error[E0609]: no field `o1` on type `__rtic_internal_initResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:48:21
|
||||
|
|
||||
48 | c.resources.o1;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o4` on type `__rtic_internal_initResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:49:21
|
||||
|
|
||||
49 | c.resources.o4;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o5` on type `__rtic_internal_initResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:50:21
|
||||
|
|
||||
50 | c.resources.o5;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o6` on type `__rtic_internal_initResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:51:21
|
||||
|
|
||||
51 | c.resources.o6;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s3` on type `__rtic_internal_initResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:52:21
|
||||
|
|
||||
52 | c.resources.s3;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o2` on type `__rtic_internal_idleResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:59:21
|
||||
|
|
||||
59 | c.resources.o2;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o4` on type `__rtic_internal_idleResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:60:21
|
||||
|
|
||||
60 | c.resources.o4;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s1` on type `__rtic_internal_idleResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:61:21
|
||||
|
|
||||
61 | c.resources.s1;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s3` on type `__rtic_internal_idleResources<'_>`
|
||||
--> $DIR/resources-cfg.rs:62:21
|
||||
|
|
||||
62 | c.resources.s3;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o3` on type `__rtic_internal_uart0Resources<'_>`
|
||||
--> $DIR/resources-cfg.rs:69:21
|
||||
|
|
||||
69 | c.resources.o3;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s1` on type `__rtic_internal_uart0Resources<'_>`
|
||||
--> $DIR/resources-cfg.rs:70:21
|
||||
|
|
||||
70 | c.resources.s1;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s2` on type `__rtic_internal_uart0Resources<'_>`
|
||||
--> $DIR/resources-cfg.rs:71:21
|
||||
|
|
||||
71 | c.resources.s2;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s3` on type `__rtic_internal_uart0Resources<'_>`
|
||||
--> $DIR/resources-cfg.rs:72:21
|
||||
|
|
||||
72 | c.resources.s3;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `s2` on type `__rtic_internal_uart1Resources<'_>`
|
||||
--> $DIR/resources-cfg.rs:77:21
|
||||
|
|
||||
77 | c.resources.s2;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
||||
|
||||
error[E0609]: no field `o5` on type `__rtic_internal_uart1Resources<'_>`
|
||||
--> $DIR/resources-cfg.rs:78:21
|
||||
|
|
||||
78 | c.resources.o5;
|
||||
| ^^ unknown field
|
||||
|
|
||||
= note: available fields are: `__marker__`
|
|
@ -2,9 +2,15 @@
|
|||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
mod app {
|
||||
#[shared]
|
||||
struct Shared {}
|
||||
|
||||
#[local]
|
||||
struct Local {}
|
||||
|
||||
#[init]
|
||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||
(init::LateResources {}, init::Monotonics())
|
||||
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||
(Shared {}, Local {}, init::Monotonics {})
|
||||
}
|
||||
|
||||
#[task(binds = GPIOA, priority = 1)]
|
||||
|
|
Loading…
Reference in a new issue