mirror of
https://github.com/rtic-rs/rtic.git
synced 2025-12-19 06:15:45 +01:00
split macro parser into its own crate and improve error handling / reporting
This commit is contained in:
parent
59afbf02aa
commit
98596554b3
10 changed files with 511 additions and 961 deletions
28
src/lib.rs
28
src/lib.rs
|
|
@ -82,6 +82,14 @@ impl<P> Peripheral<P> {
|
|||
Peripheral { peripheral }
|
||||
}
|
||||
|
||||
#[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,
|
||||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue