aboutsummaryrefslogtreecommitdiff
path: root/embassy-macros
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 /embassy-macros
parent059610a8de49ff2d38311f343d3d1a6f8d90a720 (diff)
riscv support
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 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 })