diff options
| -rwxr-xr-x | ci.sh | 4 | ||||
| -rw-r--r-- | embassy-executor/Cargo.toml | 8 | ||||
| -rw-r--r-- | embassy-executor/src/arch/avr.rs | 13 |
3 files changed, 19 insertions, 6 deletions
| @@ -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 |
| 211 | cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr | 211 | cargo 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 |
| 212 | cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr,integrated-timers | 212 | cargo 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 | ||
| 215 | rm out/tests/stm32wb55rg/wpan_mac | 215 | rm 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 | |||
| 36 | embassy-time = { version = "0.2", path = "../embassy-time", optional = true} | 36 | embassy-time = { version = "0.2", path = "../embassy-time", optional = true} |
| 37 | critical-section = "1.1" | 37 | critical-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 |
| 41 | portable-atomic = { version = "1.5", optional = true } | 41 | portable-atomic = { version = "1.5", optional = true } |
| 42 | 42 | ||
| 43 | |||
| 43 | # arch-cortex-m dependencies | 44 | # arch-cortex-m dependencies |
| 44 | cortex-m = { version = "0.7.6", optional = true } | 45 | cortex-m = { version = "0.7.6", optional = true } |
| 45 | 46 | ||
| @@ -47,6 +48,9 @@ cortex-m = { version = "0.7.6", optional = true } | |||
| 47 | wasm-bindgen = { version = "0.2.82", optional = true } | 48 | wasm-bindgen = { version = "0.2.82", optional = true } |
| 48 | js-sys = { version = "0.3", optional = true } | 49 | js-sys = { version = "0.3", optional = true } |
| 49 | 50 | ||
| 51 | # arch-avr dependencies | ||
| 52 | avr-device = { version = "0.5.3", optional = true } | ||
| 53 | |||
| 50 | [dev-dependencies] | 54 | [dev-dependencies] |
| 51 | critical-section = { version = "1.1", features = ["std"] } | 55 | critical-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 |
| 58 | arch-avr = ["_arch", "dep:portable-atomic"] | 62 | arch-avr = ["_arch", "dep:portable-atomic", "dep:avr-device"] |
| 59 | arch-std = ["_arch", "critical-section/std"] | 63 | arch-std = ["_arch", "critical-section/std"] |
| 60 | arch-cortex-m = ["_arch", "dep:cortex-m"] | 64 | arch-cortex-m = ["_arch", "dep:cortex-m"] |
| 61 | arch-riscv32 = ["_arch", "dep:portable-atomic"] | 65 | arch-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 | } |
