aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor
diff options
context:
space:
mode:
authorsodo <[email protected]>2024-01-02 01:37:00 +0900
committersodo <[email protected]>2024-01-02 13:34:22 +0900
commit6ee153a3e2eec284c0d9d87f31801265c0604f74 (patch)
tree8b801cbd15f9ad5052d5942c731e75736dc9d7eb /embassy-executor
parentb7cd7952c890f585ff876c622482534e5d58d4a4 (diff)
parent0be9b0599aaf2e425d76ec7852ff4b3535defddf (diff)
Merge remote-tracking branch 'origin'
Diffstat (limited to 'embassy-executor')
-rw-r--r--embassy-executor/Cargo.toml88
-rw-r--r--embassy-executor/README.md2
-rw-r--r--embassy-executor/gen_config.py6
-rw-r--r--embassy-executor/src/lib.rs3
-rw-r--r--embassy-executor/tests/test.rs14
5 files changed, 99 insertions, 14 deletions
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml
index c937194ce..25c2c6a1d 100644
--- a/embassy-executor/Cargo.toml
+++ b/embassy-executor/Cargo.toml
@@ -14,7 +14,7 @@ categories = [
14[package.metadata.embassy_docs] 14[package.metadata.embassy_docs]
15src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/" 15src_base = "https://github.com/embassy-rs/embassy/blob/embassy-executor-v$VERSION/embassy-executor/src/"
16src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/" 16src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-executor/src/"
17features = ["nightly", "defmt"] 17features = ["defmt"]
18flavors = [ 18flavors = [
19 { name = "std", target = "x86_64-unknown-linux-gnu", features = ["arch-std", "executor-thread"] }, 19 { name = "std", target = "x86_64-unknown-linux-gnu", features = ["arch-std", "executor-thread"] },
20 { name = "wasm", target = "wasm32-unknown-unknown", features = ["arch-wasm", "executor-thread"] }, 20 { name = "wasm", target = "wasm32-unknown-unknown", features = ["arch-wasm", "executor-thread"] },
@@ -25,7 +25,7 @@ flavors = [
25[package.metadata.docs.rs] 25[package.metadata.docs.rs]
26default-target = "thumbv7em-none-eabi" 26default-target = "thumbv7em-none-eabi"
27targets = ["thumbv7em-none-eabi"] 27targets = ["thumbv7em-none-eabi"]
28features = ["nightly", "defmt", "arch-cortex-m", "executor-thread", "executor-interrupt"] 28features = ["defmt", "arch-cortex-m", "executor-thread", "executor-interrupt"]
29 29
30[dependencies] 30[dependencies]
31defmt = { version = "0.3", optional = true } 31defmt = { version = "0.3", optional = true }
@@ -36,11 +36,12 @@ embassy-executor-macros = { version = "0.4.0", path = "../embassy-executor-macro
36embassy-time = { version = "0.2", path = "../embassy-time", optional = true} 36embassy-time = { version = "0.2", path = "../embassy-time", optional = true}
37critical-section = "1.1" 37critical-section = "1.1"
38 38
39document-features = "0.2.7"
40
39# needed for riscv and avr 41# needed for riscv and avr
40# remove when https://github.com/rust-lang/rust/pull/114499 is merged 42# remove when https://github.com/rust-lang/rust/pull/114499 is merged
41portable-atomic = { version = "1.5", optional = true } 43portable-atomic = { version = "1.5", optional = true }
42 44
43
44# arch-cortex-m dependencies 45# arch-cortex-m dependencies
45cortex-m = { version = "0.7.6", optional = true } 46cortex-m = { version = "0.7.6", optional = true }
46 47
@@ -57,67 +58,128 @@ critical-section = { version = "1.1", features = ["std"] }
57 58
58[features] 59[features]
59 60
60# Architecture 61## Enable nightly-only features
62nightly = ["embassy-executor-macros/nightly"]
63
64# Enables turbo wakers, which requires patching core. Not surfaced in the docs by default due to
65# being an complicated advanced and undocumented feature.
66# See: https://github.com/embassy-rs/embassy/pull/1263
67turbowakers = []
68
69## Use timers from `embassy-time`
70integrated-timers = ["dep:embassy-time"]
71
72#! ### Architecture
61_arch = [] # some arch was picked 73_arch = [] # some arch was picked
62arch-avr = ["_arch", "dep:portable-atomic", "dep:avr-device"] 74## std
63arch-std = ["_arch", "critical-section/std"] 75arch-std = ["_arch", "critical-section/std"]
76## Cortex-M
64arch-cortex-m = ["_arch", "dep:cortex-m"] 77arch-cortex-m = ["_arch", "dep:cortex-m"]
78## RISC-V 32
65arch-riscv32 = ["_arch", "dep:portable-atomic"] 79arch-riscv32 = ["_arch", "dep:portable-atomic"]
80## WASM
66arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"] 81arch-wasm = ["_arch", "dep:wasm-bindgen", "dep:js-sys"]
82## AVR
83arch-avr = ["_arch", "dep:portable-atomic", "dep:avr-device"]
84
85#! ### Executor
67 86
68# Enable the thread-mode executor (using WFE/SEV in Cortex-M, WFI in other embedded archs) 87## Enable the thread-mode executor (using WFE/SEV in Cortex-M, WFI in other embedded archs)
69executor-thread = [] 88executor-thread = []
70# Enable the interrupt-mode executor (available in Cortex-M only) 89## Enable the interrupt-mode executor (available in Cortex-M only)
71executor-interrupt = [] 90executor-interrupt = []
72 91
73# Enable nightly-only features 92#! ### Task Arena Size
74nightly = ["embassy-executor-macros/nightly"] 93#! Sets the [task arena](#task-arena) size. Necessary if you’re not using `nightly`.
75 94#!
76turbowakers = [] 95#! <details>
77 96#! <summary>Preconfigured Task Arena Sizes:</summary>
78integrated-timers = ["dep:embassy-time"] 97#! <!-- rustdoc requires the following blank line for the feature list to render correctly! -->
98#!
79 99
80# BEGIN AUTOGENERATED CONFIG FEATURES 100# BEGIN AUTOGENERATED CONFIG FEATURES
81# Generated by gen_config.py. DO NOT EDIT. 101# Generated by gen_config.py. DO NOT EDIT.
102## 64
82task-arena-size-64 = [] 103task-arena-size-64 = []
104## 128
83task-arena-size-128 = [] 105task-arena-size-128 = []
106## 192
84task-arena-size-192 = [] 107task-arena-size-192 = []
108## 256
85task-arena-size-256 = [] 109task-arena-size-256 = []
110## 320
86task-arena-size-320 = [] 111task-arena-size-320 = []
112## 384
87task-arena-size-384 = [] 113task-arena-size-384 = []
114## 512
88task-arena-size-512 = [] 115task-arena-size-512 = []
116## 640
89task-arena-size-640 = [] 117task-arena-size-640 = []
118## 768
90task-arena-size-768 = [] 119task-arena-size-768 = []
120## 1024
91task-arena-size-1024 = [] 121task-arena-size-1024 = []
122## 1280
92task-arena-size-1280 = [] 123task-arena-size-1280 = []
124## 1536
93task-arena-size-1536 = [] 125task-arena-size-1536 = []
126## 2048
94task-arena-size-2048 = [] 127task-arena-size-2048 = []
128## 2560
95task-arena-size-2560 = [] 129task-arena-size-2560 = []
130## 3072
96task-arena-size-3072 = [] 131task-arena-size-3072 = []
132## 4096 (default)
97task-arena-size-4096 = [] # Default 133task-arena-size-4096 = [] # Default
134## 5120
98task-arena-size-5120 = [] 135task-arena-size-5120 = []
136## 6144
99task-arena-size-6144 = [] 137task-arena-size-6144 = []
138## 8192
100task-arena-size-8192 = [] 139task-arena-size-8192 = []
140## 10240
101task-arena-size-10240 = [] 141task-arena-size-10240 = []
142## 12288
102task-arena-size-12288 = [] 143task-arena-size-12288 = []
144## 16384
103task-arena-size-16384 = [] 145task-arena-size-16384 = []
146## 20480
104task-arena-size-20480 = [] 147task-arena-size-20480 = []
148## 24576
105task-arena-size-24576 = [] 149task-arena-size-24576 = []
150## 32768
106task-arena-size-32768 = [] 151task-arena-size-32768 = []
152## 40960
107task-arena-size-40960 = [] 153task-arena-size-40960 = []
154## 49152
108task-arena-size-49152 = [] 155task-arena-size-49152 = []
156## 65536
109task-arena-size-65536 = [] 157task-arena-size-65536 = []
158## 81920
110task-arena-size-81920 = [] 159task-arena-size-81920 = []
160## 98304
111task-arena-size-98304 = [] 161task-arena-size-98304 = []
162## 131072
112task-arena-size-131072 = [] 163task-arena-size-131072 = []
164## 163840
113task-arena-size-163840 = [] 165task-arena-size-163840 = []
166## 196608
114task-arena-size-196608 = [] 167task-arena-size-196608 = []
168## 262144
115task-arena-size-262144 = [] 169task-arena-size-262144 = []
170## 327680
116task-arena-size-327680 = [] 171task-arena-size-327680 = []
172## 393216
117task-arena-size-393216 = [] 173task-arena-size-393216 = []
174## 524288
118task-arena-size-524288 = [] 175task-arena-size-524288 = []
176## 655360
119task-arena-size-655360 = [] 177task-arena-size-655360 = []
178## 786432
120task-arena-size-786432 = [] 179task-arena-size-786432 = []
180## 1048576
121task-arena-size-1048576 = [] 181task-arena-size-1048576 = []
122 182
123# END AUTOGENERATED CONFIG FEATURES 183# END AUTOGENERATED CONFIG FEATURES
184
185#! </details> \ No newline at end of file
diff --git a/embassy-executor/README.md b/embassy-executor/README.md
index 80ecfc71a..aa9d59907 100644
--- a/embassy-executor/README.md
+++ b/embassy-executor/README.md
@@ -22,7 +22,7 @@ Tasks are allocated from the arena when spawned for the first time. If the task
22The arena size can be configured in two ways: 22The arena size can be configured in two ways:
23 23
24- Via Cargo features: enable a Cargo feature like `task-arena-size-8192`. Only a selection of values 24- Via Cargo features: enable a Cargo feature like `task-arena-size-8192`. Only a selection of values
25 is available, check `Cargo.toml` for the list. 25 is available, see [Task Area Sizes](#task-arena-size) for reference.
26- Via environment variables at build time: set the variable named `EMBASSY_EXECUTOR_TASK_ARENA_SIZE`. For example 26- Via environment variables at build time: set the variable named `EMBASSY_EXECUTOR_TASK_ARENA_SIZE`. For example
27 `EMBASSY_EXECUTOR_TASK_ARENA_SIZE=4321 cargo build`. You can also set them in the `[env]` section of `.cargo/config.toml`. 27 `EMBASSY_EXECUTOR_TASK_ARENA_SIZE=4321 cargo build`. You can also set them in the `[env]` section of `.cargo/config.toml`.
28 Any value can be set, unlike with Cargo features. 28 Any value can be set, unlike with Cargo features.
diff --git a/embassy-executor/gen_config.py b/embassy-executor/gen_config.py
index e427d29f4..cf32bd530 100644
--- a/embassy-executor/gen_config.py
+++ b/embassy-executor/gen_config.py
@@ -45,6 +45,12 @@ things = ""
45for f in features: 45for f in features:
46 name = f["name"].replace("_", "-") 46 name = f["name"].replace("_", "-")
47 for val in f["vals"]: 47 for val in f["vals"]:
48 things += f"## {val}"
49 if val == f["default"]:
50 things += " (default)\n"
51 else:
52 things += "\n"
53
48 things += f"{name}-{val} = []" 54 things += f"{name}-{val} = []"
49 if val == f["default"]: 55 if val == f["default"]:
50 things += " # Default" 56 things += " # Default"
diff --git a/embassy-executor/src/lib.rs b/embassy-executor/src/lib.rs
index 834ebf16a..6a2e493a2 100644
--- a/embassy-executor/src/lib.rs
+++ b/embassy-executor/src/lib.rs
@@ -3,6 +3,9 @@
3#![doc = include_str!("../README.md")] 3#![doc = include_str!("../README.md")]
4#![warn(missing_docs)] 4#![warn(missing_docs)]
5 5
6//! ## Feature flags
7#![doc = document_features::document_features!(feature_label = r#"<span class="stab portability"><code>{feature}</code></span>"#)]
8
6// This mod MUST go first, so that the others see its macros. 9// This mod MUST go first, so that the others see its macros.
7pub(crate) mod fmt; 10pub(crate) mod fmt;
8 11
diff --git a/embassy-executor/tests/test.rs b/embassy-executor/tests/test.rs
index 0dbd391e8..2c2441dd5 100644
--- a/embassy-executor/tests/test.rs
+++ b/embassy-executor/tests/test.rs
@@ -135,3 +135,17 @@ fn executor_task_self_wake_twice() {
135 ] 135 ]
136 ) 136 )
137} 137}
138
139#[test]
140fn executor_task_cfg_args() {
141 // simulate cfg'ing away argument c
142 #[task]
143 async fn task1(a: u32, b: u32, #[cfg(any())] c: u32) {
144 let (_, _) = (a, b);
145 }
146
147 #[task]
148 async fn task2(a: u32, b: u32, #[cfg(all())] c: u32) {
149 let (_, _, _) = (a, b, c);
150 }
151}