aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2023-05-10 14:24:32 +0200
committerEmil Fresk <emil.fresk@gmail.com>2023-05-10 16:26:52 +0200
commit67d5ade4fdbb2fb4a1c13715e4829412f4007d75 (patch)
treed724871c3173736594811daa84abbd57b71bf105
parentcfac6d1d90f13f22bde849816919e42f4ecf9531 (diff)
Fix zero prio tasks when all async tasks have default (no) arguments
-rw-r--r--examples/rp2040_local_i2c_init/Cargo.toml2
-rw-r--r--examples/stm32f3_blinky/Cargo.toml2
-rw-r--r--rtic-macros/Cargo.toml2
-rw-r--r--rtic-macros/src/syntax/ast.rs2
-rw-r--r--rtic-macros/ui/task-no-prio.rs19
-rw-r--r--rtic-macros/ui/task-no-prio.stderr5
-rw-r--r--rtic/Cargo.toml4
-rw-r--r--rtic/examples/async-delay.rs9
-rw-r--r--rtic/examples/spawn_loop.rs3
-rw-r--r--rtic/ui/extern-interrupt-not-enough.rs2
10 files changed, 33 insertions, 17 deletions
diff --git a/examples/rp2040_local_i2c_init/Cargo.toml b/examples/rp2040_local_i2c_init/Cargo.toml
index 9737c99..2d004e1 100644
--- a/examples/rp2040_local_i2c_init/Cargo.toml
+++ b/examples/rp2040_local_i2c_init/Cargo.toml
@@ -10,7 +10,7 @@ edition = "2021"
[dependencies.rtic]
path = "../../rtic"
-version = "=2.0.0-alpha.1"
+version = "=2.0.0-alpha.2"
features = ["thumbv6-backend"]
[dependencies.rtic-monotonics]
diff --git a/examples/stm32f3_blinky/Cargo.toml b/examples/stm32f3_blinky/Cargo.toml
index 99f1009..be4d03d 100644
--- a/examples/stm32f3_blinky/Cargo.toml
+++ b/examples/stm32f3_blinky/Cargo.toml
@@ -9,7 +9,7 @@ version = "0.1.0"
[dependencies.rtic]
path = "../../rtic"
-version = "=2.0.0-alpha.1"
+version = "=2.0.0-alpha.2"
features = ["thumbv7-backend"]
[dependencies.rtic-monotonics]
diff --git a/rtic-macros/Cargo.toml b/rtic-macros/Cargo.toml
index 71358c0..f7e6c7b 100644
--- a/rtic-macros/Cargo.toml
+++ b/rtic-macros/Cargo.toml
@@ -22,7 +22,7 @@ name = "rtic-macros"
readme = "../README.md"
repository = "https://github.com/rtic-rs/rtic"
-version = "2.0.0-alpha.0"
+version = "2.0.0-alpha.2"
[lib]
proc-macro = true
diff --git a/rtic-macros/src/syntax/ast.rs b/rtic-macros/src/syntax/ast.rs
index d5510cb..3f4956c 100644
--- a/rtic-macros/src/syntax/ast.rs
+++ b/rtic-macros/src/syntax/ast.rs
@@ -242,7 +242,7 @@ pub struct SoftwareTaskArgs {
impl Default for SoftwareTaskArgs {
fn default() -> Self {
Self {
- priority: 1,
+ priority: 0,
local_resources: LocalResources::new(),
shared_resources: SharedResources::new(),
}
diff --git a/rtic-macros/ui/task-no-prio.rs b/rtic-macros/ui/task-no-prio.rs
new file mode 100644
index 0000000..8327777
--- /dev/null
+++ b/rtic-macros/ui/task-no-prio.rs
@@ -0,0 +1,19 @@
+#![no_main]
+
+#[rtic_macros::mock_app(device = mock)]
+mod app {
+ #[shared]
+ struct Shared {}
+
+ #[local]
+ struct Local {}
+
+ #[init]
+ fn init(_: init::Context) -> (Shared, Local) {}
+
+ #[idle]
+ fn idle(_: idle::Context) -> ! {}
+
+ #[task]
+ async fn task1(_: task1::Context) {}
+}
diff --git a/rtic-macros/ui/task-no-prio.stderr b/rtic-macros/ui/task-no-prio.stderr
new file mode 100644
index 0000000..4ff97ec
--- /dev/null
+++ b/rtic-macros/ui/task-no-prio.stderr
@@ -0,0 +1,5 @@
+error: Async task "task1" has priority 0, but `#[idle]` is defined. 0-priority async tasks are only allowed if there is no `#[idle]`.
+ --> ui/task-no-prio.rs:18:14
+ |
+18 | async fn task1(_: task1::Context) {}
+ | ^^^^^
diff --git a/rtic/Cargo.toml b/rtic/Cargo.toml
index f28c9a7..c2f3045 100644
--- a/rtic/Cargo.toml
+++ b/rtic/Cargo.toml
@@ -22,7 +22,7 @@ name = "rtic"
readme = "../README.md"
repository = "https://github.com/rtic-rs/rtic"
-version = "2.0.0-alpha.1"
+version = "2.0.0-alpha.2"
[package.metadata.docs.rs]
features = ["rtic-macros/test-template"]
@@ -36,7 +36,7 @@ bare-metal = "1.0.0"
#portable-atomic = { version = "0.3.19" }
atomic-polyfill = "1"
rtic-monotonics = { path = "../rtic-monotonics", version = "1.0.0-alpha.1", optional = true }
-rtic-macros = { path = "../rtic-macros", version = "2.0.0-alpha.0" }
+rtic-macros = { path = "../rtic-macros", version = "2.0.0-alpha.2" }
rtic-core = "1"
critical-section = "1"
diff --git a/rtic/examples/async-delay.rs b/rtic/examples/async-delay.rs
index cdffa62..98d67f9 100644
--- a/rtic/examples/async-delay.rs
+++ b/rtic/examples/async-delay.rs
@@ -34,15 +34,6 @@ mod app {
(Shared {}, Local {})
}
- #[idle]
- fn idle(_: idle::Context) -> ! {
- // debug::exit(debug::EXIT_SUCCESS);
- loop {
- // hprintln!("idle");
- cortex_m::asm::wfi(); // put the MCU in sleep mode until interrupt occurs
- }
- }
-
#[task]
async fn foo(_cx: foo::Context) {
hprintln!("hello from foo");
diff --git a/rtic/examples/spawn_loop.rs b/rtic/examples/spawn_loop.rs
index 9328a94..2da25d1 100644
--- a/rtic/examples/spawn_loop.rs
+++ b/rtic/examples/spawn_loop.rs
@@ -25,6 +25,7 @@ mod app {
(Shared {}, Local {})
}
+
#[idle]
fn idle(_: idle::Context) -> ! {
for _ in 0..3 {
@@ -35,7 +36,7 @@ mod app {
loop {}
}
- #[task]
+ #[task(priority = 1)]
async fn foo(_: foo::Context) {
hprintln!("foo");
}
diff --git a/rtic/ui/extern-interrupt-not-enough.rs b/rtic/ui/extern-interrupt-not-enough.rs
index 94c8ee1..74ae116 100644
--- a/rtic/ui/extern-interrupt-not-enough.rs
+++ b/rtic/ui/extern-interrupt-not-enough.rs
@@ -13,6 +13,6 @@ mod app {
(Shared {}, Local {})
}
- #[task]
+ #[task(priority = 1)]
async fn a(_: a::Context) {}
}