aboutsummaryrefslogtreecommitdiff
path: root/embassy-executor/src
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 /embassy-executor/src
parent172ed52128e0da519c13b7a354aeb98c492be3c3 (diff)
avr: support sleep
Diffstat (limited to 'embassy-executor/src')
-rw-r--r--embassy-executor/src/arch/avr.rs13
1 files changed, 11 insertions, 2 deletions
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 }