aboutsummaryrefslogtreecommitdiff
path: root/embassy-macros
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-11-23 09:24:11 +0000
committerGitHub <[email protected]>2022-11-23 09:24:11 +0000
commit2fa2c1a6fe9c79f11f7382a63ba6a13fe1bae1be (patch)
treefd4c3022a35c22074d9e68d6edfb3bc651c6406a /embassy-macros
parent83b199a8744ddbba93b929f59606f0518c6f9ce1 (diff)
parent4943dec1a7ea52dc92c1e58f3b7f5860d79d192c (diff)
Merge #1054
1054: riscv fixes r=lulf a=swolix With these changes I can run embassy on our RISC-V processor, please consider merging this, feedback is very welcome. I don't fully understand the code in the executor, but I have implemented a critical section by globally disabling interrupts, which means the wfi inside the critical section will hang the whole thing. Co-authored-by: Sijmen Woutersen <[email protected]>
Diffstat (limited to 'embassy-macros')
-rw-r--r--embassy-macros/Cargo.toml1
-rw-r--r--embassy-macros/src/macros/main.rs15
2 files changed, 14 insertions, 2 deletions
diff --git a/embassy-macros/Cargo.toml b/embassy-macros/Cargo.toml
index 98e4d1c70..9b83771c8 100644
--- a/embassy-macros/Cargo.toml
+++ b/embassy-macros/Cargo.toml
@@ -23,6 +23,7 @@ proc-macro = true
23[features] 23[features]
24std = [] 24std = []
25wasm = [] 25wasm = []
26riscv = []
26 27
27# Enabling this cause interrupt::take! to require embassy-executor 28# Enabling this cause interrupt::take! to require embassy-executor
28rtos-trace-interrupt = [] 29rtos-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 })