mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-25 21:19:35 +01:00
wip tests do pass, Mutex based
This commit is contained in:
parent
b138cc1631
commit
d0a3d27094
7 changed files with 14 additions and 14 deletions
|
@ -99,7 +99,7 @@ pub fn codegen(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn #name(#context: #name::Context) {
|
fn #name(#context: #name::Context) {
|
||||||
use rtic::Mutex as _;
|
use rtic::Mutex as _;
|
||||||
use rtic::MutexStruct as _;
|
// use rtic::MutexStruct as _;
|
||||||
use rtic::mutex_prelude::*;
|
use rtic::mutex_prelude::*;
|
||||||
|
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
|
|
|
@ -73,7 +73,7 @@ pub fn codegen(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn #name(#context: #name::Context) -> ! {
|
fn #name(#context: #name::Context) -> ! {
|
||||||
use rtic::Mutex as _;
|
use rtic::Mutex as _;
|
||||||
use rtic::MutexStruct as _;
|
// use rtic::MutexStruct as _;
|
||||||
use rtic::mutex_prelude::*;
|
use rtic::mutex_prelude::*;
|
||||||
|
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
|
|
|
@ -177,7 +177,7 @@ pub fn codegen(
|
||||||
quote!(#ident_mut<#lt>),
|
quote!(#ident_mut<#lt>),
|
||||||
max_ceiling,
|
max_ceiling,
|
||||||
quote!(self.priority()),
|
quote!(self.priority()),
|
||||||
quote!(|| { #ident_mut::new() }),
|
quote!(#ident_mut::new ),
|
||||||
),
|
),
|
||||||
quote!(
|
quote!(
|
||||||
// Used by the lock-all API
|
// Used by the lock-all API
|
||||||
|
|
|
@ -132,7 +132,7 @@ pub fn codegen(
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
fn #name(#context: #name::Context #(,#inputs)*) {
|
fn #name(#context: #name::Context #(,#inputs)*) {
|
||||||
use rtic::Mutex as _;
|
use rtic::Mutex as _;
|
||||||
use rtic::MutexStruct as _;
|
// use rtic::MutexStruct as _;
|
||||||
use rtic::mutex_prelude::*;
|
use rtic::mutex_prelude::*;
|
||||||
|
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
|
|
|
@ -67,7 +67,7 @@ pub fn impl_mutex_struct(
|
||||||
let device = &extra.device;
|
let device = &extra.device;
|
||||||
quote!(
|
quote!(
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
impl<'a> rtic::MutexStruct for #path<'a> {
|
impl<'a> rtic::Mutex for #path<'a> {
|
||||||
type T = #ty;
|
type T = #ty;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
|
@ -171,7 +171,7 @@ pub unsafe fn lock<T, R>(
|
||||||
#[cfg(armv7m)]
|
#[cfg(armv7m)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lock_struct<T, R>(
|
pub unsafe fn lock_struct<T, R>(
|
||||||
ptr: impl Fn() -> T,
|
ptr: unsafe fn() -> T,
|
||||||
priority: &Priority,
|
priority: &Priority,
|
||||||
ceiling: u8,
|
ceiling: u8,
|
||||||
nvic_prio_bits: u8,
|
nvic_prio_bits: u8,
|
||||||
|
@ -237,7 +237,7 @@ pub unsafe fn lock<T, R>(
|
||||||
#[cfg(not(armv7m))]
|
#[cfg(not(armv7m))]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub unsafe fn lock_struct<T, R>(
|
pub unsafe fn lock_struct<T, R>(
|
||||||
ptr: impl Fn() -> T,
|
ptr: unsafe fn() -> T,
|
||||||
priority: &Priority,
|
priority: &Priority,
|
||||||
ceiling: u8,
|
ceiling: u8,
|
||||||
_nvic_prio_bits: u8,
|
_nvic_prio_bits: u8,
|
||||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -105,11 +105,11 @@ impl<T> RacyCell<T> {
|
||||||
|
|
||||||
unsafe impl<T> Sync for RacyCell<T> {}
|
unsafe impl<T> Sync for RacyCell<T> {}
|
||||||
|
|
||||||
/// Should be moved to `rtic-core`
|
// /// Should be moved to `rtic-core`
|
||||||
pub trait MutexStruct {
|
// pub trait MutexStruct {
|
||||||
/// Data protected by the mutex
|
// /// Data protected by the mutex
|
||||||
type T;
|
// type T;
|
||||||
|
|
||||||
/// Creates a critical section and grants temporary access to the protected data
|
// /// Creates a critical section and grants temporary access to the protected data
|
||||||
fn lock<R>(&mut self, f: impl FnOnce(&mut Self::T) -> R) -> R;
|
// fn lock<R>(&mut self, f: impl FnOnce(&mut Self::T) -> R) -> R;
|
||||||
}
|
// }
|
||||||
|
|
Loading…
Reference in a new issue