aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2021-07-07 22:50:59 +0200
committerGravatar Emil Fresk <emil.fresk@gmail.com> 2021-07-07 23:07:09 +0200
commit98d2af9d73da56910c8bb6cb662fbc4d609a704a (patch)
tree46914250a980b9164b2d20cbeb08e126a86cf7ea
parent633012190baa0801efc7e3ab2f699778c5038d54 (diff)
downloadrtic-98d2af9d73da56910c8bb6cb662fbc4d609a704a.tar.gz
rtic-98d2af9d73da56910c8bb6cb662fbc4d609a704a.tar.zst
rtic-98d2af9d73da56910c8bb6cb662fbc4d609a704a.zip
Fixing tests
-rw-r--r--.github/workflows/build.yml3
-rw-r--r--Cargo.toml8
-rw-r--r--examples/big-struct-opt.rs23
-rw-r--r--examples/binds.rs22
-rw-r--r--examples/capacity.rs10
-rw-r--r--examples/cfg-whole-task.rs38
-rw-r--r--examples/cfg.rs65
-rw-r--r--examples/destructure.rs26
-rw-r--r--examples/double_schedule.rs10
-rw-r--r--examples/extern_binds.rs10
-rw-r--r--examples/extern_spawn.rs10
-rw-r--r--examples/generics.rs32
-rw-r--r--examples/hardware.rs22
-rw-r--r--examples/idle.rs20
-rw-r--r--examples/init.rs16
-rw-r--r--examples/lock.rs20
-rw-r--r--examples/message.rs20
-rw-r--r--examples/multilock.rs30
-rw-r--r--examples/not-sync.rs30
-rw-r--r--examples/only-shared-access.rs19
-rw-r--r--examples/periodic.rs10
-rw-r--r--examples/peripherals-taken.rs10
-rw-r--r--examples/pool.rs14
-rw-r--r--examples/preempt.rs10
-rw-r--r--examples/ramfunc.rs10
-rw-r--r--examples/resource-user-struct.rs26
-rw-r--r--examples/resource.rs25
-rw-r--r--examples/schedule.rs12
-rw-r--r--examples/shared.rs (renamed from examples/late.rs)26
-rw-r--r--examples/smallest.rs13
-rw-r--r--examples/spawn.rs10
-rw-r--r--examples/spawn2.rs10
-rw-r--r--examples/static.rs28
-rw-r--r--examples/t-binds.rs10
-rw-r--r--examples/t-cfg-resources.rs19
-rw-r--r--examples/t-cfg.rs50
-rw-r--r--examples/t-htask-main.rs10
-rw-r--r--examples/t-idle-main.rs10
-rw-r--r--examples/t-init-main.rs10
-rw-r--r--examples/t-late-not-send.rs18
-rw-r--r--examples/t-resource.rs62
-rw-r--r--examples/t-schedule-core-stable.rs21
-rw-r--r--examples/t-schedule.rs10
-rw-r--r--examples/t-spawn.rs10
-rw-r--r--examples/t-stask-main.rs10
-rw-r--r--examples/task-local-minimal.rs34
-rw-r--r--examples/task-local.rs87
-rw-r--r--examples/task.rs10
-rw-r--r--examples/task_named_main.rs10
-rw-r--r--examples/type-usage.rs11
-rw-r--r--examples/types.rs57
-rw-r--r--macros/src/codegen.rs1
-rw-r--r--macros/src/codegen/dispatchers.rs7
-rw-r--r--macros/src/codegen/hardware_tasks.rs8
-rw-r--r--macros/src/codegen/init.rs11
-rw-r--r--macros/src/codegen/local_resources.rs15
-rw-r--r--macros/src/codegen/local_resources_struct.rs10
-rw-r--r--macros/src/codegen/shared_resources_struct.rs2
-rw-r--r--macros/src/codegen/util.rs28
-rw-r--r--macros/src/tests/single.rs11
-rw-r--r--ui/exception-invalid.rs11
-rw-r--r--ui/exception-invalid.stderr8
-rw-r--r--ui/extern-interrupt-not-enough.rs11
-rw-r--r--ui/extern-interrupt-not-enough.stderr8
-rw-r--r--ui/extern-interrupt-used.rs11
-rw-r--r--ui/extern-interrupt-used.stderr8
-rw-r--r--ui/local-cfg-task-local-err.rs69
-rw-r--r--ui/local-cfg-task-local-err.stderr37
-rw-r--r--ui/local-err.rs83
-rw-r--r--ui/local-err.stderr60
-rw-r--r--ui/locals-cfg.rs50
-rw-r--r--ui/locals-cfg.stderr29
-rw-r--r--ui/resources-cfg.rs80
-rw-r--r--ui/resources-cfg.stderr119
-rw-r--r--ui/task-priority-too-high.rs10
75 files changed, 591 insertions, 1183 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 93e32545..5f9ad1ff 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -244,18 +244,15 @@ jobs:
resource
lock
multilock
- late
only-shared-access
task
message
capacity
- types
not-sync
generics
- cfg
pool
ramfunc
diff --git a/Cargo.toml b/Cargo.toml
index a138b515..a8903307 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -32,10 +32,6 @@ name = "schedule"
required-features = ["__v7"]
[[example]]
-name = "t-cfg"
-required-features = ["__v7"]
-
-[[example]]
name = "t-cfg-resources"
required-features = ["__min_r1_43"]
@@ -44,10 +40,6 @@ name = "t-schedule"
required-features = ["__v7"]
[[example]]
-name = "types"
-required-features = ["__v7"]
-
-[[example]]
name = "double_schedule"
required-features = ["__v7"]
diff --git a/examples/big-struct-opt.rs b/examples/big-struct-opt.rs
index e6a5c172..2d0cc83d 100644
--- a/examples/big-struct-opt.rs
+++ b/examples/big-struct-opt.rs
@@ -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) {}
}
diff --git a/examples/binds.rs b/examples/binds.rs
index 9cbe2994..0b30af65 100644
--- a/examples/binds.rs
+++ b/examples/binds.rs
@@ -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();
}
diff --git a/examples/capacity.rs b/examples/capacity.rs
index 06bd921e..ea1613f7 100644
--- a/examples/capacity.rs
+++ b/examples/capacity.rs
@@ -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)]
diff --git a/examples/cfg-whole-task.rs b/examples/cfg-whole-task.rs
index 47c3530e..3fbdb2d1 100644
--- a/examples/cfg-whole-task.rs
+++ b/examples/cfg-whole-task.rs
@@ -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;
// ..
}
diff --git a/examples/cfg.rs b/examples/cfg.rs
deleted file mode 100644
index 43c2593c..00000000
--- a/examples/cfg.rs
+++ /dev/null
@@ -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();
- }
-}
diff --git a/examples/destructure.rs b/examples/destructure.rs
index d085e4bf..984c9b8a 100644
--- a/examples/destructure.rs
+++ b/examples/destructure.rs
@@ -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();
}
diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs
index 9da57ae5..6f24297e 100644
--- a/examples/double_schedule.rs
+++ b/examples/double_schedule.rs
@@ -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]
diff --git a/examples/extern_binds.rs b/examples/extern_binds.rs
index 3c8786dd..ce4bc17e 100644
--- a/examples/extern_binds.rs
+++ b/examples/extern_binds.rs
@@ -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]
diff --git a/examples/extern_spawn.rs b/examples/extern_spawn.rs
index 275ac539..d035fe7f 100644
--- a/examples/extern_spawn.rs
+++ b/examples/extern_spawn.rs
@@ -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" {
diff --git a/examples/generics.rs b/examples/generics.rs
index eabfff7e..b2c59a08 100644
--- a/examples/generics.rs
+++ b/examples/generics.rs
@@ -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 = {})", *STATE).unwrap();
+ hprintln!("UART0(STATE = {})", *c.local.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 = {})", *STATE).unwrap();
+ hprintln!("UART1(STATE = {})", *c.local.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);
}
}
diff --git a/examples/hardware.rs b/examples/hardware.rs
index 3cf98807..5dff8222 100644
--- a/examples/hardware.rs
+++ b/examples/hardware.rs
@@ -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();
}
diff --git a/examples/idle.rs b/examples/idle.rs
index db03dc70..34c861b9 100644
--- a/examples/idle.rs
+++ b/examples/idle.rs
@@ -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();
diff --git a/examples/init.rs b/examples/init.rs
index 9de79581..97e3c513 100644
--- a/examples/init.rs
+++ b/examples/init.rs
@@ -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())
}
}
diff --git a/examples/lock.rs b/examples/lock.rs
index 75d47d24..aeadd295 100644
--- a/examples/lock.rs
+++ b/examples/lock.rs
@@ -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
diff --git a/examples/message.rs b/examples/message.rs
index 722e73a7..7318d4b7 100644
--- a/examples/message.rs
+++ b/examples/message.rs
@@ -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]
diff --git a/examples/multilock.rs b/examples/multilock.rs
index ad9d72ab..7d8d7d24 100644
--- a/examples/multilock.rs
+++ b/examples/multilock.rs
@@ -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| {
diff --git a/examples/not-sync.rs b/examples/not-sync.rs
index f01d4043..1510e504 100644
--- a/examples/not-sync.rs
+++ b/examples/not-sync.rs
@@ -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;
}
}
diff --git a/examples/only-shared-access.rs b/examples/only-shared-access.rs
index 2c6ad4c4..e3f1dbd3 100644
--- a/examples/only-shared-access.rs
+++ b/examples/only-shared-access.rs
@@ -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();
}
}
diff --git a/examples/periodic.rs b/examples/periodic.rs
index 01061c9f..b1868839 100644
--- a/examples/periodic.rs
+++ b/examples/periodic.rs
@@ -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]
diff --git a/examples/peripherals-taken.rs b/examples/peripherals-taken.rs
index 6b4a282b..cb90319e 100644
--- a/examples/peripherals-taken.rs
+++ b/examples/peripherals-taken.rs
@@ -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())
}
}
diff --git a/examples/pool.rs b/examples/pool.rs
index 44405b49..63be899e 100644
--- a/examples/pool.rs
+++ b/examples/pool.rs
@@ -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)]
diff --git a/examples/preempt.rs b/examples/preempt.rs
index 14b3a0a6..8d9f9ead 100644
--- a/examples/preempt.rs
+++ b/examples/preempt.rs
@@ -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)]
diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs
index d9c8143f..ecff8530 100644
--- a/examples/ramfunc.rs
+++ b/examples/ramfunc.rs
@@ -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)]
diff --git a/examples/resource-user-struct.rs b/examples/resource-user-struct.rs
index 6ad540b0..1ebaa59e 100644
--- a/examples/resource-user-struct.rs
+++ b/examples/resource-user-struct.rs
@@ -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
});
diff --git a/examples/resource.rs b/examples/resource.rs
index c8c57bf5..2c7dffe3 100644
--- a/examples/resource.rs
+++ b/examples/resource.rs
@@ -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
});
diff --git a/examples/schedule.rs b/examples/schedule.rs
index bb5119c2..f62f24a7 100644
--- a/examples/schedule.rs
+++ b/examples/schedule.rs
@@ -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]
diff --git a/examples/late.rs b/examples/shared.rs
index e65b6e69..c3fa07b9 100644
--- a/examples/late.rs
+++ b/examples/shared.rs
@@ -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());
}
}
diff --git a/examples/smallest.rs b/examples/smallest.rs
index b8cbf87e..6afcfbd4 100644
--- a/examples/smallest.rs
+++ b/examples/smallest.rs
@@ -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 {})
+ }
+}
diff --git a/examples/spawn.rs b/examples/spawn.rs
index 987ebf7d..bcb4fb23 100644
--- a/examples/spawn.rs
+++ b/examples/spawn.rs
@@ -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()]
diff --git a/examples/spawn2.rs b/examples/spawn2.rs
index be113f79..ff9516a6 100644
--- a/examples/spawn2.rs
+++ b/examples/spawn2.rs
@@ -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]
diff --git a/examples/static.rs b/examples/static.rs
index cbbc5399..f51c5f2d 100644
--- a/examples/static.rs
+++ b/examples/static.rs
@@ -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());
}
}
diff --git a/examples/t-binds.rs b/examples/t-binds.rs
index fbc89e88..2c405ea0 100644
--- a/examples/t-binds.rs
+++ b/examples/t-binds.rs
@@ -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
diff --git a/examples/t-cfg-resources.rs b/examples/t-cfg-resources.rs
index 1adcb905..3b06f0e0 100644
--- a/examples/t-cfg-resources.rs
+++ b/examples/t-cfg-resources.rs
@@ -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(),
)
}
diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs
deleted file mode 100644
index ef591c4d..00000000
--- a/examples/t-cfg.rs
+++ /dev/null
@@ -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) {}
-}
diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs
index 2d480d0b..39404322 100644
--- a/examples/t-htask-main.rs
+++ b/examples/t-htask-main.rs
@@ -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)]
diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs
index 891896fa..c649a973 100644
--- a/examples/t-idle-main.rs
+++ b/examples/t-idle-main.rs
@@ -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]
diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs
index b77a7df8..92717887 100644
--- a/examples/t-init-main.rs
+++ b/examples/t-init-main.rs
@@ -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())
}
}
diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs
index 579f8436..7408a1eb 100644
--- a/examples/t-late-not-send.rs
+++ b/examples/t-late-not-send.rs
@@ -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();
diff --git a/examples/t-resource.rs b/examples/t-resource.rs
index 6e83069d..27324910 100644
--- a/examples/t-resource.rs
+++ b/examples/t-resource.rs
@@ -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;
}
}
diff --git a/examples/t-schedule-core-stable.rs b/examples/t-schedule-core-stable.rs
deleted file mode 100644
index 98d42ce7..00000000
--- a/examples/t-schedule-core-stable.rs
+++ /dev/null
@@ -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) {}
-}
diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs
index d7051609..6708c689 100644
--- a/examples/t-schedule.rs
+++ b/examples/t-schedule.rs
@@ -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]
diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs
index ca5c61b2..0f98592e 100644
--- a/examples/t-spawn.rs
+++ b/examples/t-spawn.rs
@@ -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]
diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs
index cfc93425..ee5959de 100644
--- a/examples/t-stask-main.rs
+++ b/examples/t-stask-main.rs
@@ -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]
diff --git a/examples/task-local-minimal.rs b/examples/task-local-minimal.rs
deleted file mode 100644
index f83493c2..00000000
--- a/examples/task-local-minimal.rs
+++ /dev/null
@@ -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();
- }
- }
-}
diff --git a/examples/task-local.rs b/examples/task-local.rs
deleted file mode 100644
index 3020c3b3..00000000
--- a/examples/task-local.rs
+++ /dev/null
@@ -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();
- }
-}
diff --git a/examples/task.rs b/examples/task.rs
index 9d4492f2..bec7b1ab 100644
--- a/examples/task.rs
+++ b/examples/task.rs
@@ -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]
diff --git a/examples/task_named_main.rs b/examples/task_named_main.rs
index c2c4e62d..b030b5e7 100644
--- a/examples/task_named_main.rs
+++ b/examples/task_named_main.rs
@@ -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]
diff --git a/examples/type-usage.rs b/examples/type-usage.rs
index 9bb7eb8d..e5a088f0 100644
--- a/examples/type-usage.rs
+++ b/examples/type-usage.rs
@@ -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) {}
}
diff --git a/examples/types.rs b/examples/types.rs
deleted file mode 100644
index cdcf80c2..00000000
--- a/examples/types.rs
+++ /dev/null
@@ -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;
- }
-}
diff --git a/macros/src/codegen.rs b/macros/src/codegen.rs
index 9c1ae88c..6920031a 100644
--- a/macros/src/codegen.rs
+++ b/macros/src/codegen.rs
@@ -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![];
diff --git a/macros/src/codegen/dispatchers.rs b/macros/src/codegen/dispatchers.rs
index 1c311954..ac550036 100644
--- a/macros/src/codegen/dispatchers.rs
+++ b/macros/src/codegen/dispatchers.rs
@@ -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 => {
diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs
index c7f3e7d9..e6192e2c 100644
--- a/macros/src/codegen/hardware_tasks.rs
+++ b/macros/src/codegen/hardware_tasks.rs
@@ -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(
diff --git a/macros/src/codegen/init.rs b/macros/src/codegen/init.rs
index 1bea7b7e..b6d3f72e 100644
--- a/macros/src/codegen/init.rs
+++ b/macros/src/codegen/init.rs
@@ -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;
diff --git a/macros/src/codegen/local_resources.rs b/macros/src/codegen/local_resources.rs
index 70f75809..c5cddfb3 100644
--- a/macros/src/codegen/local_resources.rs
+++ b/macros/src/codegen/local_resources.rs
@@ -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())
}
diff --git a/macros/src/codegen/local_resources_struct.rs b/macros/src/codegen/local_resources_struct.rs
index 0283d526..4bd9e2a4 100644
--- a/macros/src/codegen/local_resources_struct.rs
+++ b/macros/src/codegen/local_resources_struct.rs
@@ -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)*
diff --git a/macros/src/codegen/shared_resources_struct.rs b/macros/src/codegen/shared_resources_struct.rs
index df7f38de..301bef73 100644
--- a/macros/src/codegen/shared_resources_struct.rs
+++ b/macros/src/codegen/shared_resources_struct.rs
@@ -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() {
diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs
index e3df2076..3b0b9e4f 100644
--- a/macros/src/codegen/util.rs
+++ b/macros/src/codegen/util.rs
@@ -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
diff --git a/macros/src/tests/single.rs b/macros/src/tests/single.rs
index 8c026e99..27118856 100644
--- a/macros/src/tests/single.rs
+++ b/macros/src/tests/single.rs
@@ -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) {}
diff --git a/ui/exception-invalid.rs b/ui/exception-invalid.rs
index 04d9bc75..d899443b 100644
--- a/ui/exception-invalid.rs
+++ b/ui/exception-invalid.rs
@@ -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) {}
}
diff --git a/ui/exception-invalid.stderr b/ui/exception-invalid.stderr
index 90213768..32123680 100644
--- a/ui/exception-invalid.stderr
+++ b/ui/exception-invalid.stderr
@@ -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) {}
+ | ^^^
diff --git a/ui/extern-interrupt-not-enough.rs b/ui/extern-interrupt-not-enough.rs
index f2624036..6e786347 100644
--- a/ui/extern-interrupt-not-enough.rs
+++ b/ui/extern-interrupt-not-enough.rs
@@ -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) {}
}
diff --git a/ui/extern-interrupt-not-enough.stderr b/ui/extern-interrupt-not-enough.stderr
index 14f8fe9c..a667c588 100644
--- a/ui/extern-interrupt-not-enough.stderr
+++ b/ui/extern-interrupt-not-enough.stderr
@@ -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) {}
+ | ^
diff --git a/ui/extern-interrupt-used.rs b/ui/extern-interrupt-used.rs
index 240e7363..a22b85f4 100644
--- a/ui/extern-interrupt-used.rs
+++ b/ui/extern-interrupt-used.rs
@@ -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) {}
}
diff --git a/ui/extern-interrupt-used.stderr b/ui/extern-interrupt-used.stderr
index b4d8d160..75657399 100644
--- a/ui/extern-interrupt-used.stderr
+++ b/ui/extern-interrupt-used.stderr
@@ -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)]
+ | ^^^^^
diff --git a/ui/local-cfg-task-local-err.rs b/ui/local-cfg-task-local-err.rs
deleted file mode 100644
index d4752edf..00000000
--- a/ui/local-cfg-task-local-err.rs
+++ /dev/null
@@ -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();
- }
-}
diff --git a/ui/local-cfg-task-local-err.stderr b/ui/local-cfg-task-local-err.stderr
deleted file mode 100644
index 73dfaeb6..00000000
--- a/ui/local-cfg-task-local-err.stderr
+++ /dev/null
@@ -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;
- | ^^^^^^^^^^^^^^^^^^^
diff --git a/ui/local-err.rs b/ui/local-err.rs
deleted file mode 100644
index 7ebfc069..00000000
--- a/ui/local-err.rs
+++ /dev/null
@@ -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();
- }
-}
diff --git a/ui/local-err.stderr b/ui/local-err.stderr
deleted file mode 100644
index 88369d8e..00000000
--- a/ui/local-err.stderr
+++ /dev/null
@@ -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;
- | ^^^^^^^^^^^^^^^^^^^
diff --git a/ui/locals-cfg.rs b/ui/locals-cfg.rs
deleted file mode 100644
index 170d3026..00000000
--- a/ui/locals-cfg.rs
+++ /dev/null
@@ -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;
- }
-}
diff --git a/ui/locals-cfg.stderr b/ui/locals-cfg.stderr
deleted file mode 100644
index 33a80754..00000000
--- a/ui/locals-cfg.stderr
+++ /dev/null
@@ -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
diff --git a/ui/resources-cfg.rs b/ui/resources-cfg.rs
deleted file mode 100644
index c802a46f..00000000
--- a/ui/resources-cfg.rs
+++ /dev/null
@@ -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;
- }
-}
diff --git a/ui/resources-cfg.stderr b/ui/resources-cfg.stderr
deleted file mode 100644
index 03612de0..00000000
--- a/ui/resources-cfg.stderr
+++ /dev/null
@@ -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__`
diff --git a/ui/task-priority-too-high.rs b/ui/task-priority-too-high.rs
index b1cbfa94..0d903d3a 100644
--- a/ui/task-priority-too-high.rs
+++ b/ui/task-priority-too-high.rs
@@ -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)]