diff options
Diffstat (limited to 'macros/src/codegen/shared_resources.rs')
-rw-r--r-- | macros/src/codegen/shared_resources.rs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/macros/src/codegen/shared_resources.rs b/macros/src/codegen/shared_resources.rs index b27c827c..fc3184cc 100644 --- a/macros/src/codegen/shared_resources.rs +++ b/macros/src/codegen/shared_resources.rs @@ -104,5 +104,62 @@ pub fn codegen( }) }; + let manual = "Manual Codegen".to_string(); + + let to_gen = quote! { + + pub struct __rtic_internal_fooShared { + a: &'static mut u32, + b: &'static mut i64, + } + + + impl __rtic_internal_fooShared { + #[inline(always)] + pub unsafe fn new() -> Self { + __rtic_internal_fooShared { + a: &mut *__rtic_internal_shared_resource_a + .get_mut_unchecked() + .as_mut_ptr(), + b: &mut *__rtic_internal_shared_resource_b + .get_mut_unchecked() + .as_mut_ptr(), + } + } + } + + #[doc = #manual] + impl<'a> __rtic_internal_fooSharedResources<'a> { + #[inline(always)] + pub unsafe fn priority(&self) -> &rtic::export::Priority { + self.priority + } + } + + #[doc = #manual] + impl<'a> rtic::Mutex for __rtic_internal_fooSharedResources<'a> { + type T = __rtic_internal_fooShared; + #[inline(always)] + fn lock<RTIC_INTERNAL_R>( + &mut self, + f: impl FnOnce(&mut __rtic_internal_fooShared) -> RTIC_INTERNAL_R, + ) -> RTIC_INTERNAL_R { + /// Priority ceiling + const CEILING: u8 = 1u8; + unsafe { + rtic::export::lock( + &mut __rtic_internal_fooShared::new(), + self.priority(), + CEILING, + lm3s6965::NVIC_PRIO_BITS, + f, + ) + } + } + } + }; + + mod_app.push(to_gen); + (mod_app, mod_resources) } |