Merge #555
555: Use cortex-m only on cortex-m archs. r=Dirbaio a=Dirbaio Without this, build fails for iOS. Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
commit
7561fa1934
@ -29,7 +29,6 @@ executor-agnostic = []
|
|||||||
defmt = { version = "0.3", optional = true }
|
defmt = { version = "0.3", optional = true }
|
||||||
log = { version = "0.4.14", optional = true }
|
log = { version = "0.4.14", optional = true }
|
||||||
|
|
||||||
cortex-m = "0.7.3"
|
|
||||||
futures = { version = "0.3.17", default-features = false, features = [ "cfg-target-has-atomic", "unstable" ] }
|
futures = { version = "0.3.17", default-features = false, features = [ "cfg-target-has-atomic", "unstable" ] }
|
||||||
pin-project = { version = "1.0.8", default-features = false }
|
pin-project = { version = "1.0.8", default-features = false }
|
||||||
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
|
||||||
@ -38,12 +37,28 @@ atomic-polyfill = "0.1.5"
|
|||||||
critical-section = "0.2.5"
|
critical-section = "0.2.5"
|
||||||
embedded-hal = "0.2.6"
|
embedded-hal = "0.2.6"
|
||||||
heapless = "0.7.5"
|
heapless = "0.7.5"
|
||||||
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
# WASM dependencies
|
# WASM dependencies
|
||||||
wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true }
|
wasm-bindgen = { version = "0.2.76", features = ["nightly"], optional = true }
|
||||||
js-sys = { version = "0.3", optional = true }
|
js-sys = { version = "0.3", optional = true }
|
||||||
wasm-timer = { version = "0.2.5", optional = true }
|
wasm-timer = { version = "0.2.5", optional = true }
|
||||||
|
|
||||||
|
[target."thumbv6m-none-eabi".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
[target."thumbv7m-none-eabi".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
[target."thumbv7em-none-eabi".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
[target."thumbv7em-none-eabihf".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
[target."thumbv8m.base-none-eabi".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
[target."thumbv8m.main-none-eabi".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
[target."thumbv8m.main-none-eabihf".dependencies]
|
||||||
|
cortex-m = "0.7.3"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
embassy = { path = ".", features = ["executor-agnostic"] }
|
embassy = { path = ".", features = ["executor-agnostic"] }
|
||||||
futures-executor = { version = "0.3.17", features = [ "thread-pool" ] }
|
futures-executor = { version = "0.3.17", features = [ "thread-pool" ] }
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
use super::{CriticalSectionMutex, Mutex, NoopMutex, ThreadModeMutex};
|
|
||||||
|
|
||||||
pub trait MutexKind {
|
pub trait MutexKind {
|
||||||
type Mutex<T>: Mutex<Data = T>;
|
type Mutex<T>: super::Mutex<Data = T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CriticalSection {}
|
pub enum CriticalSection {}
|
||||||
impl MutexKind for CriticalSection {
|
impl MutexKind for CriticalSection {
|
||||||
type Mutex<T> = CriticalSectionMutex<T>;
|
type Mutex<T> = super::CriticalSectionMutex<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(cortex_m, feature = "std"))]
|
||||||
pub enum ThreadMode {}
|
pub enum ThreadMode {}
|
||||||
|
#[cfg(any(cortex_m, feature = "std"))]
|
||||||
impl MutexKind for ThreadMode {
|
impl MutexKind for ThreadMode {
|
||||||
type Mutex<T> = ThreadModeMutex<T>;
|
type Mutex<T> = super::ThreadModeMutex<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Noop {}
|
pub enum Noop {}
|
||||||
impl MutexKind for Noop {
|
impl MutexKind for Noop {
|
||||||
type Mutex<T> = NoopMutex<T>;
|
type Mutex<T> = super::NoopMutex<T>;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,12 @@ impl<T> Mutex for CriticalSectionMutex<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(cortex_m, feature = "std"))]
|
||||||
|
pub use thread_mode_mutex::*;
|
||||||
|
#[cfg(any(cortex_m, feature = "std"))]
|
||||||
|
mod thread_mode_mutex {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
/// A "mutex" that only allows borrowing from thread mode.
|
/// A "mutex" that only allows borrowing from thread mode.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
@ -132,6 +138,7 @@ pub fn in_thread_mode() -> bool {
|
|||||||
return cortex_m::peripheral::SCB::vect_active()
|
return cortex_m::peripheral::SCB::vect_active()
|
||||||
== cortex_m::peripheral::scb::VectActive::ThreadMode;
|
== cortex_m::peripheral::scb::VectActive::ThreadMode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// A "mutex" that does nothing and cannot be shared between threads.
|
/// A "mutex" that does nothing and cannot be shared between threads.
|
||||||
pub struct NoopMutex<T> {
|
pub struct NoopMutex<T> {
|
||||||
|
@ -2,12 +2,25 @@
|
|||||||
|
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
#[cfg_attr(feature = "std", path = "arch/std.rs")]
|
cfg_if::cfg_if! {
|
||||||
#[cfg_attr(feature = "wasm", path = "arch/wasm.rs")]
|
if #[cfg(cortex_m)] {
|
||||||
#[cfg_attr(not(any(feature = "std", feature = "wasm")), path = "arch/arm.rs")]
|
#[path="arch/cortex_m.rs"]
|
||||||
mod arch;
|
mod arch;
|
||||||
pub mod raw;
|
|
||||||
mod spawner;
|
|
||||||
|
|
||||||
pub use arch::*;
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
else if #[cfg(feature="wasm")] {
|
||||||
|
#[path="arch/wasm.rs"]
|
||||||
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
else if #[cfg(feature="std")] {
|
||||||
|
#[path="arch/std.rs"]
|
||||||
|
mod arch;
|
||||||
|
pub use arch::*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod raw;
|
||||||
|
|
||||||
|
mod spawner;
|
||||||
pub use spawner::*;
|
pub use spawner::*;
|
||||||
|
@ -13,6 +13,7 @@ pub mod channel;
|
|||||||
pub mod waitqueue;
|
pub mod waitqueue;
|
||||||
|
|
||||||
pub mod executor;
|
pub mod executor;
|
||||||
|
#[cfg(cortex_m)]
|
||||||
pub mod interrupt;
|
pub mod interrupt;
|
||||||
pub mod io;
|
pub mod io;
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "time")]
|
||||||
|
Loading…
Reference in New Issue
Block a user