aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsodo <[email protected]>2024-01-01 21:18:30 +0900
committersodo <[email protected]>2024-01-01 21:23:57 +0900
commitb7cd7952c890f585ff876c622482534e5d58d4a4 (patch)
tree0e5ea4766ed76c0d6ca5de5507cb3ae0995fca86
parent172ed52128e0da519c13b7a354aeb98c492be3c3 (diff)
avr: support sleep
-rwxr-xr-xci.sh4
-rw-r--r--embassy-executor/Cargo.toml8
-rw-r--r--embassy-executor/src/arch/avr.rs13
3 files changed, 19 insertions, 6 deletions
diff --git a/ci.sh b/ci.sh
index a5ddda3a1..a804647e1 100755
--- a/ci.sh
+++ b/ci.sh
@@ -208,8 +208,8 @@ cargo batch \
208 $BUILD_EXTRA 208 $BUILD_EXTRA
209 209
210# walkaround: "-Z" option not working on cargo batch 210# walkaround: "-Z" option not working on cargo batch
211cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr 211cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr,avr-device/atmega328p
212cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr,integrated-timers 212cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr,integrated-timers,avr-device/atmega328p
213 213
214 214
215rm out/tests/stm32wb55rg/wpan_mac 215rm out/tests/stm32wb55rg/wpan_mac
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml
index ade37913b..c937194ce 100644
--- a/embassy-executor/Cargo.toml
+++ b/embassy-executor/Cargo.toml
@@ -36,10 +36,11 @@ 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
39# needed for riscv 39# needed for riscv and avr
40# remove when https://github.com/rust-lang/rust/pull/114499 is merged 40# remove when https://github.com/rust-lang/rust/pull/114499 is merged
41portable-atomic = { version = "1.5", optional = true } 41portable-atomic = { version = "1.5", optional = true }
42 42
43
43# arch-cortex-m dependencies 44# arch-cortex-m dependencies
44cortex-m = { version = "0.7.6", optional = true } 45cortex-m = { version = "0.7.6", optional = true }
45 46
@@ -47,6 +48,9 @@ cortex-m = { version = "0.7.6", optional = true }
47wasm-bindgen = { version = "0.2.82", optional = true } 48wasm-bindgen = { version = "0.2.82", optional = true }
48js-sys = { version = "0.3", optional = true } 49js-sys = { version = "0.3", optional = true }
49 50
51# arch-avr dependencies
52avr-device = { version = "0.5.3", optional = true }
53
50[dev-dependencies] 54[dev-dependencies]
51critical-section = { version = "1.1", features = ["std"] } 55critical-section = { version = "1.1", features = ["std"] }
52 56
@@ -55,7 +59,7 @@ critical-section = { version = "1.1", features = ["std"] }
55 59
56# Architecture 60# Architecture
57_arch = [] # some arch was picked 61_arch = [] # some arch was picked
58arch-avr = ["_arch", "dep:portable-atomic"] 62arch-avr = ["_arch", "dep:portable-atomic", "dep:avr-device"]
59arch-std = ["_arch", "critical-section/std"] 63arch-std = ["_arch", "critical-section/std"]
60arch-cortex-m = ["_arch", "dep:cortex-m"] 64arch-cortex-m = ["_arch", "dep:cortex-m"]
61arch-riscv32 = ["_arch", "dep:portable-atomic"] 65arch-riscv32 = ["_arch", "dep:portable-atomic"]
diff --git a/embassy-executor/src/arch/avr.rs b/embassy-executor/src/arch/avr.rs
index 2c715f297..fa6afe762 100644
--- a/embassy-executor/src/arch/avr.rs
+++ b/embassy-executor/src/arch/avr.rs
@@ -8,11 +8,16 @@ mod thread {
8 use core::marker::PhantomData; 8 use core::marker::PhantomData;
9 9
10 pub use embassy_executor_macros::main_avr as main; 10 pub use embassy_executor_macros::main_avr as main;
11 use portable_atomic::{AtomicBool, Ordering};
11 12
12 use crate::{raw, Spawner}; 13 use crate::{raw, Spawner};
13 14
15 static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false);
16
14 #[export_name = "__pender"] 17 #[export_name = "__pender"]
15 fn __pender(_context: *mut ()) {} 18 fn __pender(_context: *mut ()) {
19 SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst);
20 }
16 21
17 /// avr Executor 22 /// avr Executor
18 pub struct Executor { 23 pub struct Executor {
@@ -52,7 +57,11 @@ mod thread {
52 57
53 loop { 58 loop {
54 unsafe { 59 unsafe {
55 self.inner.poll(); 60 if SIGNAL_WORK_THREAD_MODE.swap(false, Ordering::SeqCst) {
61 self.inner.poll();
62 } else {
63 avr_device::asm::sleep();
64 }
56 } 65 }
57 } 66 }
58 } 67 }