diff options
author | 2017-07-14 18:54:54 -0500 | |
---|---|---|
committer | 2017-07-14 18:57:02 -0500 | |
commit | 98596554b3d88a7619bdbc3ac7462a95b7263e96 (patch) | |
tree | b04a8e1e6011f741e045044389e6189d49abf78a /src | |
parent | 59afbf02aa06d976dfd22df4cb87fadf6027a0fb (diff) | |
download | rtic-98596554b3d88a7619bdbc3ac7462a95b7263e96.tar.gz rtic-98596554b3d88a7619bdbc3ac7462a95b7263e96.tar.zst rtic-98596554b3d88a7619bdbc3ac7462a95b7263e96.zip |
split macro parser into its own crate and improve error handling / reporting
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -83,6 +83,14 @@ impl<P> Peripheral<P> { } #[inline(always)] + pub unsafe fn borrow<'cs>( + &'static self, + _cs: &'cs CriticalSection, + ) -> &'cs P { + &*self.peripheral.get() + } + + #[inline(always)] pub unsafe fn claim<R, F>( &'static self, ceiling: u8, @@ -123,7 +131,25 @@ pub struct Resource<T> { impl<T> Resource<T> { pub const fn new(value: T) -> Self { - Resource { data: UnsafeCell::new(value) } + Resource { + data: UnsafeCell::new(value), + } + } + + #[inline(always)] + pub unsafe fn borrow<'cs>( + &'static self, + _cs: &'cs CriticalSection, + ) -> &'cs Static<T> { + Static::ref_(&*self.data.get()) + } + + #[inline(always)] + pub unsafe fn borrow_mut<'cs>( + &'static self, + _cs: &'cs CriticalSection, + ) -> &'cs mut Static<T> { + Static::ref_mut(&mut *self.data.get()) } #[inline(always)] |