From d0a3d270948f870fd7add51149448c2164b3193d Mon Sep 17 00:00:00 2001 From: Per Lindgren Date: Wed, 3 Nov 2021 21:44:57 +0100 Subject: [PATCH] wip tests do pass, Mutex based --- macros/src/codegen/hardware_tasks.rs | 2 +- macros/src/codegen/idle.rs | 2 +- macros/src/codegen/shared_resources_struct.rs | 2 +- macros/src/codegen/software_tasks.rs | 2 +- macros/src/codegen/util.rs | 2 +- src/export.rs | 4 ++-- src/lib.rs | 14 +++++++------- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/macros/src/codegen/hardware_tasks.rs b/macros/src/codegen/hardware_tasks.rs index da0d6441c5..20b06cc7f7 100644 --- a/macros/src/codegen/hardware_tasks.rs +++ b/macros/src/codegen/hardware_tasks.rs @@ -99,7 +99,7 @@ pub fn codegen( #[allow(non_snake_case)] fn #name(#context: #name::Context) { use rtic::Mutex as _; - use rtic::MutexStruct as _; + // use rtic::MutexStruct as _; use rtic::mutex_prelude::*; #(#stmts)* diff --git a/macros/src/codegen/idle.rs b/macros/src/codegen/idle.rs index 718ed2617e..23200b79c4 100644 --- a/macros/src/codegen/idle.rs +++ b/macros/src/codegen/idle.rs @@ -73,7 +73,7 @@ pub fn codegen( #[allow(non_snake_case)] fn #name(#context: #name::Context) -> ! { use rtic::Mutex as _; - use rtic::MutexStruct as _; + // use rtic::MutexStruct as _; use rtic::mutex_prelude::*; #(#stmts)* diff --git a/macros/src/codegen/shared_resources_struct.rs b/macros/src/codegen/shared_resources_struct.rs index ababbd8a1b..eed8f896a1 100644 --- a/macros/src/codegen/shared_resources_struct.rs +++ b/macros/src/codegen/shared_resources_struct.rs @@ -177,7 +177,7 @@ pub fn codegen( quote!(#ident_mut<#lt>), max_ceiling, quote!(self.priority()), - quote!(|| { #ident_mut::new() }), + quote!(#ident_mut::new ), ), quote!( // Used by the lock-all API diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 56779c7b61..9ccba71c2b 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -132,7 +132,7 @@ pub fn codegen( #[allow(non_snake_case)] fn #name(#context: #name::Context #(,#inputs)*) { use rtic::Mutex as _; - use rtic::MutexStruct as _; + // use rtic::MutexStruct as _; use rtic::mutex_prelude::*; #(#stmts)* diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index 7a4c58ce32..f2ed62ad8d 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -67,7 +67,7 @@ pub fn impl_mutex_struct( let device = &extra.device; quote!( #(#cfgs)* - impl<'a> rtic::MutexStruct for #path<'a> { + impl<'a> rtic::Mutex for #path<'a> { type T = #ty; #[inline(always)] diff --git a/src/export.rs b/src/export.rs index 07a41d73d5..df4d86fcf8 100644 --- a/src/export.rs +++ b/src/export.rs @@ -171,7 +171,7 @@ pub unsafe fn lock( #[cfg(armv7m)] #[inline(always)] pub unsafe fn lock_struct( - ptr: impl Fn() -> T, + ptr: unsafe fn() -> T, priority: &Priority, ceiling: u8, nvic_prio_bits: u8, @@ -237,7 +237,7 @@ pub unsafe fn lock( #[cfg(not(armv7m))] #[inline(always)] pub unsafe fn lock_struct( - ptr: impl Fn() -> T, + ptr: unsafe fn() -> T, priority: &Priority, ceiling: u8, _nvic_prio_bits: u8, diff --git a/src/lib.rs b/src/lib.rs index bb331e9fa8..78867d2710 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -105,11 +105,11 @@ impl RacyCell { unsafe impl Sync for RacyCell {} -/// Should be moved to `rtic-core` -pub trait MutexStruct { - /// Data protected by the mutex - type T; +// /// Should be moved to `rtic-core` +// pub trait MutexStruct { +// /// Data protected by the mutex +// type T; - /// Creates a critical section and grants temporary access to the protected data - fn lock(&mut self, f: impl FnOnce(&mut Self::T) -> R) -> R; -} +// /// Creates a critical section and grants temporary access to the protected data +// fn lock(&mut self, f: impl FnOnce(&mut Self::T) -> R) -> R; +// }