diff options
author | 2021-10-18 16:00:34 +0200 | |
---|---|---|
committer | 2021-11-03 10:07:10 +0100 | |
commit | cde82dea30d945eb82272f4a3c324b65d0259ee2 (patch) | |
tree | ced8dd84416b5a6fecc5afd8a2b423ed30a5f944 /macros/src/codegen/shared_resources.rs | |
parent | 7155b55ac8ff4e5f8860bd6f81c39d31756af633 (diff) | |
download | rtic-cde82dea30d945eb82272f4a3c324b65d0259ee2.tar.gz rtic-cde82dea30d945eb82272f4a3c324b65d0259ee2.tar.zst rtic-cde82dea30d945eb82272f4a3c324b65d0259ee2.zip |
api test (mostly hard coded)
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) } |