diff options
| author | sodo <[email protected]> | 2023-12-10 01:45:24 +0900 |
|---|---|---|
| committer | sodo <[email protected]> | 2023-12-10 01:45:24 +0900 |
| commit | 58d503a77da73204f097fae1f1a2a1ce2cf90600 (patch) | |
| tree | c7739f0342e2e0d243cf9bb652c2246b2499cb23 /embassy-executor-macros/src | |
| parent | 83138ce68e506692aabd825eae39016ddb8fd2c4 (diff) | |
add avr support
Diffstat (limited to 'embassy-executor-macros/src')
| -rw-r--r-- | embassy-executor-macros/src/lib.rs | 7 | ||||
| -rw-r--r-- | embassy-executor-macros/src/macros/main.rs | 14 |
2 files changed, 21 insertions, 0 deletions
diff --git a/embassy-executor-macros/src/lib.rs b/embassy-executor-macros/src/lib.rs index c9d58746a..5461fe04c 100644 --- a/embassy-executor-macros/src/lib.rs +++ b/embassy-executor-macros/src/lib.rs | |||
| @@ -62,6 +62,13 @@ pub fn task(args: TokenStream, item: TokenStream) -> TokenStream { | |||
| 62 | task::run(&args.meta, f).unwrap_or_else(|x| x).into() | 62 | task::run(&args.meta, f).unwrap_or_else(|x| x).into() |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | #[proc_macro_attribute] | ||
| 66 | pub fn main_avr(args: TokenStream, item: TokenStream) -> TokenStream { | ||
| 67 | let args = syn::parse_macro_input!(args as Args); | ||
| 68 | let f = syn::parse_macro_input!(item as syn::ItemFn); | ||
| 69 | main::run(&args.meta, f, main::avr()).unwrap_or_else(|x| x).into() | ||
| 70 | } | ||
| 71 | |||
| 65 | /// Creates a new `executor` instance and declares an application entry point for Cortex-M spawning the corresponding function body as an async task. | 72 | /// Creates a new `executor` instance and declares an application entry point for Cortex-M spawning the corresponding function body as an async task. |
| 66 | /// | 73 | /// |
| 67 | /// The following restrictions apply: | 74 | /// The following restrictions apply: |
diff --git a/embassy-executor-macros/src/macros/main.rs b/embassy-executor-macros/src/macros/main.rs index 3c0d58567..088e64d1c 100644 --- a/embassy-executor-macros/src/macros/main.rs +++ b/embassy-executor-macros/src/macros/main.rs | |||
| @@ -12,6 +12,20 @@ struct Args { | |||
| 12 | entry: Option<String>, | 12 | entry: Option<String>, |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | pub fn avr() -> TokenStream { | ||
| 16 | quote! { | ||
| 17 | #[avr_device::entry] | ||
| 18 | fn main() -> ! { | ||
| 19 | let mut executor = ::embassy_executor::Executor::new(); | ||
| 20 | let executor = unsafe { __make_static(&mut executor) }; | ||
| 21 | |||
| 22 | executor.run(|spawner| { | ||
| 23 | spawner.must_spawn(__embassy_main(spawner)); | ||
| 24 | }) | ||
| 25 | } | ||
| 26 | } | ||
| 27 | } | ||
| 28 | |||
| 15 | pub fn riscv(args: &[NestedMeta]) -> TokenStream { | 29 | pub fn riscv(args: &[NestedMeta]) -> TokenStream { |
| 16 | let maybe_entry = match Args::from_list(args) { | 30 | let maybe_entry = match Args::from_list(args) { |
| 17 | Ok(args) => args.entry, | 31 | Ok(args) => args.entry, |
