split macro parser into its own crate and improve error handling / reporting

This commit is contained in:
Jorge Aparicio 2017-07-14 18:54:54 -05:00
parent 59afbf02aa
commit 98596554b3
10 changed files with 511 additions and 961 deletions

View file

@ -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)]