aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSijmen Woutersen <[email protected]>2022-09-25 20:10:11 +0200
committerSijmen Woutersen <[email protected]>2022-11-10 17:39:41 +0100
commit6e1120e17e384a04cd3aef58a1467a4a0a862ba5 (patch)
tree557458df0822437844cd767f38c47ef0ce423aa0
parent059610a8de49ff2d38311f343d3d1a6f8d90a720 (diff)
riscv support
-rw-r--r--embassy-executor/Cargo.toml1
-rw-r--r--embassy-executor/src/arch/riscv32.rs15
-rw-r--r--embassy-macros/Cargo.toml1
-rw-r--r--embassy-macros/src/macros/main.rs15
4 files changed, 16 insertions, 16 deletions
diff --git a/embassy-executor/Cargo.toml b/embassy-executor/Cargo.toml
index d0f51646d..e6b4c596f 100644
--- a/embassy-executor/Cargo.toml
+++ b/embassy-executor/Cargo.toml
@@ -25,6 +25,7 @@ flavors = [
25default = [] 25default = []
26std = ["embassy-macros/std", "critical-section/std"] 26std = ["embassy-macros/std", "critical-section/std"]
27wasm = ["dep:wasm-bindgen", "dep:js-sys", "embassy-macros/wasm"] 27wasm = ["dep:wasm-bindgen", "dep:js-sys", "embassy-macros/wasm"]
28riscv = ["embassy-macros/riscv"]
28 29
29# Enable nightly-only features 30# Enable nightly-only features
30nightly = [] 31nightly = []
diff --git a/embassy-executor/src/arch/riscv32.rs b/embassy-executor/src/arch/riscv32.rs
index 2a4b006da..e095c0ee0 100644
--- a/embassy-executor/src/arch/riscv32.rs
+++ b/embassy-executor/src/arch/riscv32.rs
@@ -54,20 +54,7 @@ impl Executor {
54 loop { 54 loop {
55 unsafe { 55 unsafe {
56 self.inner.poll(); 56 self.inner.poll();
57 // we do not care about race conditions between the load and store operations, interrupts 57 core::arch::asm!("wfi");
58 //will only set this value to true.
59 critical_section::with(|_| {
60 // if there is work to do, loop back to polling
61 // TODO can we relax this?
62 if SIGNAL_WORK_THREAD_MODE.load(Ordering::SeqCst) {
63 SIGNAL_WORK_THREAD_MODE.store(false, Ordering::SeqCst);
64 }
65 // if not, wait for interrupt
66 else {
67 core::arch::asm!("wfi");
68 }
69 });
70 // if an interrupt occurred while waiting, it will be serviced here
71 } 58 }
72 } 59 }
73 } 60 }
diff --git a/embassy-macros/Cargo.toml b/embassy-macros/Cargo.toml
index 91d5ec8a3..c5ed3b5da 100644
--- a/embassy-macros/Cargo.toml
+++ b/embassy-macros/Cargo.toml
@@ -16,6 +16,7 @@ proc-macro = true
16[features] 16[features]
17std = [] 17std = []
18wasm = [] 18wasm = []
19riscv = []
19 20
20# Enabling this cause interrupt::take! to require embassy-executor 21# Enabling this cause interrupt::take! to require embassy-executor
21rtos-trace-interrupt = [] 22rtos-trace-interrupt = []
diff --git a/embassy-macros/src/macros/main.rs b/embassy-macros/src/macros/main.rs
index afe9bd3e2..54806847c 100644
--- a/embassy-macros/src/macros/main.rs
+++ b/embassy-macros/src/macros/main.rs
@@ -45,7 +45,7 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
45 } 45 }
46 }; 46 };
47 47
48 #[cfg(all(feature = "std", not(feature = "wasm")))] 48 #[cfg(all(feature = "std", not(feature = "wasm"), not(feature = "riscv")))]
49 let main = quote! { 49 let main = quote! {
50 fn main() -> ! { 50 fn main() -> ! {
51 let mut executor = ::embassy_executor::Executor::new(); 51 let mut executor = ::embassy_executor::Executor::new();
@@ -57,13 +57,24 @@ pub fn run(args: syn::AttributeArgs, f: syn::ItemFn) -> Result<TokenStream, Toke
57 } 57 }
58 }; 58 };
59 59
60 #[cfg(all(not(feature = "std"), not(feature = "wasm")))] 60 #[cfg(all(not(feature = "std"), not(feature = "wasm"), not(feature = "riscv")))]
61 let main = quote! { 61 let main = quote! {
62 #[cortex_m_rt::entry] 62 #[cortex_m_rt::entry]
63 fn main() -> ! { 63 fn main() -> ! {
64 let mut executor = ::embassy_executor::Executor::new(); 64 let mut executor = ::embassy_executor::Executor::new();
65 let executor = unsafe { __make_static(&mut executor) }; 65 let executor = unsafe { __make_static(&mut executor) };
66 executor.run(|spawner| {
67 spawner.must_spawn(__embassy_main(spawner));
68 })
69 }
70 };
66 71
72 #[cfg(all(not(feature = "std"), not(feature = "wasm"), feature = "riscv"))]
73 let main = quote! {
74 #[riscv_rt::entry]
75 fn main() -> ! {
76 let mut executor = ::embassy_executor::Executor::new();
77 let executor = unsafe { __make_static(&mut executor) };
67 executor.run(|spawner| { 78 executor.run(|spawner| {
68 spawner.must_spawn(__embassy_main(spawner)); 79 spawner.must_spawn(__embassy_main(spawner));
69 }) 80 })