mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 16:23:10 +00:00
avr: support sleep
This commit is contained in:
parent
172ed52128
commit
b7cd7952c8
4
ci.sh
4
ci.sh
@ -208,8 +208,8 @@ cargo batch \
|
|||||||
$BUILD_EXTRA
|
$BUILD_EXTRA
|
||||||
|
|
||||||
# walkaround: "-Z" option not working on cargo batch
|
# walkaround: "-Z" option not working on cargo batch
|
||||||
cargo build --release --manifest-path embassy-executor/Cargo.toml --target avr-unknown-gnu-atmega328 -Z build-std=core,alloc --features nightly,arch-avr
|
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
|
||||||
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
|
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
|
||||||
|
|
||||||
|
|
||||||
rm out/tests/stm32wb55rg/wpan_mac
|
rm out/tests/stm32wb55rg/wpan_mac
|
||||||
|
@ -36,10 +36,11 @@ embassy-executor-macros = { version = "0.4.0", path = "../embassy-executor-macro
|
|||||||
embassy-time = { version = "0.2", path = "../embassy-time", optional = true}
|
embassy-time = { version = "0.2", path = "../embassy-time", optional = true}
|
||||||
critical-section = "1.1"
|
critical-section = "1.1"
|
||||||
|
|
||||||
# needed for riscv
|
# needed for riscv and avr
|
||||||
# remove when https://github.com/rust-lang/rust/pull/114499 is merged
|
# remove when https://github.com/rust-lang/rust/pull/114499 is merged
|
||||||
portable-atomic = { version = "1.5", optional = true }
|
portable-atomic = { version = "1.5", optional = true }
|
||||||
|
|
||||||
|
|
||||||
# arch-cortex-m dependencies
|
# arch-cortex-m dependencies
|
||||||
cortex-m = { version = "0.7.6", optional = true }
|
cortex-m = { version = "0.7.6", optional = true }
|
||||||
|
|
||||||
@ -47,6 +48,9 @@ cortex-m = { version = "0.7.6", optional = true }
|
|||||||
wasm-bindgen = { version = "0.2.82", optional = true }
|
wasm-bindgen = { version = "0.2.82", optional = true }
|
||||||
js-sys = { version = "0.3", optional = true }
|
js-sys = { version = "0.3", optional = true }
|
||||||
|
|
||||||
|
# arch-avr dependencies
|
||||||
|
avr-device = { version = "0.5.3", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
critical-section = { version = "1.1", features = ["std"] }
|
critical-section = { version = "1.1", features = ["std"] }
|
||||||
|
|
||||||
@ -55,7 +59,7 @@ critical-section = { version = "1.1", features = ["std"] }
|
|||||||
|
|
||||||
# Architecture
|
# Architecture
|
||||||
_arch = [] # some arch was picked
|
_arch = [] # some arch was picked
|
||||||
arch-avr = ["_arch", "dep:portable-atomic"]
|
arch-avr = ["_arch", "dep:portable-atomic", "dep:avr-device"]
|
||||||
arch-std = ["_arch", "critical-section/std"]
|
arch-std = ["_arch", "critical-section/std"]
|
||||||
arch-cortex-m = ["_arch", "dep:cortex-m"]
|
arch-cortex-m = ["_arch", "dep:cortex-m"]
|
||||||
arch-riscv32 = ["_arch", "dep:portable-atomic"]
|
arch-riscv32 = ["_arch", "dep:portable-atomic"]
|
||||||
|
@ -8,11 +8,16 @@ mod thread {
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
|
|
||||||
pub use embassy_executor_macros::main_avr as main;
|
pub use embassy_executor_macros::main_avr as main;
|
||||||
|
use portable_atomic::{AtomicBool, Ordering};
|
||||||
|
|
||||||
use crate::{raw, Spawner};
|
use crate::{raw, Spawner};
|
||||||
|
|
||||||
|
static SIGNAL_WORK_THREAD_MODE: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
#[export_name = "__pender"]
|
#[export_name = "__pender"]
|
||||||
fn __pender(_context: *mut ()) {}
|
fn __pender(_context: *mut ()) {
|
||||||
|
SIGNAL_WORK_THREAD_MODE.store(true, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
|
||||||
/// avr Executor
|
/// avr Executor
|
||||||
pub struct Executor {
|
pub struct Executor {
|
||||||
@ -52,7 +57,11 @@ mod thread {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.inner.poll();
|
if SIGNAL_WORK_THREAD_MODE.swap(false, Ordering::SeqCst) {
|
||||||
|
self.inner.poll();
|
||||||
|
} else {
|
||||||
|
avr_device::asm::sleep();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user